{ "cells": [ { "cell_type": "code", "execution_count": 1, "id": "7e08d187", "metadata": {}, "outputs": [], "source": [ "#|default_exp app" ] }, { "cell_type": "code", "execution_count": 2, "id": "e449d107", "metadata": {}, "outputs": [], "source": [ "#|export\n", "# write this at the top of each cell which has to be exported to final script" ] }, { "cell_type": "code", "execution_count": 3, "id": "7fa3f38f", "metadata": {}, "outputs": [], "source": [ "#|export\n", "from fastai.vision.all import *" ] }, { "cell_type": "code", "execution_count": 6, "id": "ba04f1d8", "metadata": {}, "outputs": [], "source": [ "#|export\n", "# this identifies the type of classifier\n", "learn = load_learner('export.pkl')\n", "labels = learn.dls.vocab\n", "def predict(img):\n", " img = PILImage.create(img)\n", " pred,pred_idx,probs = learn.predict(img)\n", " return {labels[i]: float(probs[i]) for i in range(len(labels))}" ] }, { "cell_type": "code", "execution_count": 5, "id": "5c77d812", "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "/home/gilopez/mambaforge/envs/fastai/lib/python3.9/site-packages/gradio/inputs.py:256: 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", "/home/gilopez/mambaforge/envs/fastai/lib/python3.9/site-packages/gradio/deprecation.py:40: UserWarning: `optional` parameter is deprecated, and it has no effect\n", " warnings.warn(value)\n", "/home/gilopez/mambaforge/envs/fastai/lib/python3.9/site-packages/gradio/outputs.py:196: 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", "/home/gilopez/mambaforge/envs/fastai/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:7860\n", "Running on public URL: https://28738.gradio.app\n", "\n", "This share link expires in 72 hours. For free permanent hosting, check out Spaces: https://huggingface.co./spaces\n" ] }, { "data": { "text/html": [ "
" ], "text/plain": [ "