File size: 1,870 Bytes
52810f4
 
12655d2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
c0527cb
 
 
 
 
 
 
52810f4
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import gradio as gr


# %% drive/MyDrive/Colab Notebooks/fastbook/fastcourse/ch2minimal/tmabrahamgradio/gradiotest/gradiotest.ipynb 1
from fastai.vision.all import *
import skimage

# %% drive/MyDrive/Colab Notebooks/fastbook/fastcourse/ch2minimal/tmabrahamgradio/gradiotest/gradiotest.ipynb 4
learn = load_learner('export.pkl')

labels = learn.dls.vocab

def predict(img):
  img = PILImage.create(img)
  pred, pred_idx, probs = learn.predict(img)
  return {labels[i]: float(probs[i]) for i in range(len(labels))}




# %% drive/MyDrive/Colab Notebooks/fastbook/fastcourse/ch2minimal/tmabrahamgradio/gradiotest/gradiotest.ipynb 7
#gr.Interface(fn=predict, inputs=gr.Image(shape=(512,512)), outputs=gr.outputs.Label(num_top_classes=3), title="Pet Breed Classifier", description="A pet breed classifier trained on the Oxford Pets dataset using the fastai library (5 epochs) as a proof of concept for Gradio.", article="<p style='text-align: center'><a href='https://gameologist.com/portfolio' target='_blank'>see more of my things here</a></p>", examples=['abys.jpg', 'download (3).jpg'], enable_queue=True).launch()

#iface = gr.Interface(fn=predict, inputs=gr.Image(shape=(512,512)), outputs=gr.outputs.Label(num_top_classes=3))
#iface.launch();





#def greet(name):
 #   return "Hellooo " + name + "!!"

#iface = gr.Interface(fn=greet, inputs="text", outputs="text")


iface = gr.Interface(fn=predict, inputs=gr.Image(shape=(512,512)), outputs=gr.outputs.Label(num_top_classes=3), title="Pet Breed Classifier", description="A pet breed classifier trained on the Oxford Pets dataset using the fastai library (5 epochs) as a proof of concept for Gradio.", article="<p style='text-align: center'><a href='https://gameologist.com/portfolio' target='_blank'>see more of my things here</a></p>", examples=['abys.jpg', 'download (3).jpg'], enable_queue=True)

iface.launch()