Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -11,27 +11,15 @@ model_path = "IYRI1.h5"
|
|
| 11 |
# Load the model and label encoder
|
| 12 |
model = load_model(model_path)
|
| 13 |
|
| 14 |
-
|
| 15 |
-
def
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
# Make predictions
|
| 23 |
-
prediction = model.predict(image)
|
| 24 |
-
predicted_class = label_encoder.inverse_transform(np.argmax(prediction))
|
| 25 |
-
|
| 26 |
-
return predicted_class[0]
|
| 27 |
-
|
| 28 |
-
# Define the input and output interfaces
|
| 29 |
-
input_image = gr.inputs.Image(shape=(100, 100))
|
| 30 |
-
output_text = gr.outputs.Textbox()
|
| 31 |
-
|
| 32 |
-
# Create the Gradio interface
|
| 33 |
-
iface = gr.Interface(fn=predict_image, inputs=input_image, outputs=output_text, title="Dog Cat Classifier",
|
| 34 |
-
server_name="localhost", server_port=8000, share = True, debug=True)
|
| 35 |
|
|
|
|
| 36 |
|
|
|
|
| 37 |
iface.launch()
|
|
|
|
| 11 |
# Load the model and label encoder
|
| 12 |
model = load_model(model_path)
|
| 13 |
|
| 14 |
+
class_names = ["Cat", "Dog"]
|
| 15 |
+
def predict_input_image(img):
|
| 16 |
+
img_4d=img.reshape(-1,100,100,3)
|
| 17 |
+
prediction=model.predict(img_4d)[0]
|
| 18 |
+
return {class_names[i]: float(prediction[i]) for i in range(2)}
|
| 19 |
+
image = gr.inputs.Image(shape=(100,100))
|
| 20 |
+
label = gr.outputs.Label(num_top_classes=2)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
|
| 22 |
+
iface = gr.Interface(fn=predict_input_image, inputs=image, outputs=label,title="IYRI Classifier 1",interpretation='default').launch(debug='True')
|
| 23 |
|
| 24 |
+
# Run the Gradio interface
|
| 25 |
iface.launch()
|