Spaces:
Runtime error
Runtime error
Update app.py
Browse files
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:
|
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()
|