# AUTOGENERATED! DO NOT EDIT! File to edit: chess-deployment.ipynb. # %% auto 0 __all__ = ['learn', 'categories', 'image', 'label', 'examples', 'intf', 'classify_image'] # %% chess-deployment.ipynb 1 from fastai.vision.all import * import gradio as gr # %% chess-deployment.ipynb 3 learn = load_learner("chess-model.pkl") # %% chess-deployment.ipynb 5 categories = ("Bishop", "King", "Knight", "Pawn", "Queen", "Rook") def classify_image(img): pred,pred_idx,probs = learn.predict(img) return dict(zip(categories, map(float, probs))) # %% chess-deployment.ipynb 7 image = gr.inputs.Image(shape=(192,192)) label = gr.outputs.Label() examples = ["bishop.png", "king.jpg", "knight.png", "rook.jpg", "pawn.jpg"] intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples, title="Chess Piece Classifier", description="Classify chess pieces into King, Queen, Bishop, Knight, Rook, or Pawn") intf.launch(inline=False)