{ "cells": [ { "cell_type": "code", "execution_count": 1, "id": "f7574cf0", "metadata": {}, "outputs": [], "source": [ "from fastcore.all import *" ] }, { "cell_type": "code", "execution_count": 2, "id": "70c6d38b", "metadata": {}, "outputs": [], "source": [ "from fastai.vision.all import *" ] }, { "cell_type": "code", "execution_count": 7, "id": "e6cf2649", "metadata": {}, "outputs": [], "source": [ "learn = load_learner('mode.pkl')" ] }, { "cell_type": "code", "execution_count": 8, "id": "31dd1521", "metadata": {}, "outputs": [], "source": [ "labels = learn.dls.vocab" ] }, { "cell_type": "code", "execution_count": 9, "id": "6cb8e202", "metadata": {}, "outputs": [], "source": [ "def predict(img) :\n", " pred,id,probs = learn.predict(PILImage.create(img))\n", " return {labels[i] : float(probs[i]) for i in range(len(labels)) }" ] }, { "cell_type": "code", "execution_count": 10, "id": "ad1e5548", "metadata": {}, "outputs": [], "source": [ "from gradio.components import Image , Label" ] }, { "cell_type": "code", "execution_count": 11, "id": "675ef28b", "metadata": {}, "outputs": [], "source": [ "import gradio as gr" ] }, { "cell_type": "code", "execution_count": 12, "id": "fa536164", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Running on local URL: http://127.0.0.1:7866\n", "Running on public URL: https://fc407041673570426e.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": [ "