Spaces:
Runtime error
Runtime error
add files
Browse files- app.py +64 -0
- examples/beyaynetu_0026.jpg +0 -0
- examples/chechebsa_0056.jpg +0 -0
- examples/doro_wat_0018.jpg +0 -0
- examples/firfir_005.jpg +0 -0
- examples/genfo_0049.jpg +0 -0
- examples/kikil_0048.jpg +0 -0
- examples/kitfo_0060.jpg +0 -0
- examples/shekla_tibs_000.jpg +0 -0
- examples/shiro_wat_0048.jpg +0 -0
- examples/tihlo_007.jpg +0 -0
- examples/tire_siga_0034.jpg +0 -0
- requirements.txt +5 -0
app.py
ADDED
@@ -0,0 +1,64 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from huggingface_hub import from_pretrained_fastai
|
3 |
+
from fastai.vision.all import *
|
4 |
+
|
5 |
+
repo_id = "Tinsae/EthioFoodtest3"
|
6 |
+
|
7 |
+
learn = from_pretrained_fastai(repo_id)
|
8 |
+
labels = learn.dls.vocab
|
9 |
+
EXAMPLES_PATH = Path('./examples')
|
10 |
+
|
11 |
+
title = "Ethiopian Food classifier "
|
12 |
+
description = """
|
13 |
+
This app is a demo of a model trained to classify images of the following Ethiopian food categories
|
14 |
+
- Beyaynetu - Chechebsa - Doro wat - Firfir
|
15 |
+
- Genfo - Kikil - Kitfo - Shekla tibs
|
16 |
+
- Shiro wat - Tihlo - Tire_siga
|
17 |
+
|
18 |
+
"""
|
19 |
+
|
20 |
+
article = "Full report on this model can be found [here](https://wandb.ai/tinsae/Ethiopian-foods/reports/Ethiopian-Foods-Classification---VmlldzoyMzExNjk1)"
|
21 |
+
examples = [f'{EXAMPLES_PATH}/{f.name}' for f in EXAMPLES_PATH.iterdir()]
|
22 |
+
|
23 |
+
labels = learn.dls.vocab
|
24 |
+
|
25 |
+
v ='''<!DOCTYPE html>
|
26 |
+
<html>
|
27 |
+
<body>
|
28 |
+
<h1>A recipe video</h1>
|
29 |
+
{0}
|
30 |
+
</body>
|
31 |
+
</html> '''
|
32 |
+
v_ls = ['''<iframe width="956" height="240" src="https://www.youtube.com/embed/53Kj_dpBYzo" title="How to Make Ethiopian Food: Yetsom Beyaynetu | α¨α
α α α«ααα± α₯α΅α«α" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>''',
|
33 |
+
'''<iframe width="956" height="240" src="https://www.youtube.com/embed/Hw9K9Q9Q_0M" title="Chechebsa (Spicy Flat Bread) | Ethiopian/Eritrean Food BY HabeshChef" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>''',
|
34 |
+
''' <iframe width="956" height="240" src="https://www.youtube.com/embed/zi4AT6uYKUs" title="How To Make Spicy Ethiopian Chicken Stew: Doro Wat" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>''',
|
35 |
+
'''<iframe width="956" height="240" src="https://www.youtube.com/embed/V2fuMDmjqbc" title="Best Ethiopian Breakfast Food: Firfir Recipe (αααα α α°α«α )" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>''',
|
36 |
+
'''<iframe width="956" height="240" src="https://www.youtube.com/embed/9iFMR3299BY" title="Genfo (Ethiopian style porridge)" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>''',
|
37 |
+
'''<iframe width="956" height="240" src="https://www.youtube.com/embed/XtS1uzHGBYQ" title="Ethiopian Food EASY KIKIL Recipe α¨α
α
α α α°α«α | Amena and Elias" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>''' ,
|
38 |
+
'''<iframe width="956" height="240" src="https://www.youtube.com/embed/-xFR_daRIyw" title="Get a Taste Of Ethiopia: Kitfo with Woinee Mariam | Food Network" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>''',
|
39 |
+
'''<iframe width="956" height="240" src="https://www.youtube.com/embed/SFEu7JcQsis" title="Letβs cook Ethiopian Shekla Tibs! π₯" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>''',
|
40 |
+
'''<iframe width="956" height="240" src="https://www.youtube.com/embed/_W_J6wNq3nI" title="LET'S MAKE SHIRO TOGETHER AT HOME Vlogmas Day 22" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>''',
|
41 |
+
'''<iframe width="956" height="240" src="https://www.youtube.com/embed/7kDe2yBgB1I" title="α£α
αα α¨ α₯αα α α°α«α | Traditional Tigrayan Tihlo Recipe | Ethiopian Food" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>''',
|
42 |
+
'''<iframe width="956" height="240" src="https://www.youtube.com/embed/Qex-uPtbUD0" title="FEEDING RAW MEAT TO GERMAN DIASPORA" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>'''
|
43 |
+
]
|
44 |
+
|
45 |
+
def predict(img):
|
46 |
+
img = PILImage.create(img)
|
47 |
+
pred, pred_w_idx, probs = learn.predict(img)
|
48 |
+
|
49 |
+
labels_probs = {labels[i]: float(probs[i]) for i, _ in enumerate(labels)}
|
50 |
+
|
51 |
+
|
52 |
+
return labels_probs, v.format(v_ls[pred_w_idx])
|
53 |
+
|
54 |
+
|
55 |
+
|
56 |
+
demo = gr.Interface(predict,
|
57 |
+
"image",
|
58 |
+
[gr.outputs.Label(num_top_classes=3), "html"],
|
59 |
+
examples= examples,
|
60 |
+
title=title,
|
61 |
+
description=description,
|
62 |
+
article=article)
|
63 |
+
|
64 |
+
demo.launch()
|
examples/beyaynetu_0026.jpg
ADDED
examples/chechebsa_0056.jpg
ADDED
examples/doro_wat_0018.jpg
ADDED
examples/firfir_005.jpg
ADDED
examples/genfo_0049.jpg
ADDED
examples/kikil_0048.jpg
ADDED
examples/kitfo_0060.jpg
ADDED
examples/shekla_tibs_000.jpg
ADDED
examples/shiro_wat_0048.jpg
ADDED
examples/tihlo_007.jpg
ADDED
examples/tire_siga_0034.jpg
ADDED
requirements.txt
ADDED
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
fastai==2.7.4
|
2 |
+
huggingface_hub[fastai]
|
3 |
+
fastcore>=1.3.27
|
4 |
+
gradio
|
5 |
+
timm
|