seyma9gulsen commited on
Commit
dbc7ca3
·
1 Parent(s): e09dd67

first commit

Browse files
Files changed (3) hide show
  1. app.py +24 -0
  2. model_mnist.pkl +3 -0
  3. requirements.txt +2 -0
app.py ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from fastai.vision.all import *
3
+ import pathlib
4
+ import os
5
+
6
+ # Load the exported model
7
+ learn = load_learner("model.pkl")
8
+
9
+ # Define prediction function
10
+ def predict(img):
11
+ pred, pred_idx, probs = learn.predict(img)
12
+ return f"Prediction: {pred} (Confidence: {probs[pred_idx]:.4f})"
13
+
14
+ # Create Gradio interface
15
+ interface = gr.Interface(
16
+ fn=predict,
17
+ inputs=gr.Image(type="pil", label="Upload a digit image (3 or 7 only)"),
18
+ outputs="text",
19
+ title="MNIST Digit Classifier (3 vs 7)",
20
+ description="Upload an image of a handwritten digit. Only digits 3 and 7 will work!"
21
+ )
22
+
23
+ if __name__ == "__main__":
24
+ interface.launch()
model_mnist.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:267c795658e8d9d63ccec667fd1e1b9feddfeace368cf22f060ac9531d9f2c78
3
+ size 87663138
requirements.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ fastai==2.7.12
2
+ gradio==4.26.0