Spaces:
Sleeping
Sleeping
Upload 3 files
Browse filesuploads gradio app
- .gitattributes +1 -0
- example_input.png +3 -0
- gradio_app.py +30 -0
- requirements.txt +3 -0
.gitattributes
CHANGED
|
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
| 36 |
+
example_input.png filter=lfs diff=lfs merge=lfs -text
|
example_input.png
ADDED
|
Git LFS Details
|
gradio_app.py
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from transformers import pipeline
|
| 3 |
+
|
| 4 |
+
# Lade DEIN Modell
|
| 5 |
+
vit_classifier = pipeline("image-classification", model="LindiSimon/vit-beans-model")
|
| 6 |
+
clip_detector = pipeline(model="openai/clip-vit-large-patch14", task="zero-shot-image-classification")
|
| 7 |
+
|
| 8 |
+
labels_beans = ["angular_leaf_spot", "bean_rust", "healthy"]
|
| 9 |
+
|
| 10 |
+
def classify_bean(image):
|
| 11 |
+
vit_results = vit_classifier(image)
|
| 12 |
+
vit_output = {result['label']: result['score'] for result in vit_results}
|
| 13 |
+
|
| 14 |
+
clip_results = clip_detector(image, candidate_labels=labels_beans)
|
| 15 |
+
clip_output = {result['label']: result['score'] for result in clip_results}
|
| 16 |
+
|
| 17 |
+
return {"ViT Classification": vit_output, "CLIP Zero-Shot Classification": clip_output}
|
| 18 |
+
|
| 19 |
+
examples = [["example_input.png"]]
|
| 20 |
+
|
| 21 |
+
iface = gr.Interface(
|
| 22 |
+
fn=classify_bean,
|
| 23 |
+
inputs=gr.Image(type="filepath"),
|
| 24 |
+
outputs=gr.JSON(),
|
| 25 |
+
title="Bean Disease Classification",
|
| 26 |
+
description="Vergleich eines trainierten ViT-Modells mit CLIP für Bean-Disease-Klassifikation.",
|
| 27 |
+
examples=examples
|
| 28 |
+
)
|
| 29 |
+
|
| 30 |
+
iface.launch()
|
requirements.txt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
gradio
|
| 2 |
+
transformers
|
| 3 |
+
torch
|