{ "cells": [ { "cell_type": "code", "execution_count": null, "id": "c36629cb", "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "code", "execution_count": 4, "id": "b1b65d61", "metadata": {}, "outputs": [], "source": [ "import pathlib\n", "from fastai.vision.all import *\n", "temp = pathlib.PosixPath\n", "pathlib.PosixPath = pathlib.WindowsPath\n", "learn = load_learner('BreedModel.pkl')" ] }, { "cell_type": "code", "execution_count": 5, "id": "081c71b1", "metadata": {}, "outputs": [], "source": [ "categories = learn.dls.vocab\n", "def classify_image(img):\n", " pred,pred_idx,probs = learn.predict(img)\n", " return {categories[i]: float(probs[i]) for i in range(len(categories))}" ] }, { "cell_type": "code", "execution_count": null, "id": "41de9255", "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "C:\\Users\\57310\\AppData\\Local\\Temp/ipykernel_26988/2842739511.py:3: GradioDeprecationWarning: Usage of gradio.inputs is deprecated, and will not be supported in the future, please import your component from gradio.components\n", " gr.Interface(fn=classify_image, inputs=gr.inputs.Image(shape=(512, 512)), outputs=gr.outputs.Label(num_top_classes=3), examples=examples).launch(share=True)\n", "C:\\Users\\57310\\AppData\\Local\\Temp/ipykernel_26988/2842739511.py:3: GradioDeprecationWarning: `optional` parameter is deprecated, and it has no effect\n", " gr.Interface(fn=classify_image, inputs=gr.inputs.Image(shape=(512, 512)), outputs=gr.outputs.Label(num_top_classes=3), examples=examples).launch(share=True)\n", "C:\\Users\\57310\\AppData\\Local\\Temp/ipykernel_26988/2842739511.py:3: GradioDeprecationWarning: Usage of gradio.outputs is deprecated, and will not be supported in the future, please import your components from gradio.components\n", " gr.Interface(fn=classify_image, inputs=gr.inputs.Image(shape=(512, 512)), outputs=gr.outputs.Label(num_top_classes=3), examples=examples).launch(share=True)\n", "C:\\Users\\57310\\AppData\\Local\\Temp/ipykernel_26988/2842739511.py:3: GradioUnusedKwargWarning: You have unused kwarg parameters in Label, please remove them: {'type': 'auto'}\n", " gr.Interface(fn=classify_image, inputs=gr.inputs.Image(shape=(512, 512)), outputs=gr.outputs.Label(num_top_classes=3), examples=examples).launch(share=True)\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "Running on local URL: http://127.0.0.1:7860\n", "Running on public URL: https://0c0b6c90e0e6b4495b.gradio.live\n", "\n", "This share link expires in 72 hours. For free permanent hosting and GPU upgrades, run `gradio deploy` from Terminal to deploy to Spaces (https://huggingface.co/spaces)\n" ] }, { "data": { "text/html": [ "
" ], "text/plain": [ "