gradio app
Browse files
app.py
CHANGED
|
@@ -1,7 +1,26 @@
|
|
| 1 |
import gradio as gr
|
|
|
|
|
|
|
|
|
|
| 2 |
|
| 3 |
def greet(name):
|
| 4 |
return "Hello " + name + "!!"
|
| 5 |
|
| 6 |
iface = gr.Interface(fn=greet, inputs="text", outputs="text")
|
| 7 |
-
iface.launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
from fastai.vision.all import *
|
| 3 |
+
"""
|
| 4 |
+
Hello world gradio
|
| 5 |
|
| 6 |
def greet(name):
|
| 7 |
return "Hello " + name + "!!"
|
| 8 |
|
| 9 |
iface = gr.Interface(fn=greet, inputs="text", outputs="text")
|
| 10 |
+
iface.launch()
|
| 11 |
+
"""
|
| 12 |
+
|
| 13 |
+
learn = load_learner('pet_model.pkl')
|
| 14 |
+
|
| 15 |
+
categories = ('Abyssinian', 'Bengal', 'Birman', 'Bombay', 'British_Shorthair', 'Egyptian_Mau', 'Maine_Coon', 'Persian', 'Ragdoll', 'Russian_Blue', 'Siamese', 'Sphynx', 'american_bulldog', 'american_pit_bull_terrier', 'basset_hound', 'beagle', 'boxer', 'chihuahua', 'english_cocker_spaniel', 'english_setter', 'german_shorthaired', 'great_pyrenees', 'havanese', 'japanese_chin', 'keeshond', 'leonberger', 'miniature_pinscher', 'newfoundland', 'pomeranian', 'pug', 'saint_bernard', 'samoyed', 'scottish_terrier', 'shiba_inu', 'staffordshire_bull_terrier', 'wheaten_terrier', 'yorkshire_terrier')
|
| 16 |
+
|
| 17 |
+
def classify_image(img):
|
| 18 |
+
_ ,_ ,probs = learn.predict(img)
|
| 19 |
+
return dict(zip(categories, map(float, probs)))
|
| 20 |
+
|
| 21 |
+
image = gr.inputs.Image(shape=(192,192))
|
| 22 |
+
label = gr.outputs.Label()
|
| 23 |
+
examples = ['bengal.jpg', 'pug.jpg']
|
| 24 |
+
|
| 25 |
+
intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples)
|
| 26 |
+
intf.launch(inline=False)
|