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 ='''

A recipe video

{0} ''' v_dic = ['''''', '''''', ''' ''', '''''', '''''', '''''' , '''''', '''''', '''''', '''''', '''''' ] 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()