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 = "
" html += "
" html += "

List of breed dogs trained:

" html += "
    " + "".join([f"
  1. {breed}
  2. " for breed in list(dogs.keys())]) + "
" html += "
" html += "
" html += "

Author:

" html += "profile image" html += "

Eric de Lima

" html += "
" html += "
" 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)