Spaces:
Runtime error
Runtime error
from fastai.vision.all import * | |
learn = load_learner('image_has_text.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))} | |
import gradio as gr | |
# add a title and description | |
title = "Does your image contain text?" | |
desc = "It's useful to know if your AI art generator went nuts and output some crazy text on your image, or simply to know if your image contains text. This classifier will let you know if your image has text or is a plain photo or illustration without text." | |
iface = gr.Interface(fn=predict, inputs=gr.inputs.Image(shape=(512, 512)), outputs=gr.outputs.Label(num_top_classes=3), title=title, description=desc) | |
iface.launch() | |