mirror of
https://github.com/huggingface/transformers.git
synced 2025-07-18 20:18:24 +06:00
parent
7f95372c62
commit
c8c8dffbe4
@ -45,7 +45,7 @@ url_2 = "http://images.cocodataset.org/val2017/000000219578.jpg"
|
|||||||
image_1 = Image.open(requests.get(url_1, stream=True).raw)
|
image_1 = Image.open(requests.get(url_1, stream=True).raw)
|
||||||
image_2 = Image.open(requests.get(url_2, stream=True).raw)
|
image_2 = Image.open(requests.get(url_2, stream=True).raw)
|
||||||
|
|
||||||
model_id = "jmtzt/ijepa_vith14_1k"
|
model_id = "facebook/ijepa_vith14_1k"
|
||||||
processor = AutoProcessor.from_pretrained(model_id)
|
processor = AutoProcessor.from_pretrained(model_id)
|
||||||
model = AutoModel.from_pretrained(model_id)
|
model = AutoModel.from_pretrained(model_id)
|
||||||
|
|
||||||
|
@ -155,7 +155,7 @@ class IJepaModel(IJepaPreTrainedModel, ViTModel):
|
|||||||
self.embeddings = IJepaEmbeddings(config, use_mask_token=use_mask_token)
|
self.embeddings = IJepaEmbeddings(config, use_mask_token=use_mask_token)
|
||||||
|
|
||||||
|
|
||||||
_IMAGE_CLASS_CHECKPOINT = "jmtzt/ijepa_vith14_1k"
|
_IMAGE_CLASS_CHECKPOINT = "facebook/ijepa_vith14_1k"
|
||||||
_IMAGE_CLASS_EXPECTED_OUTPUT = "Egyptian cat"
|
_IMAGE_CLASS_EXPECTED_OUTPUT = "Egyptian cat"
|
||||||
|
|
||||||
|
|
||||||
|
@ -250,7 +250,7 @@ class IJepaModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.TestCase):
|
|||||||
|
|
||||||
@slow
|
@slow
|
||||||
def test_model_from_pretrained(self):
|
def test_model_from_pretrained(self):
|
||||||
model_name = "jmtzt/ijepa_vith14_1k"
|
model_name = "facebook/ijepa_vith14_1k"
|
||||||
model = IJepaModel.from_pretrained(model_name)
|
model = IJepaModel.from_pretrained(model_name)
|
||||||
self.assertIsNotNone(model)
|
self.assertIsNotNone(model)
|
||||||
|
|
||||||
@ -266,11 +266,11 @@ def prepare_img():
|
|||||||
class IJepaModelIntegrationTest(unittest.TestCase):
|
class IJepaModelIntegrationTest(unittest.TestCase):
|
||||||
@cached_property
|
@cached_property
|
||||||
def default_image_processor(self):
|
def default_image_processor(self):
|
||||||
return ViTImageProcessor.from_pretrained("jmtzt/ijepa_vith14_1k") if is_vision_available() else None
|
return ViTImageProcessor.from_pretrained("facebook/ijepa_vith14_1k") if is_vision_available() else None
|
||||||
|
|
||||||
@slow
|
@slow
|
||||||
def test_inference_no_head(self):
|
def test_inference_no_head(self):
|
||||||
model = IJepaModel.from_pretrained("jmtzt/ijepa_vith14_1k").to(torch_device)
|
model = IJepaModel.from_pretrained("facebook/ijepa_vith14_1k").to(torch_device)
|
||||||
|
|
||||||
image_processor = self.default_image_processor
|
image_processor = self.default_image_processor
|
||||||
image = prepare_img()
|
image = prepare_img()
|
||||||
@ -299,7 +299,7 @@ class IJepaModelIntegrationTest(unittest.TestCase):
|
|||||||
A small test to make sure that inference work in half precision without any problem.
|
A small test to make sure that inference work in half precision without any problem.
|
||||||
"""
|
"""
|
||||||
model = IJepaModel.from_pretrained(
|
model = IJepaModel.from_pretrained(
|
||||||
"jmtzt/ijepa_vith14_1k",
|
"facebook/ijepa_vith14_1k",
|
||||||
torch_dtype=torch.float16,
|
torch_dtype=torch.float16,
|
||||||
device_map="auto",
|
device_map="auto",
|
||||||
)
|
)
|
||||||
@ -319,7 +319,7 @@ class IJepaModelIntegrationTest(unittest.TestCase):
|
|||||||
# allowing to interpolate the pre-trained position embeddings in order to use
|
# allowing to interpolate the pre-trained position embeddings in order to use
|
||||||
# the model on higher resolutions. The DINO model by Facebook AI leverages this
|
# the model on higher resolutions. The DINO model by Facebook AI leverages this
|
||||||
# to visualize self-attention on higher resolution images.
|
# to visualize self-attention on higher resolution images.
|
||||||
model = IJepaModel.from_pretrained("jmtzt/ijepa_vith14_1k").to(torch_device)
|
model = IJepaModel.from_pretrained("facebook/ijepa_vith14_1k").to(torch_device)
|
||||||
|
|
||||||
image_processor = self.default_image_processor
|
image_processor = self.default_image_processor
|
||||||
image = prepare_img()
|
image = prepare_img()
|
||||||
|
Loading…
Reference in New Issue
Block a user