jiehou commited on
Commit
aff1e76
·
1 Parent(s): ce34bb9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -3
app.py CHANGED
@@ -121,8 +121,8 @@ def KNN_predict(train_features, train_labels, test_feature, K):
121
  ### main function for gradio to call to classify image
122
  def call_our_KNN(test_image, K=7):
123
  test_image_flatten = test_image.reshape((-1, 28*28))
124
- y_pred_each, image_path = KNN_predict(train_features, train_labels, test_image_flatten, int(K))
125
- return y_pred_each, image_path
126
 
127
 
128
  ### generate several example cases
@@ -133,13 +133,13 @@ set_image = gr.inputs.Image(shape=(28, 28), image_mode='L')
133
  set_K = gr.inputs.Slider(1, 24, step=1, default=7)
134
 
135
  set_label = gr.outputs.Textbox(label="Predicted Digit")
 
136
  # define output as the single class text
137
  set_probability = gr.outputs.Label(num_top_classes=10, label="Predicted Class")
138
 
139
  set_out_images = gr.outputs.Image(label="Closest Neighbors")
140
 
141
 
142
-
143
  ### configure gradio, detailed can be found at https://www.gradio.app/docs/#i_slider
144
  interface = gr.Interface(fn=call_our_KNN,
145
  inputs=[set_image, set_K],
 
121
  ### main function for gradio to call to classify image
122
  def call_our_KNN(test_image, K=7):
123
  test_image_flatten = test_image.reshape((-1, 28*28))
124
+ y_pred_each, y_prob_each, image_path = KNN_predict(train_features, train_labels, test_image_flatten, int(K))
125
+ return y_pred_each, y_prob_each, image_path
126
 
127
 
128
  ### generate several example cases
 
133
  set_K = gr.inputs.Slider(1, 24, step=1, default=7)
134
 
135
  set_label = gr.outputs.Textbox(label="Predicted Digit")
136
+
137
  # define output as the single class text
138
  set_probability = gr.outputs.Label(num_top_classes=10, label="Predicted Class")
139
 
140
  set_out_images = gr.outputs.Image(label="Closest Neighbors")
141
 
142
 
 
143
  ### configure gradio, detailed can be found at https://www.gradio.app/docs/#i_slider
144
  interface = gr.Interface(fn=call_our_KNN,
145
  inputs=[set_image, set_K],