File size: 4,675 Bytes
5a39fd2 be4ae40 5a39fd2 be4ae40 5a39fd2 be4ae40 5a39fd2 be4ae40 f7b54b4 be4ae40 5a39fd2 |
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 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
import gradio as gr
from huggingface_hub import from_pretrained_fastai
from fastai.vision.all import *
repo_id = "Tinsae/EthioFoodtest3"
learn = from_pretrained_fastai(repo_id)
labels = learn.dls.vocab
EXAMPLES_PATH = Path('./examples')
title = "Ethiopian Foods "
description = """
The bot was trained to answer questions based on Rick and Morty dialogues. Ask Rick anything!
"""
article = "Check out [the original Rick and Morty Bot](https://huggingface.co/spaces/kingabzpro/Rick_and_Morty_Bot) that this demo is based off of."
examples = [f'{EXAMPLES_PATH}/{f.name}' for f in EXAMPLES_PATH.iterdir()]
labels = learn.dls.vocab
v ='''<!DOCTYPE html>
<html>
<body>
<h1>A recipe video</h1>
{0}
</body>
</html> '''
v_dic = ['''<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>''',
'''<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>''',
''' <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>''',
'''<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>''',
'''<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>''',
'''<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>''' ,
'''<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>''',
'''<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>''',
'''<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>''',
'''<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>''',
'''<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>'''
]
def predict(img):
img = PILImage.create(img)
pred, pred_w_idx, probs = learn.predict(img)
labels_probs = {labels[i]: float(probs[i]) for i, _ in enumerate(labels)}
return labels_probs, v.format(v_dic[pred_w_idx])
demo = gr.Interface(predict,
"image",
[gr.outputs.Label(num_top_classes=3), "html"],
examples= examples,
title=title,
description=description,
article=article)
demo.launch() |