Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -35,8 +35,11 @@ def predict():
|
|
| 35 |
if not file:
|
| 36 |
return jsonify({'error': 'No image provided'}), 400
|
| 37 |
|
| 38 |
-
img = preprocess_image(file.read())
|
| 39 |
-
|
|
|
|
|
|
|
|
|
|
| 40 |
sorted_indices = np.argsort(pred)[::-1]
|
| 41 |
top1, top2 = sorted_indices[:2]
|
| 42 |
top1_label = class_names[top1]
|
|
|
|
| 35 |
if not file:
|
| 36 |
return jsonify({'error': 'No image provided'}), 400
|
| 37 |
|
| 38 |
+
img = preprocess_image(file.read()).astype(np.float32)
|
| 39 |
+
interpreter.set_tensor(input_details[0]['index'], img)
|
| 40 |
+
interpreter.invoke()
|
| 41 |
+
pred = interpreter.get_tensor(output_details[0]['index'])[0]
|
| 42 |
+
|
| 43 |
sorted_indices = np.argsort(pred)[::-1]
|
| 44 |
top1, top2 = sorted_indices[:2]
|
| 45 |
top1_label = class_names[top1]
|