Download app.py from nbacchi/Abgabe2: direct link, hf CLI and curl.
- Browser
- Download file 933 Bytes
-
https://huggingface.co/spaces/nbacchi/Abgabe2/resolve/main/app.py
- Command line
-
hf download hf://spaces/nbacchi/Abgabe2/app.py
-
curl -L -o app.py https://huggingface.co/spaces/nbacchi/Abgabe2/resolve/main/app.py
933 Bytes
| import gradio as gr | |
| from pathlib import Path | |
| from model_comparison import ModelComparison, discover_example_images | |
| comparison = ModelComparison() | |
| PROJECT_DIR = Path(__file__).resolve().parent | |
| example_images = discover_example_images(str(PROJECT_DIR / "example_images")) | |
| def classify_image(image_path: str): | |
| return comparison.classify_all(image_path) | |
| iface = gr.Interface( | |
| fn=classify_image, | |
| inputs=gr.Image(type="filepath", label="Upload bean leaf image"), | |
| outputs=gr.JSON(label="Model Comparison"), | |
| title="Bean Disease Classification Comparison", | |
| description=( | |
| "Compare predictions for bean leaf disease classification. " | |
| "Upload a bean leaf image to get predictions from three models: " | |
| "custom ViT (fine-tuned), CLIP (zero-shot), and OpenAI Vision (reasoning)." | |
| ), | |
| examples=example_images if example_images else None, | |
| ) | |
| if __name__ == "__main__": | |
| iface.launch() | |