Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -39,14 +39,17 @@ def predict_image(image_path, model):
|
|
| 39 |
img = np.expand_dims(img, axis=0) # Add batch dimension
|
| 40 |
img = img / 255.0 # Normalize pixel values
|
| 41 |
if model == "Vgg19":
|
| 42 |
-
|
|
|
|
|
|
|
|
|
|
| 43 |
elif model == "Vgg16":
|
| 44 |
prediction = model_vgg16.run(None, {"input": img})[0]
|
| 45 |
elif model == "InceptionV3":
|
| 46 |
prediction = model_inceptionv3.run(None, {"input": img})[0]
|
| 47 |
elif model == "Resnet101":
|
| 48 |
prediction = model_resnet101.run(None, {"input": img})[0]
|
| 49 |
-
prediction = np.argmax(prediction)
|
| 50 |
pre_class = labels[prediction]
|
| 51 |
|
| 52 |
return pre_class
|
|
|
|
| 39 |
img = np.expand_dims(img, axis=0) # Add batch dimension
|
| 40 |
img = img / 255.0 # Normalize pixel values
|
| 41 |
if model == "Vgg19":
|
| 42 |
+
input_name = model_vgg19.get_inputs()[0].name
|
| 43 |
+
output_name= model_vgg19.get_outputs()[0].name
|
| 44 |
+
prediction = model_vgg19.run(None, {input_name: img})
|
| 45 |
+
|
| 46 |
elif model == "Vgg16":
|
| 47 |
prediction = model_vgg16.run(None, {"input": img})[0]
|
| 48 |
elif model == "InceptionV3":
|
| 49 |
prediction = model_inceptionv3.run(None, {"input": img})[0]
|
| 50 |
elif model == "Resnet101":
|
| 51 |
prediction = model_resnet101.run(None, {"input": img})[0]
|
| 52 |
+
prediction = np.argmax(prediction[0][0])
|
| 53 |
pre_class = labels[prediction]
|
| 54 |
|
| 55 |
return pre_class
|