Spaces:
Sleeping
Sleeping
Download app.py from gagandskk/imageclassification: direct link, hf CLI and curl.
- Browser
- Download file 677 Bytes
-
https://huggingface.co/spaces/gagandskk/imageclassification/resolve/main/app.py
- Command line
-
hf download hf://spaces/gagandskk/imageclassification/app.py
-
curl -L -o app.py https://huggingface.co/spaces/gagandskk/imageclassification/resolve/main/app.py
677 Bytes
| import gradio as gr | |
| from transformers import pipeline | |
| titulo = "Mi primer demo con Hugging Face" | |
| descripcion = "Esta es mi primera demo con Hugging Face" | |
| image_classifier = pipeline("image-classification", model="microsoft/swin-tiny-patch4-window7-224") | |
| def classify_image(image): | |
| results = image_classifier(image) | |
| formatted_results = {result['label']: result['score'] for result in results} | |
| return formatted_results | |
| interface = gr.Interface( | |
| fn=classify_image, | |
| inputs=gr.Image(type="pil", label="Carga una imagen"), | |
| outputs=gr.Label(num_top_classes=5), | |
| title=titulo, | |
| description=descripcion, | |
| allow_flagging="never" | |
| ) | |
| interface.launch() |