Spaces:
Running
Running
Update utils.py
Browse files
utils.py
CHANGED
|
@@ -33,10 +33,10 @@ def load_model(model_id: str, token: str | None = None) -> Any:
|
|
| 33 |
|
| 34 |
def analyze(image_path: str | None, image_url: str | None, model_id: str, token: str | None = None):
|
| 35 |
"""Run inference and return classification scores."""
|
| 36 |
-
if not
|
| 37 |
raise gr.Error("Provide an image or URL")
|
| 38 |
|
| 39 |
-
img =
|
| 40 |
model = load_model(model_id, token)
|
| 41 |
results = model(img)
|
| 42 |
|
|
|
|
| 33 |
|
| 34 |
def analyze(image_path: str | None, image_url: str | None, model_id: str, token: str | None = None):
|
| 35 |
"""Run inference and return classification scores."""
|
| 36 |
+
if not image_path and not image_url:
|
| 37 |
raise gr.Error("Provide an image or URL")
|
| 38 |
|
| 39 |
+
img = Image.open(image_path).convert("RGB") if image_path else download_image(image_url)
|
| 40 |
model = load_model(model_id, token)
|
| 41 |
results = model(img)
|
| 42 |
|