Spaces:
Sleeping
Sleeping
Commit
·
355aa9e
1
Parent(s):
357e1a3
Update model.py
Browse files
model.py
CHANGED
|
@@ -12,6 +12,7 @@ from uuid import uuid4
|
|
| 12 |
from PIL import Image
|
| 13 |
|
| 14 |
from creds import get_credentials
|
|
|
|
| 15 |
|
| 16 |
|
| 17 |
def generate_download_signed_url_v4(blob_name):
|
|
@@ -37,8 +38,8 @@ def generate_download_signed_url_v4(blob_name):
|
|
| 37 |
|
| 38 |
# print("Generated GET signed URL:")
|
| 39 |
# print(url)
|
| 40 |
-
|
| 41 |
-
|
| 42 |
return url
|
| 43 |
|
| 44 |
|
|
@@ -59,8 +60,9 @@ class Model(LabelStudioMLBase):
|
|
| 59 |
|
| 60 |
|
| 61 |
url = task["data"]["image"]
|
| 62 |
-
|
| 63 |
-
|
|
|
|
| 64 |
|
| 65 |
original_width, original_height = image.size
|
| 66 |
with torch.no_grad():
|
|
|
|
| 12 |
from PIL import Image
|
| 13 |
|
| 14 |
from creds import get_credentials
|
| 15 |
+
from io import BytesIO
|
| 16 |
|
| 17 |
|
| 18 |
def generate_download_signed_url_v4(blob_name):
|
|
|
|
| 38 |
|
| 39 |
# print("Generated GET signed URL:")
|
| 40 |
# print(url)
|
| 41 |
+
print("You can use this URL with any user agent, for example:")
|
| 42 |
+
print(f"curl '{url}'")
|
| 43 |
return url
|
| 44 |
|
| 45 |
|
|
|
|
| 60 |
|
| 61 |
|
| 62 |
url = task["data"]["image"]
|
| 63 |
+
response = requests.get(generate_download_signed_url_v4(url))
|
| 64 |
+
image_data = BytesIO(response.read())
|
| 65 |
+
image = Image.open(image_data)
|
| 66 |
|
| 67 |
original_width, original_height = image.size
|
| 68 |
with torch.no_grad():
|