{ "cells": [ { "cell_type": "code", "execution_count": 1, "id": "6169050c", "metadata": {}, "outputs": [], "source": [ "import gradio as gr\n", "from fastai.vision.all import *" ] }, { "cell_type": "code", "execution_count": 5, "id": "f9d42773", "metadata": {}, "outputs": [], "source": [ "learner = load_learner(\"./zidane_scholes_mbappe_resnet34.pkl\")\n", "labels = learner.dls.vocab" ] }, { "cell_type": "code", "execution_count": 6, "id": "1d09c8aa", "metadata": {}, "outputs": [], "source": [ "def predict(img):\n", " _, _, probs = learner.predict(img)\n", " return {labels[i]: float(probs[i]) for i in range(len(labels))}" ] }, { "cell_type": "code", "execution_count": 8, "id": "6e94819f", "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "/Users/pvasudev/.virtualenvs/fast_ai/lib/python3.9/site-packages/gradio/inputs.py:257: UserWarning: Usage of gradio.inputs is deprecated, and will not be supported in the future, please import your component from gradio.components\n", " warnings.warn(\n", "/Users/pvasudev/.virtualenvs/fast_ai/lib/python3.9/site-packages/gradio/deprecation.py:40: UserWarning: `optional` parameter is deprecated, and it has no effect\n", " warnings.warn(value)\n", "/Users/pvasudev/.virtualenvs/fast_ai/lib/python3.9/site-packages/gradio/outputs.py:197: UserWarning: Usage of gradio.outputs is deprecated, and will not be supported in the future, please import your components from gradio.components\n", " warnings.warn(\n", "/Users/pvasudev/.virtualenvs/fast_ai/lib/python3.9/site-packages/gradio/deprecation.py:40: UserWarning: The 'type' parameter has been deprecated. Use the Number component instead.\n", " warnings.warn(value)\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "Running on local URL: http://127.0.0.1:7861\n", "\n", "To create a public link, set `share=True` in `launch()`.\n" ] }, { "data": { "text/html": [ "
" ], "text/plain": [ "