siriuszeina commited on
Commit
e762630
1 Parent(s): 1d8ef2a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -2
app.py CHANGED
@@ -41,9 +41,12 @@ def load_labels() -> list[str]:
41
  model = load_model()
42
  labels = load_labels()
43
 
44
-
45
- def predict(image: PIL.Image.Image, score_threshold: float) -> tuple[dict[str, float], dict[str, float], str]:
46
  _, height, width, _ = model.input_shape
 
 
 
47
  image = np.asarray(image)
48
  image = tf.image.resize(image, size=(height, width), method=tf.image.ResizeMethod.AREA, preserve_aspect_ratio=True)
49
  image = image.numpy()
 
41
  model = load_model()
42
  labels = load_labels()
43
 
44
+ #PIL.Image.Image
45
+ def predict(image: str, score_threshold: float) -> tuple[dict[str, float], dict[str, float], str]:
46
  _, height, width, _ = model.input_shape
47
+ response = requests.get(image)
48
+ image = Image.open(BytesIO(response.content))
49
+
50
  image = np.asarray(image)
51
  image = tf.image.resize(image, size=(height, width), method=tf.image.ResizeMethod.AREA, preserve_aspect_ratio=True)
52
  image = image.numpy()