fcakyon commited on
Commit
331e0bb
·
verified ·
1 Parent(s): e189a6a

Update utils.py

Browse files
Files changed (1) hide show
  1. utils.py +2 -2
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 image_url and not image_path:
37
  raise gr.Error("Provide an image or URL")
38
 
39
- img = download_image(image_url) if image_url else Image.open(image_path).convert("RGB")
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