Viet commited on
Commit
bf10465
1 Parent(s): 83ae382

update .gitattributes so git lfs will track .pkl files

Browse files
Files changed (1) hide show
  1. app.py +15 -10
app.py CHANGED
@@ -6,17 +6,22 @@ from PIL import Image
6
 
7
  learn = load_learner('model.pkl')
8
 
 
9
  labels = learn.dls.vocab
10
- def predict(img):
11
- img = Image.open(img)
12
- pred,pred_idx,probs = learn.predict(img)
13
- return {labels[i]: float(probs[i]) for i in range(len(labels))}
14
 
15
- title = "Shark vs Bird Classifier"
16
- description = "A Shark vs Bird classifier trained using Duck Duck Go search engine with fastai. Created as a demo for Gradio and HuggingFace Spaces."
 
 
 
 
 
 
 
 
17
 
18
- examples = ['shark.jpg', 'bird.jpg']
19
- interpretation='default'
20
- enable_queue=True
21
 
22
- gr.Interface(fn=predict,inputs=gr.inputs.Image(shape=(512, 512)),outputs=gr.outputs.Label(num_top_classes=3),title=title,description=description,examples=examples,interpretation=interpretation,enable_queue=enable_queue).launch()
 
6
 
7
  learn = load_learner('model.pkl')
8
 
9
+
10
  labels = learn.dls.vocab
 
 
 
 
11
 
12
+ def greet(name): return f"Hello {name}!"
13
+ gr.Interface(fn=greet, inputs="text", outputs="text").launch()
14
+
15
+ # def predict(img):
16
+ # img = Image.open(img)
17
+ # pred,pred_idx,probs = learn.predict(img)
18
+ # return {labels[i]: float(probs[i]) for i in range(len(labels))}
19
+
20
+ # title = "Shark vs Bird Classifier"
21
+ # description = "A Shark vs Bird classifier trained using Duck Duck Go search engine with fastai. Created as a demo for Gradio and HuggingFace Spaces."
22
 
23
+ # examples = ['shark.jpg', 'bird.jpg']
24
+ # interpretation='default'
25
+ # enable_queue=True
26
 
27
+ # gr.Interface(fn=predict,inputs=gr.inputs.Image(shape=(512, 512)),outputs=gr.outputs.Label(num_top_classes=3),title=title,description=description,examples=examples,interpretation=interpretation,enable_queue=enable_queue).launch()