File size: 933 Bytes
16c7630
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
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()