Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -40,14 +40,16 @@ with gr.Blocks() as demo:
|
|
| 40 |
|
| 41 |
|
| 42 |
model.fit(x_train, y_train, epochs=5)
|
| 43 |
-
test_loss, test_acc = model.evaluate(x_test, y_test, verbose=2)
|
| 44 |
|
| 45 |
-
|
|
|
|
|
|
|
| 46 |
|
| 47 |
def predict_image(img):
|
| 48 |
# Define any necessary preprocessing steps for the image input here
|
| 49 |
# Make a prediction using the model
|
| 50 |
-
prediction = model.predict(
|
| 51 |
|
| 52 |
# Postprocess the prediction and return it
|
| 53 |
return prediction
|
|
@@ -60,7 +62,7 @@ with gr.Blocks() as demo:
|
|
| 60 |
with gr.Column(scale=2):
|
| 61 |
model_performance = gr.Text(label="Model Performance", interactive=False)
|
| 62 |
model_prediction = gr.Text(label="Model Prediction", interactive=False)
|
| 63 |
-
image_data = gr.Image(label="Upload Image")
|
| 64 |
submit_btn.click(modelTraining, [], model_performance)
|
| 65 |
image_data.change(predict_image, image_data, model_prediction)
|
| 66 |
|
|
|
|
| 40 |
|
| 41 |
|
| 42 |
model.fit(x_train, y_train, epochs=5)
|
| 43 |
+
test_loss, test_acc = model.evaluate(x_test, y_test, verbose=2)]
|
| 44 |
|
| 45 |
+
result = "Test accuracy: ", test_acc
|
| 46 |
+
|
| 47 |
+
return result
|
| 48 |
|
| 49 |
def predict_image(img):
|
| 50 |
# Define any necessary preprocessing steps for the image input here
|
| 51 |
# Make a prediction using the model
|
| 52 |
+
prediction = model.predict(img)
|
| 53 |
|
| 54 |
# Postprocess the prediction and return it
|
| 55 |
return prediction
|
|
|
|
| 62 |
with gr.Column(scale=2):
|
| 63 |
model_performance = gr.Text(label="Model Performance", interactive=False)
|
| 64 |
model_prediction = gr.Text(label="Model Prediction", interactive=False)
|
| 65 |
+
image_data = gr.Image(label="Upload Image", type="numpy")
|
| 66 |
submit_btn.click(modelTraining, [], model_performance)
|
| 67 |
image_data.change(predict_image, image_data, model_prediction)
|
| 68 |
|