tyler cross
Added model and interface
711e417
raw
history blame
No virus
553 Bytes
import gradio as gr
from fastai.vision.all import load_learner
from PIL import Image
model = load_learner('./export.pkl')
def classify_image(img):
# Convert the image to a format the model expects
img = Image.fromarray(img.astype('uint8'), 'RGB')
# Make a prediction
pred, idx, probs = model.predict(img)
# Return the result
return {model.dls.vocab[i]: float(probs[i]) for i in range(len(model.dls.vocab))}
demo = gr.Interface(fn=classify_image, inputs="image", outputs="label")
if __name__ == "__main__":
demo.launch()