{ "cells": [ { "cell_type": "code", "execution_count": 1, "id": "db4fccaf", "metadata": {}, "outputs": [], "source": [ "#|default_exp test\n", "\n", "!pip install -Uqq fastai\n", "!pip install -Uqq gradio" ] }, { "cell_type": "code", "execution_count": 2, "id": "7f067622", "metadata": {}, "outputs": [], "source": [ "from fastai.vision.all import *\n", "\n", "def is_cat(x): return x[0].isupper() " ] }, { "cell_type": "code", "execution_count": 3, "id": "2a2f5376", "metadata": {}, "outputs": [], "source": [ "learn = load_learner('model.pkl')" ] }, { "cell_type": "code", "execution_count": 4, "id": "2ee57395", "metadata": {}, "outputs": [], "source": [ "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": "7e0abb03", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Running on local URL: http://127.0.0.1:7860\n", "\n", "To create a public link, set `share=True` in `launch()`.\n" ] }, { "data": { "text/html": [ "
" ], "text/plain": [ "