hwberry2 commited on
Commit
39f82d8
·
1 Parent(s): 70ae181

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -2
app.py CHANGED
@@ -43,6 +43,14 @@ with gr.Blocks() as demo:
43
  test_loss, test_acc = model.evaluate(x_test, y_test, verbose=2)
44
 
45
  return('\nTest accuracy:', test_acc)
 
 
 
 
 
 
 
 
46
 
47
 
48
  # Creates the Gradio interface objects
@@ -50,8 +58,11 @@ with gr.Blocks() as demo:
50
  with gr.Column(scale=1):
51
  submit_btn = gr.Button(value="Train/Eval")
52
  with gr.Column(scale=2):
53
- model_data = gr.Text(label="Model Results", interactive=False)
54
- submit_btn.click(modelTraining, [], model_data)
 
 
 
55
 
56
 
57
  # creates a local web server
 
43
  test_loss, test_acc = model.evaluate(x_test, y_test, verbose=2)
44
 
45
  return('\nTest accuracy:', test_acc)
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(preprocessed_img)
51
+
52
+ # Postprocess the prediction and return it
53
+ return prediction
54
 
55
 
56
  # Creates the Gradio interface objects
 
58
  with gr.Column(scale=1):
59
  submit_btn = gr.Button(value="Train/Eval")
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
 
67
 
68
  # creates a local web server