import gradio as gr from huggingface_hub import hf_hub_download import subprocess # Needed helper function for pickling def label_func(o): return o[0].isupper() # Download model requirements requirements_hash = hf_hub_download(repo_id="muellerzr/fastai-pets-resnet-34", filename="requirements.txt") subprocess.call(['pip', 'install', '-r', requirements_hash ]) # After installing, import Learner from fastai.learner import load_learner # Download and load model learner_hash = hf_hub_download(repo_id="muellerzr/fastai-pets-resnet-34", filename="model.pkl") learn = load_learner(learner_hash) # Predict def predict(img): clas, idx, probs = learn.predict(img) return "Dog" if clas == "False" else "Cat" iface = gr.Interface(fn=predict, inputs="image", outputs="label") iface.launch()