acidtib's picture
Update app.py
eb71cc4 verified
raw
history blame contribute delete
810 Bytes
import gradio as gr
from transformers import pipeline
from pathlib import Path
pipeline = pipeline(task="image-classification", model="acidtib/tcg-magic-cards")
sample_img_paths = [str(p) for p in Path('./samples').glob('*.png')]
def predict(input_img):
predictions = pipeline(input_img)
return input_img, {p["label"]: p["score"] for p in predictions}
gradio_app = gr.Interface(
predict,
inputs=gr.Image(label="Select Magic Card", sources=['upload', 'webcam'], type="pil"),
outputs=[gr.Image(label="Processed Image"), gr.Label(label="Result", num_top_classes=1)],
examples=sample_img_paths,
title="TCG Magic Classifier",
description='This classifier returns the id of cards from scryfall!, try one of the samples below'
)
if __name__ == "__main__":
gradio_app.launch()