chrisis2 commited on
Commit
a58ff0a
·
verified ·
1 Parent(s): 8bb9da5

Upload 7 files

Browse files
.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_images/burger.jpg filter=lfs diff=lfs merge=lfs -text
app.py ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #! pip install gradio
2
+ import gradio as gr
3
+ from transformers import pipeline
4
+
5
+ # Lade beide Modelle
6
+ vit_classifier = pipeline("image-classification", model="chrisis2/vit-food-classification-chrisis2") # Ersetze mit deinem Modell
7
+ clip_detector = pipeline(model="openai/clip-vit-large-patch14", task="zero-shot-image-classification")
8
+
9
+ # Verwende deine Food-Labels
10
+ food_labels = [
11
+ "Baked Potato", "Crispy Chicken", "Donut", "Fries", "Hot Dog", "Sandwich", "Taco", "Taquito",
12
+ "apple_pie", "burger", "butter_naan", "chai", "chapati", "cheesecake", "chicken_curry",
13
+ "chole_bhature", "dal_makhani", "dhokla", "fried_rice", "ice_cream", "idli", "jalebi",
14
+ "kaathi_rolls", "kadai_paneer", "kulfi", "masala_dosa", "momos", "omelette", "paani_puri",
15
+ "pakode", "pav_bhaji", "pizza", "samosa", "sushi"
16
+ ]
17
+
18
+ def classify_food(image):
19
+ # Klassifiziere mit deinem trainierten Modell
20
+ vit_results = vit_classifier(image)
21
+ vit_output = {result['label']: result['score'] for result in vit_results}
22
+
23
+ # Klassifiziere mit CLIP Zero-Shot
24
+ clip_results = clip_detector(image, candidate_labels=food_labels)
25
+ clip_output = {result['label']: result['score'] for result in clip_results}
26
+
27
+ return {"Trainiertes ViT-Modell": vit_output, "CLIP Zero-Shot": clip_output}
28
+
29
+ # Füge Beispielbilder aus deinem Dataset hinzu
30
+ example_images = [
31
+ ["gradio-food-app/example_images/burger.jpg.jpg"],
32
+ ["gradio-food-app/example_images/burger.jpg.jpg"],
33
+ ["gradio-food-app/example_images/burger.jpg.jpg"],
34
+ ["gradio-food-app/example_images/pizza.jpg.jpg"],
35
+ ["gradio-food-app/example_images/sushi.jpg.jpg"],
36
+ # Füge weitere Beispiele hinzu
37
+ ]
38
+
39
+ # Erstelle die Gradio-Oberfläche
40
+ iface = gr.Interface(
41
+ fn=classify_food,
42
+ inputs=gr.Image(type="filepath"),
43
+ outputs=gr.JSON(),
44
+ title="Food Classification Vergleich",
45
+ description="Lade ein Bild eines Lebensmittels hoch und vergleiche die Ergebnisse eines trainierten ViT-Modells mit einem Zero-Shot CLIP-Modell.",
46
+ examples=example_images
47
+ )
48
+
49
+ iface.launch()
example_images/burger.jpg ADDED

Git LFS Details

  • SHA256: d7204a2a0b8ca356c8063bb5a4336462ccf4b59b851fffeb5387b94cd3cab7fd
  • Pointer size: 131 Bytes
  • Size of remote file: 189 kB
example_images/donut.jpg ADDED
example_images/fries.jpg ADDED
example_images/pizza.jpg ADDED
example_images/sushi.jpg ADDED
requirements.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ transformers
2
+ torch