import gradio as gr from fastai.vision.all import * learn=load_learner('export.pkl') 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))} # Read the image file and encode it as base64 with open("./1001epochs.png", "rb") as f: image_data = f.read() image_base64 = base64.b64encode(image_data).decode("utf-8") allow_flagging = "never" title = f"""

Emergency Vehicle Classifier

""" description = f"""

Simply upload a photo and let our sophisticated AI system determine the specific type of emergency vehicle depicted.

Disclaimer: This web app is for demonstration purposes only and not intended for commercial use. Contact: contact@1001epochs.co.uk for full solution.

""" interpretation='default' gr.Interface(fn=predict, inputs=gr.inputs.Image(shape=(512, 512)), outputs=gr.outputs.Label(num_top_classes=3), title=title, interpretation=interpretation, description=description).launch()