| 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() |
|
|