From 087a22045029da2d85ff3abc78f6727dd67ae179 Mon Sep 17 00:00:00 2001 From: Lain Date: Sun, 7 Apr 2024 14:16:54 +0100 Subject: [PATCH] =?UTF-8?q?loadimg=20from=20=F0=9F=A4=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- setup.py | 2 +- src/loadimg/utils.py | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index e6a061e..da1be51 100644 --- a/setup.py +++ b/setup.py @@ -3,7 +3,7 @@ setup( name="loadimg", - version="0.1.1", + version="0.1.2", description="a python package for loading images", long_description=pathlib.Path("README.md").read_text(encoding="utf-8"), long_description_content_type="text/markdown", diff --git a/src/loadimg/utils.py b/src/loadimg/utils.py index 8ec9d80..3d82ab0 100644 --- a/src/loadimg/utils.py +++ b/src/loadimg/utils.py @@ -15,10 +15,12 @@ def download_image(url: str): try: if "github" in url and "raw=true" not in url: url += "?raw=true" - if "drive" in url and "uc?id=" not in url: + elif "drive" in url and "uc?id=" not in url: if "/view" in url or url.endswith("/"): url = "/".join(url.split("/")[:-1]) url = "https://drive.google.com/uc?id=" + url.split("/")[-1] + elif "hf.co" or "huggingface.co" in url : + url = url.replace("/blob/","/resolve") response = requests.get(url, timeout=5) # Timeout set to 5 seconds response.raise_for_status() # Raise an exception for HTTP errors return Image.open(BytesIO(response.content))