Spaces:
Runtime error
Runtime error
File size: 800 Bytes
cb89fdc c99bca1 cb89fdc c99bca1 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
from fastai.vision.all import *
import gradio as gr
learn = load_learner('nationalflagidentifier.pkl')
def predict(image):
img = PILImage.create(image)
country, idx, probs = learn.predict(img)
return f'This is the national flag of {country}------------ Probability: {probs[idx]:.4f}'
title = 'National Flag Classifier'
description = """Upload a flag photo and get to know to which country or dependency it belongs to.
267 countries or dependencies supported."""
interpretation = 'default'
infer = gr.Interface(
fn = predict,
inputs = gr.inputs.Image(shape = (256, 256)),
outputs = gr.outputs.Label(num_top_classes = len(learn.dls.vocab)),
title = title,
description = description,
interpretation = interpretation
)
infer.launch() |