AlexLinh12 commited on
Commit
9184687
Β·
1 Parent(s): 0e05e7c

initial commit

Browse files
Files changed (3) hide show
  1. .gitignore +7 -0
  2. app.py +18 -0
  3. requirements.txt +1 -0
.gitignore ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ flagged/
2
+ *.pkl
3
+ *.png
4
+ *.jpg
5
+ *.mp4
6
+ *.mkv
7
+ gradio_cached_examples/
app.py ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from fastai.vision.all import *
2
+ import gradio as gr
3
+
4
+ learn = load_learner('export.pkl')
5
+
6
+ labels = learn.dls.vocab
7
+ def predict(img):
8
+ img = PILImage.create(img)
9
+ pred,pred_idx,probs = learn.predict(img)
10
+ return {labels[i]: float(probs[i]) for i in range(len(labels))}
11
+
12
+ gr.Interface(
13
+ fn=predict,
14
+ inputs=gr.Image(type="pil", image_mode="RGB", height=512, width=512, sources=["upload"]),
15
+ outputs=gr.Label(num_top_classes=3),
16
+ title="Image Classifier",
17
+ description="Upload an image; the app resizes to 512Γ—512 inside predict()."
18
+ ).launch(share=True)
requirements.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ fastai