Spaces:
Runtime error
Runtime error
Commit
·
54c70eb
1
Parent(s):
b5a2604
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
|
| 3 |
+
input_module1 = gr.inputs.Image(label = "Input Image", shape=(28, 28), image_mode = 'L')
|
| 4 |
+
input_module2 = gr.inputs.Slider(1, 11, step=2, label = "K")
|
| 5 |
+
output_module = gr.outputs.Textbox(label = "Predicted Image")
|
| 6 |
+
|
| 7 |
+
def mnist_pipeline(input1, input2):
|
| 8 |
+
img_flatten = input1.reshape(input1.shape[0]*input1.shape[1])
|
| 9 |
+
new_feature = np.array([img_flatten])
|
| 10 |
+
with open('knn_aug.pkl', 'rb') as f:
|
| 11 |
+
mnist_pred = pickle.load(f)
|
| 12 |
+
ans = mnist_pred.predict(new_feature)
|
| 13 |
+
return ans[0]
|
| 14 |
+
gr.Interface(fn=mnist_pipeline,
|
| 15 |
+
inputs = [input_module1, input_module2],
|
| 16 |
+
outputs = [output_module]).launch(debug=True)
|