From 7bf0f75bf1fcc000b6c3d5b63a2280f9e5d27e64 Mon Sep 17 00:00:00 2001 From: Kye Date: Sat, 11 Nov 2023 17:48:07 -0500 Subject: [PATCH] fuyu attempted fix Former-commit-id: bcf2b888739eaeac8747ec30eec06cb8c04e9eeb --- pyproject.toml | 2 +- swarms/models/fuyu.py | 13 ++++++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 267342242..d1dfd8295 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api" [tool.poetry] name = "swarms" -version = "2.2.0" +version = "2.2.1" description = "Swarms - Pytorch" license = "MIT" authors = ["Kye Gomez "] diff --git a/swarms/models/fuyu.py b/swarms/models/fuyu.py index dd664f516..bba2068c9 100644 --- a/swarms/models/fuyu.py +++ b/swarms/models/fuyu.py @@ -75,6 +75,13 @@ def __call__(self, text: str, img: str): def get_img_from_web(self, img_url: str): """Get the image from the web""" - response = requests.get(img_url) - image_pil = Image.open(BytesIO(response.content)) - return image_pil + try: + response = requests.get(img_url) + response.raise_for_status() + image_pil = Image.open(BytesIO(response.content)) + return image_pil + except requests.RequestException as error: + print(f"Error fetching image from {img_url} and error: {error}") + return None + + \ No newline at end of file