Spaces:
Runtime error
Runtime error
File size: 1,780 Bytes
ccb94c4 bf14324 15e52ec bf14324 15e52ec 7194e46 277a022 970d818 ccb94c4 9665866 ce7b541 ccb94c4 970d818 ccb94c4 970d818 ccb94c4 970d818 ccb94c4 970d818 ccb94c4 970d818 ccb94c4 fcbe51d ccb94c4 | 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 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 | import gradio as gr
from transformers import pipeline, AutoModel
model = AutoModel.from_pretrained("ericxlima/DogsClassifierModel")
dogs = {
'Zwergspitz Dog': [],
'Bouledogue Français Dog': [],
'Shih Tzu Dog': [],
'Rottweiler Dog': [],
'Pug Dog': [],
'Golden Retriever Dog': [],
'Deutscher Schäferhund Dog': [],
'Yorkshire Terrier Dog': [],
'Border Collie Dog': [],
'Dachshund Dog': [],
'Poodle Dog': [],
'Labrador Retriever Dog': [],
'Pinscher Dog': [],
'Golden Retriever': [],
}
pipeline = pipeline(model=model)
def predict(image):
predictions = pipeline(image)
return {p["label"]: p["score"] for p in predictions}
def list_breeds():
global dogs
html = "<div class='row'>"
html += "<div class='column'>"
html += "<h2>List of breed dogs trained:</h2>"
html += "<ol>" + "".join([f"<li>{breed}</li>" for breed in list(dogs.keys())]) + "</ol>"
html += "</div>"
html += "<div class='column'>"
html += "<h2>Author:</h2>"
html += "<a href='https://github.com/ericxlima'><img src='https://avatars.githubusercontent.com/u/58092119?v=4' alt='profile image' style='width:40%' /></a>"
html += "<h2><a href='https://github.com/ericxlima'>Eric de Lima</a></h2>"
html += "</div>"
html += "</div>"
return html
image = gr.Image(shape=(224, 224))
label = gr.Label(num_top_classes=3)
# breeds_list = list_breeds()
demo = gr.Interface(
fn=predict,
inputs=image,
outputs=label,
title="🐶 Dog Breed Classifier",
interpretation="default",
description="Upload an image of a dog and the model will predict its breed.",
# article=breeds_list,
css=".row { display: flex; } .column { flex: 50%; }",
)
demo.launch(share=True, debug=True)
|