Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions tests/model_hub_tests/jax/test_hf_transformers.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ def load_model(self, model_name, _):
model = FlaxAutoModel.from_pretrained(model_name)
if model_name in ['google/vit-base-patch16-224-in21k']:
url = "http://images.cocodataset.org/val2017/000000039769.jpg"
image = Image.open(requests.get(url, stream=True).raw)
response = requests.get(url, stream=True)
response.raise_for_status()
image = Image.open(response.raw)
image_processor = AutoImageProcessor.from_pretrained(model_name)
self.example = image_processor(images=image, return_tensors="np")
elif model_name in ['albert/albert-base-v2', 'facebook/bart-base', 'ksmcg/Mistral-tiny']:
Expand All @@ -34,7 +36,9 @@ def load_model(self, model_name, _):
elif model_name in ['openai/clip-vit-base-patch32']:
processor = AutoProcessor.from_pretrained(model_name)
url = "http://images.cocodataset.org/val2017/000000039769.jpg"
image = Image.open(requests.get(url, stream=True).raw)
response = requests.get(url, stream=True)
response.raise_for_status()
image = Image.open(response.raw)
self.example = processor(text=["a photo of a cat", "a photo of a dog"],
images=image, return_tensors="np", padding=True)
if isinstance(self.example, BatchFeature):
Expand Down
4 changes: 3 additions & 1 deletion tests/model_hub_tests/pytorch/test_detectron2.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ def setup_class(self):
import requests

url = "http://images.cocodataset.org/val2017/000000039769.jpg"
self.image = Image.open(requests.get(url, stream=True).raw)
response = requests.get(url, stream=True)
response.raise_for_status()
self.image = Image.open(response.raw)
self.image = self.image.resize([640, 480])

subprocess.run([sys.executable, "-m", "pip", "install",
Expand Down
4 changes: 3 additions & 1 deletion tests/model_hub_tests/pytorch/test_hf_transformers.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@ def setup_class(self):
self.infer_timeout = 1800

url = "http://images.cocodataset.org/val2017/000000039769.jpg"
self.image = Image.open(requests.get(url, stream=True).raw)
response = requests.get(url, stream=True)
response.raise_for_status()
self.image = Image.open(response.raw)

@retry(3, exceptions=(OSError,), delay=1)
def load_model(self, name, type):
Expand Down
Loading