import gradio as gr from fastai.vision.all import * import skimage training_set = "mane6-8000" # this is here, because it needs to be, otherwise I have no friggin clue def get_x(r): return os.path.join(training_set, r['fname'].replace('png', 'jpg').replace('gif', 'jpg').replace('svg', 'jpg')) # the replacing part is an interim solution lol (bug on a different end) def get_y(r): return r['tag'] learn = load_learner('export.pkl') # pls rename labels = learn.dls.vocab def predict(img): img = PILImage.create(img) pred,pred_idx,probs = learn.predict(img) return {labels[i]: float(probs[i]) for i in range(len(labels))} title = "Ember" description = "" examples = ["examples/1.jpg", "examples/2.jpg", "examples/3.jpg", "examples/4.jpg"] interpretation='default' enable_queue=True gr.Interface( fn=predict, inputs=gr.inputs.Image(shape=(400, 400)), outputs=gr.outputs.Label(num_top_classes=3), title=title, description=description, examples=examples, interpretation=interpretation, enable_queue=enable_queue).launch() """ LINKS https://tmabraham.github.io/blog/gradio_hf_spaces_tutorial """