CoolFace
Apppublic

yangtommy6/Computer_Vision_Project

sourceHugging Faceapache-2.0updated 4y agoView on Hugging Face
1likes
app.py14 linesDownload Raw Back to root
1from fastai.vision.all import *2import gradio as gr 3 4learn = load_learner('model.pkl')5 6categories = ('A room', 'Albatross', 'Anaconda', 'Bears', 'Bison', 'Bobcat', 'Buffalo', 'Cheetah', 'Cobra', 'Crocodile', 'Crowd', 'Dingo', 'Elephant', 'Eurasian Lynx', 'Field', 'Gorilla', 'Kangaroo', 'Koala', 'Komodo Dragon', 'Leopard', 'Lion' , 'Llama', 'Manatee', 'Monkey','Moose','Natural river', 'Organgutan', 'Panda', 'Penguins', 'Platypus', 'Reindeer', 'Rhinoceros', 'Robot', 'Seals', 'Tasmanian Devil','Technology products', 'Tigar', 'Wolf', 'anime', 'automobile', 'bird', 'book', 'building', 'capybara', 'cat', 'cave', 'city', 'computer', 'deep sea creatures', 'dessert', 'dog', 'dophin', 'fish', 'flag', 'food', 'forest', 'game', 'gas station', 'hamster', 'icon', 'jaguar', 'jellyfish', 'kitchen', 'lake', 'lantern', 'man', 'mountain', 'phone', 'rabbit','sea','shark', 'sky', 'sloth', 'snow', 'turtle', 'universe', 'whale', 'women')7def classify_image(img):8  pred,idx,probs = learn.predict(img)9  return dict(zip(categories, map(float,probs)))10 11image = gr.inputs.Image(shape=(192,192))12label = gr.outputs.Label()13intf = gr.Interface(fn = classify_image, inputs = image, outputs = label)14intf.launch(inline = False)