socd06
restore previous commit
384db06
raw
history blame
572 Bytes
import os
from huggingface_hub import from_pretrained_fastai
import gradio as gr
from gradio.components import Image
from gradio import Label
SECRET_TOKEN = os.getenv("SECRET_TOKEN")
repo_id = "artificeresearch/spiritvision"
learner = from_pretrained_fastai(repo_id)
labels = learner.dls.vocab
def predict_fn(img):
pred, pred_idx, probs = learner.predict(img)
return {labels[i]: float(probs[i]) for i in range(len(labels))}
gr.Interface(predict_fn,
Image(shape=(512, 512)),
outputs=Label(num_top_classes=3),
).launch()