Spaces:
Runtime error
Runtime error
exiomius
commited on
Commit
·
351ff91
1
Parent(s):
fe3c909
Added First Push
Browse files- .ipynb_checkpoints/Nova or Toast-checkpoint.ipynb +169 -0
- NovaOrToast.ipynb +250 -0
- NovaOrToast.py +59 -0
- NovaOrToastModel.pkl +3 -0
- ToastTest.jpeg +0 -0
.ipynb_checkpoints/Nova or Toast-checkpoint.ipynb
ADDED
@@ -0,0 +1,169 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"cells": [
|
3 |
+
{
|
4 |
+
"cell_type": "code",
|
5 |
+
"execution_count": 1,
|
6 |
+
"id": "435a6f23",
|
7 |
+
"metadata": {},
|
8 |
+
"outputs": [
|
9 |
+
{
|
10 |
+
"name": "stdout",
|
11 |
+
"output_type": "stream",
|
12 |
+
"text": [
|
13 |
+
"Note: you may need to restart the kernel to use updated packages.\n",
|
14 |
+
"Requirement already satisfied: fastbook in c:\\users\\adnan\\anaconda3\\lib\\site-packages (0.0.28)\n",
|
15 |
+
"Requirement already satisfied: fastai>=2.6 in c:\\users\\adnan\\anaconda3\\lib\\site-packages (from fastbook) (2.7.9)\n",
|
16 |
+
"Requirement already satisfied: requests in c:\\users\\adnan\\anaconda3\\lib\\site-packages (from fastbook) (2.27.1)\n",
|
17 |
+
"Requirement already satisfied: pandas in c:\\users\\adnan\\anaconda3\\lib\\site-packages (from fastbook) (1.4.2)\n",
|
18 |
+
"Requirement already satisfied: datasets in c:\\users\\adnan\\anaconda3\\lib\\site-packages (from fastbook) (2.4.0)\n",
|
19 |
+
"Requirement already satisfied: transformers in c:\\users\\adnan\\anaconda3\\lib\\site-packages (from fastbook) (4.21.3)\n",
|
20 |
+
"Requirement already satisfied: packaging in c:\\users\\adnan\\anaconda3\\lib\\site-packages (from fastbook) (21.3)\n",
|
21 |
+
"Requirement already satisfied: sentencepiece in c:\\users\\adnan\\anaconda3\\lib\\site-packages (from fastbook) (0.1.97)\n",
|
22 |
+
"Requirement already satisfied: graphviz in c:\\users\\adnan\\anaconda3\\lib\\site-packages (from fastbook) (0.20.1)\n",
|
23 |
+
"Requirement already satisfied: pip in c:\\users\\adnan\\anaconda3\\lib\\site-packages (from fastbook) (21.2.4)\n",
|
24 |
+
"Requirement already satisfied: torch<1.14,>=1.7 in c:\\users\\adnan\\anaconda3\\lib\\site-packages (from fastai>=2.6->fastbook) (1.12.1)\n",
|
25 |
+
"Requirement already satisfied: pillow>6.0.0 in c:\\users\\adnan\\anaconda3\\lib\\site-packages (from fastai>=2.6->fastbook) (9.0.1)\n",
|
26 |
+
"Requirement already satisfied: spacy<4 in c:\\users\\adnan\\anaconda3\\lib\\site-packages (from fastai>=2.6->fastbook) (3.4.1)\n",
|
27 |
+
"Requirement already satisfied: fastdownload<2,>=0.0.5 in c:\\users\\adnan\\anaconda3\\lib\\site-packages (from fastai>=2.6->fastbook) (0.0.7)\n",
|
28 |
+
"Requirement already satisfied: scipy in c:\\users\\adnan\\anaconda3\\lib\\site-packages (from fastai>=2.6->fastbook) (1.7.3)\n",
|
29 |
+
"Requirement already satisfied: matplotlib in c:\\users\\adnan\\anaconda3\\lib\\site-packages (from fastai>=2.6->fastbook) (3.5.1)\n",
|
30 |
+
"Requirement already satisfied: scikit-learn in c:\\users\\adnan\\anaconda3\\lib\\site-packages (from fastai>=2.6->fastbook) (1.0.2)\n",
|
31 |
+
"Requirement already satisfied: torchvision>=0.8.2 in c:\\users\\adnan\\anaconda3\\lib\\site-packages (from fastai>=2.6->fastbook) (0.13.1)\n",
|
32 |
+
"Requirement already satisfied: fastprogress>=0.2.4 in c:\\users\\adnan\\anaconda3\\lib\\site-packages (from fastai>=2.6->fastbook) (1.0.3)\n",
|
33 |
+
"Requirement already satisfied: fastcore<1.6,>=1.4.5 in c:\\users\\adnan\\anaconda3\\lib\\site-packages (from fastai>=2.6->fastbook) (1.5.26)\n",
|
34 |
+
"Requirement already satisfied: pyyaml in c:\\users\\adnan\\anaconda3\\lib\\site-packages (from fastai>=2.6->fastbook) (6.0)\n",
|
35 |
+
"Requirement already satisfied: spacy-legacy<3.1.0,>=3.0.9 in c:\\users\\adnan\\anaconda3\\lib\\site-packages (from spacy<4->fastai>=2.6->fastbook) (3.0.10)\n",
|
36 |
+
"Requirement already satisfied: pydantic!=1.8,!=1.8.1,<1.10.0,>=1.7.4 in c:\\users\\adnan\\anaconda3\\lib\\site-packages (from spacy<4->fastai>=2.6->fastbook) (1.9.2)\n",
|
37 |
+
"Requirement already satisfied: wasabi<1.1.0,>=0.9.1 in c:\\users\\adnan\\anaconda3\\lib\\site-packages (from spacy<4->fastai>=2.6->fastbook) (0.10.1)\n",
|
38 |
+
"Requirement already satisfied: catalogue<2.1.0,>=2.0.6 in c:\\users\\adnan\\anaconda3\\lib\\site-packages (from spacy<4->fastai>=2.6->fastbook) (2.0.8)\n",
|
39 |
+
"Requirement already satisfied: langcodes<4.0.0,>=3.2.0 in c:\\users\\adnan\\anaconda3\\lib\\site-packages (from spacy<4->fastai>=2.6->fastbook) (3.3.0)\n",
|
40 |
+
"Requirement already satisfied: numpy>=1.15.0 in c:\\users\\adnan\\anaconda3\\lib\\site-packages (from spacy<4->fastai>=2.6->fastbook) (1.21.5)\n",
|
41 |
+
"Requirement already satisfied: murmurhash<1.1.0,>=0.28.0 in c:\\users\\adnan\\anaconda3\\lib\\site-packages (from spacy<4->fastai>=2.6->fastbook) (1.0.8)\n",
|
42 |
+
"Requirement already satisfied: typer<0.5.0,>=0.3.0 in c:\\users\\adnan\\anaconda3\\lib\\site-packages (from spacy<4->fastai>=2.6->fastbook) (0.4.2)\n",
|
43 |
+
"Requirement already satisfied: thinc<8.2.0,>=8.1.0 in c:\\users\\adnan\\anaconda3\\lib\\site-packages (from spacy<4->fastai>=2.6->fastbook) (8.1.1)\n",
|
44 |
+
"Requirement already satisfied: preshed<3.1.0,>=3.0.2 in c:\\users\\adnan\\anaconda3\\lib\\site-packages (from spacy<4->fastai>=2.6->fastbook) (3.0.7)\n",
|
45 |
+
"Requirement already satisfied: tqdm<5.0.0,>=4.38.0 in c:\\users\\adnan\\anaconda3\\lib\\site-packages (from spacy<4->fastai>=2.6->fastbook) (4.64.0)\n",
|
46 |
+
"Requirement already satisfied: srsly<3.0.0,>=2.4.3 in c:\\users\\adnan\\anaconda3\\lib\\site-packages (from spacy<4->fastai>=2.6->fastbook) (2.4.4)\n",
|
47 |
+
"Requirement already satisfied: pathy>=0.3.5 in c:\\users\\adnan\\anaconda3\\lib\\site-packages (from spacy<4->fastai>=2.6->fastbook) (0.6.2)\n",
|
48 |
+
"Requirement already satisfied: spacy-loggers<2.0.0,>=1.0.0 in c:\\users\\adnan\\anaconda3\\lib\\site-packages (from spacy<4->fastai>=2.6->fastbook) (1.0.3)\n",
|
49 |
+
"Requirement already satisfied: jinja2 in c:\\users\\adnan\\anaconda3\\lib\\site-packages (from spacy<4->fastai>=2.6->fastbook) (2.11.3)\n",
|
50 |
+
"Requirement already satisfied: cymem<2.1.0,>=2.0.2 in c:\\users\\adnan\\anaconda3\\lib\\site-packages (from spacy<4->fastai>=2.6->fastbook) (2.0.6)\n",
|
51 |
+
"Requirement already satisfied: setuptools in c:\\users\\adnan\\anaconda3\\lib\\site-packages (from spacy<4->fastai>=2.6->fastbook) (61.2.0)\n",
|
52 |
+
"Requirement already satisfied: pyparsing!=3.0.5,>=2.0.2 in c:\\users\\adnan\\anaconda3\\lib\\site-packages (from packaging->fastbook) (3.0.4)\n",
|
53 |
+
"Requirement already satisfied: smart-open<6.0.0,>=5.2.1 in c:\\users\\adnan\\anaconda3\\lib\\site-packages (from pathy>=0.3.5->spacy<4->fastai>=2.6->fastbook) (5.2.1)\n",
|
54 |
+
"Requirement already satisfied: typing-extensions>=3.7.4.3 in c:\\users\\adnan\\anaconda3\\lib\\site-packages (from pydantic!=1.8,!=1.8.1,<1.10.0,>=1.7.4->spacy<4->fastai>=2.6->fastbook) (4.1.1)\n",
|
55 |
+
"Requirement already satisfied: certifi>=2017.4.17 in c:\\users\\adnan\\anaconda3\\lib\\site-packages (from requests->fastbook) (2022.6.15)\n",
|
56 |
+
"Requirement already satisfied: charset-normalizer~=2.0.0 in c:\\users\\adnan\\anaconda3\\lib\\site-packages (from requests->fastbook) (2.0.4)\n",
|
57 |
+
"Requirement already satisfied: idna<4,>=2.5 in c:\\users\\adnan\\anaconda3\\lib\\site-packages (from requests->fastbook) (3.3)\n",
|
58 |
+
"Requirement already satisfied: urllib3<1.27,>=1.21.1 in c:\\users\\adnan\\anaconda3\\lib\\site-packages (from requests->fastbook) (1.26.9)\n",
|
59 |
+
"Requirement already satisfied: blis<0.10.0,>=0.7.8 in c:\\users\\adnan\\anaconda3\\lib\\site-packages (from thinc<8.2.0,>=8.1.0->spacy<4->fastai>=2.6->fastbook) (0.9.1)\n",
|
60 |
+
"Requirement already satisfied: confection<1.0.0,>=0.0.1 in c:\\users\\adnan\\anaconda3\\lib\\site-packages (from thinc<8.2.0,>=8.1.0->spacy<4->fastai>=2.6->fastbook) (0.0.1)\n",
|
61 |
+
"Requirement already satisfied: colorama in c:\\users\\adnan\\anaconda3\\lib\\site-packages (from tqdm<5.0.0,>=4.38.0->spacy<4->fastai>=2.6->fastbook) (0.4.4)\n",
|
62 |
+
"Requirement already satisfied: click<9.0.0,>=7.1.1 in c:\\users\\adnan\\anaconda3\\lib\\site-packages (from typer<0.5.0,>=0.3.0->spacy<4->fastai>=2.6->fastbook) (8.0.4)\n",
|
63 |
+
"Requirement already satisfied: dill<0.3.6 in c:\\users\\adnan\\anaconda3\\lib\\site-packages (from datasets->fastbook) (0.3.5.1)\n",
|
64 |
+
"Requirement already satisfied: multiprocess in c:\\users\\adnan\\anaconda3\\lib\\site-packages (from datasets->fastbook) (0.70.13)\n",
|
65 |
+
"Requirement already satisfied: responses<0.19 in c:\\users\\adnan\\anaconda3\\lib\\site-packages (from datasets->fastbook) (0.18.0)\n",
|
66 |
+
"Requirement already satisfied: fsspec[http]>=2021.11.1 in c:\\users\\adnan\\anaconda3\\lib\\site-packages (from datasets->fastbook) (2022.2.0)\n",
|
67 |
+
"Requirement already satisfied: huggingface-hub<1.0.0,>=0.1.0 in c:\\users\\adnan\\anaconda3\\lib\\site-packages (from datasets->fastbook) (0.9.1)\n",
|
68 |
+
"Requirement already satisfied: aiohttp in c:\\users\\adnan\\anaconda3\\lib\\site-packages (from datasets->fastbook) (3.8.1)\n",
|
69 |
+
"Requirement already satisfied: pyarrow>=6.0.0 in c:\\users\\adnan\\anaconda3\\lib\\site-packages (from datasets->fastbook) (9.0.0)\n",
|
70 |
+
"Requirement already satisfied: xxhash in c:\\users\\adnan\\anaconda3\\lib\\site-packages (from datasets->fastbook) (3.0.0)\n",
|
71 |
+
"Requirement already satisfied: filelock in c:\\users\\adnan\\anaconda3\\lib\\site-packages (from huggingface-hub<1.0.0,>=0.1.0->datasets->fastbook) (3.6.0)\n",
|
72 |
+
"Requirement already satisfied: aiosignal>=1.1.2 in c:\\users\\adnan\\anaconda3\\lib\\site-packages (from aiohttp->datasets->fastbook) (1.2.0)\n",
|
73 |
+
"Requirement already satisfied: yarl<2.0,>=1.0 in c:\\users\\adnan\\anaconda3\\lib\\site-packages (from aiohttp->datasets->fastbook) (1.6.3)\n",
|
74 |
+
"Requirement already satisfied: multidict<7.0,>=4.5 in c:\\users\\adnan\\anaconda3\\lib\\site-packages (from aiohttp->datasets->fastbook) (5.1.0)\n",
|
75 |
+
"Requirement already satisfied: frozenlist>=1.1.1 in c:\\users\\adnan\\anaconda3\\lib\\site-packages (from aiohttp->datasets->fastbook) (1.2.0)\n",
|
76 |
+
"Requirement already satisfied: attrs>=17.3.0 in c:\\users\\adnan\\anaconda3\\lib\\site-packages (from aiohttp->datasets->fastbook) (21.4.0)\n",
|
77 |
+
"Requirement already satisfied: async-timeout<5.0,>=4.0.0a3 in c:\\users\\adnan\\anaconda3\\lib\\site-packages (from aiohttp->datasets->fastbook) (4.0.1)\n",
|
78 |
+
"Requirement already satisfied: MarkupSafe>=0.23 in c:\\users\\adnan\\anaconda3\\lib\\site-packages (from jinja2->spacy<4->fastai>=2.6->fastbook) (2.0.1)\n",
|
79 |
+
"Requirement already satisfied: kiwisolver>=1.0.1 in c:\\users\\adnan\\anaconda3\\lib\\site-packages (from matplotlib->fastai>=2.6->fastbook) (1.3.2)\n",
|
80 |
+
"Requirement already satisfied: fonttools>=4.22.0 in c:\\users\\adnan\\anaconda3\\lib\\site-packages (from matplotlib->fastai>=2.6->fastbook) (4.25.0)\n",
|
81 |
+
"Requirement already satisfied: cycler>=0.10 in c:\\users\\adnan\\anaconda3\\lib\\site-packages (from matplotlib->fastai>=2.6->fastbook) (0.11.0)\n",
|
82 |
+
"Requirement already satisfied: python-dateutil>=2.7 in c:\\users\\adnan\\anaconda3\\lib\\site-packages (from matplotlib->fastai>=2.6->fastbook) (2.8.2)\n",
|
83 |
+
"Requirement already satisfied: six>=1.5 in c:\\users\\adnan\\anaconda3\\lib\\site-packages (from python-dateutil>=2.7->matplotlib->fastai>=2.6->fastbook) (1.16.0)\n",
|
84 |
+
"Requirement already satisfied: pytz>=2020.1 in c:\\users\\adnan\\anaconda3\\lib\\site-packages (from pandas->fastbook) (2021.3)\n",
|
85 |
+
"Requirement already satisfied: threadpoolctl>=2.0.0 in c:\\users\\adnan\\anaconda3\\lib\\site-packages (from scikit-learn->fastai>=2.6->fastbook) (2.2.0)\n",
|
86 |
+
"Requirement already satisfied: joblib>=0.11 in c:\\users\\adnan\\anaconda3\\lib\\site-packages (from scikit-learn->fastai>=2.6->fastbook) (1.1.0)\n",
|
87 |
+
"Requirement already satisfied: tokenizers!=0.11.3,<0.13,>=0.11.1 in c:\\users\\adnan\\anaconda3\\lib\\site-packages (from transformers->fastbook) (0.12.1)\n",
|
88 |
+
"Requirement already satisfied: regex!=2019.12.17 in c:\\users\\adnan\\anaconda3\\lib\\site-packages (from transformers->fastbook) (2022.3.15)\n",
|
89 |
+
"Note: you may need to restart the kernel to use updated packages.\n"
|
90 |
+
]
|
91 |
+
},
|
92 |
+
{
|
93 |
+
"name": "stdout",
|
94 |
+
"output_type": "stream",
|
95 |
+
"text": [
|
96 |
+
"Note: you may need to restart the kernel to use updated packages.\n"
|
97 |
+
]
|
98 |
+
}
|
99 |
+
],
|
100 |
+
"source": [
|
101 |
+
"%pip install -q gradio\n",
|
102 |
+
"%pip install fastbook\n",
|
103 |
+
"%pip install -Uqq fastai"
|
104 |
+
]
|
105 |
+
},
|
106 |
+
{
|
107 |
+
"cell_type": "code",
|
108 |
+
"execution_count": 2,
|
109 |
+
"id": "a89a7628",
|
110 |
+
"metadata": {},
|
111 |
+
"outputs": [],
|
112 |
+
"source": [
|
113 |
+
"import fastbook\n",
|
114 |
+
"fastbook.setup_book()\n",
|
115 |
+
"from fastbook import *\n",
|
116 |
+
"from fastai.vision.widgets import *\n",
|
117 |
+
"from fastai.vision.all import *\n",
|
118 |
+
"import gradio as gr"
|
119 |
+
]
|
120 |
+
},
|
121 |
+
{
|
122 |
+
"cell_type": "code",
|
123 |
+
"execution_count": null,
|
124 |
+
"id": "9c270e70",
|
125 |
+
"metadata": {},
|
126 |
+
"outputs": [],
|
127 |
+
"source": [
|
128 |
+
"!pip uninstall Pillow\n",
|
129 |
+
"!pip install Pillow"
|
130 |
+
]
|
131 |
+
},
|
132 |
+
{
|
133 |
+
"cell_type": "code",
|
134 |
+
"execution_count": null,
|
135 |
+
"id": "d1d0d596",
|
136 |
+
"metadata": {},
|
137 |
+
"outputs": [],
|
138 |
+
"source": [
|
139 |
+
"import numpy as np \n",
|
140 |
+
"import pandas as pd \n",
|
141 |
+
"\n",
|
142 |
+
"learn_inf = load_learner('NovaOrToastModel.pkl')\n",
|
143 |
+
"learn_inf.dls.vocab # Reminds us of the categories\n",
|
144 |
+
"categories = learn_inf.dls.vocab"
|
145 |
+
]
|
146 |
+
}
|
147 |
+
],
|
148 |
+
"metadata": {
|
149 |
+
"kernelspec": {
|
150 |
+
"display_name": "Python 3 (ipykernel)",
|
151 |
+
"language": "python",
|
152 |
+
"name": "python3"
|
153 |
+
},
|
154 |
+
"language_info": {
|
155 |
+
"codemirror_mode": {
|
156 |
+
"name": "ipython",
|
157 |
+
"version": 3
|
158 |
+
},
|
159 |
+
"file_extension": ".py",
|
160 |
+
"mimetype": "text/x-python",
|
161 |
+
"name": "python",
|
162 |
+
"nbconvert_exporter": "python",
|
163 |
+
"pygments_lexer": "ipython3",
|
164 |
+
"version": "3.9.12"
|
165 |
+
}
|
166 |
+
},
|
167 |
+
"nbformat": 4,
|
168 |
+
"nbformat_minor": 5
|
169 |
+
}
|
NovaOrToast.ipynb
ADDED
@@ -0,0 +1,250 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"cells": [
|
3 |
+
{
|
4 |
+
"cell_type": "code",
|
5 |
+
"execution_count": 1,
|
6 |
+
"id": "435a6f23",
|
7 |
+
"metadata": {},
|
8 |
+
"outputs": [
|
9 |
+
{
|
10 |
+
"name": "stdout",
|
11 |
+
"output_type": "stream",
|
12 |
+
"text": [
|
13 |
+
"Note: you may need to restart the kernel to use updated packages.\n",
|
14 |
+
"Requirement already satisfied: fastbook in c:\\users\\adnan\\anaconda3\\lib\\site-packages (0.0.28)\n",
|
15 |
+
"Requirement already satisfied: requests in c:\\users\\adnan\\anaconda3\\lib\\site-packages (from fastbook) (2.28.1)\n",
|
16 |
+
"Requirement already satisfied: fastai>=2.6 in c:\\users\\adnan\\anaconda3\\lib\\site-packages (from fastbook) (2.7.9)\n",
|
17 |
+
"Requirement already satisfied: pip in c:\\users\\adnan\\anaconda3\\lib\\site-packages (from fastbook) (22.1.2)\n",
|
18 |
+
"Requirement already satisfied: sentencepiece in c:\\users\\adnan\\anaconda3\\lib\\site-packages (from fastbook) (0.1.97)\n",
|
19 |
+
"Requirement already satisfied: graphviz in c:\\users\\adnan\\anaconda3\\lib\\site-packages (from fastbook) (0.20.1)\n",
|
20 |
+
"Requirement already satisfied: datasets in c:\\users\\adnan\\anaconda3\\lib\\site-packages (from fastbook) (2.4.0)\n",
|
21 |
+
"Requirement already satisfied: packaging in c:\\users\\adnan\\anaconda3\\lib\\site-packages (from fastbook) (21.3)\n",
|
22 |
+
"Requirement already satisfied: pandas in c:\\users\\adnan\\anaconda3\\lib\\site-packages (from fastbook) (1.4.3)\n",
|
23 |
+
"Requirement already satisfied: transformers in c:\\users\\adnan\\anaconda3\\lib\\site-packages (from fastbook) (4.21.3)\n",
|
24 |
+
"Requirement already satisfied: fastdownload<2,>=0.0.5 in c:\\users\\adnan\\anaconda3\\lib\\site-packages (from fastai>=2.6->fastbook) (0.0.7)\n",
|
25 |
+
"Requirement already satisfied: matplotlib in c:\\users\\adnan\\anaconda3\\lib\\site-packages (from fastai>=2.6->fastbook) (3.5.2)\n",
|
26 |
+
"Requirement already satisfied: scikit-learn in c:\\users\\adnan\\anaconda3\\lib\\site-packages (from fastai>=2.6->fastbook) (1.1.1)\n",
|
27 |
+
"Requirement already satisfied: spacy<4 in c:\\users\\adnan\\anaconda3\\lib\\site-packages (from fastai>=2.6->fastbook) (3.4.1)\n",
|
28 |
+
"Requirement already satisfied: fastprogress>=0.2.4 in c:\\users\\adnan\\anaconda3\\lib\\site-packages (from fastai>=2.6->fastbook) (1.0.3)\n",
|
29 |
+
"Requirement already satisfied: scipy in c:\\users\\adnan\\anaconda3\\lib\\site-packages (from fastai>=2.6->fastbook) (1.7.3)\n",
|
30 |
+
"Requirement already satisfied: pillow>6.0.0 in c:\\users\\adnan\\anaconda3\\lib\\site-packages (from fastai>=2.6->fastbook) (9.2.0)\n",
|
31 |
+
"Requirement already satisfied: torch<1.14,>=1.7 in c:\\users\\adnan\\anaconda3\\lib\\site-packages (from fastai>=2.6->fastbook) (1.12.1)\n",
|
32 |
+
"Requirement already satisfied: torchvision>=0.8.2 in c:\\users\\adnan\\anaconda3\\lib\\site-packages (from fastai>=2.6->fastbook) (0.13.1)\n",
|
33 |
+
"Requirement already satisfied: fastcore<1.6,>=1.4.5 in c:\\users\\adnan\\anaconda3\\lib\\site-packages (from fastai>=2.6->fastbook) (1.5.26)\n",
|
34 |
+
"Requirement already satisfied: pyyaml in c:\\users\\adnan\\anaconda3\\lib\\site-packages (from fastai>=2.6->fastbook) (6.0)\n",
|
35 |
+
"Requirement already satisfied: dill<0.3.6 in c:\\users\\adnan\\anaconda3\\lib\\site-packages (from datasets->fastbook) (0.3.5.1)\n",
|
36 |
+
"Requirement already satisfied: pyarrow>=6.0.0 in c:\\users\\adnan\\anaconda3\\lib\\site-packages (from datasets->fastbook) (9.0.0)\n",
|
37 |
+
"Requirement already satisfied: huggingface-hub<1.0.0,>=0.1.0 in c:\\users\\adnan\\anaconda3\\lib\\site-packages (from datasets->fastbook) (0.9.1)\n",
|
38 |
+
"Requirement already satisfied: aiohttp in c:\\users\\adnan\\anaconda3\\lib\\site-packages (from datasets->fastbook) (3.8.1)\n",
|
39 |
+
"Requirement already satisfied: fsspec[http]>=2021.11.1 in c:\\users\\adnan\\anaconda3\\lib\\site-packages (from datasets->fastbook) (2022.7.1)\n",
|
40 |
+
"Requirement already satisfied: xxhash in c:\\users\\adnan\\anaconda3\\lib\\site-packages (from datasets->fastbook) (3.0.0)\n",
|
41 |
+
"Requirement already satisfied: responses<0.19 in c:\\users\\adnan\\anaconda3\\lib\\site-packages (from datasets->fastbook) (0.18.0)\n",
|
42 |
+
"Requirement already satisfied: numpy>=1.17 in c:\\users\\adnan\\anaconda3\\lib\\site-packages (from datasets->fastbook) (1.21.5)\n",
|
43 |
+
"Requirement already satisfied: multiprocess in c:\\users\\adnan\\anaconda3\\lib\\site-packages (from datasets->fastbook) (0.70.13)\n",
|
44 |
+
"Requirement already satisfied: tqdm>=4.62.1 in c:\\users\\adnan\\anaconda3\\lib\\site-packages (from datasets->fastbook) (4.64.0)\n",
|
45 |
+
"Requirement already satisfied: certifi>=2017.4.17 in c:\\users\\adnan\\anaconda3\\lib\\site-packages (from requests->fastbook) (2022.6.15)\n",
|
46 |
+
"Requirement already satisfied: charset-normalizer<3,>=2 in c:\\users\\adnan\\anaconda3\\lib\\site-packages (from requests->fastbook) (2.0.4)\n",
|
47 |
+
"Requirement already satisfied: idna<4,>=2.5 in c:\\users\\adnan\\anaconda3\\lib\\site-packages (from requests->fastbook) (3.3)\n",
|
48 |
+
"Requirement already satisfied: urllib3<1.27,>=1.21.1 in c:\\users\\adnan\\anaconda3\\lib\\site-packages (from requests->fastbook) (1.26.11)\n",
|
49 |
+
"Requirement already satisfied: pyparsing!=3.0.5,>=2.0.2 in c:\\users\\adnan\\anaconda3\\lib\\site-packages (from packaging->fastbook) (3.0.9)\n",
|
50 |
+
"Requirement already satisfied: python-dateutil>=2.8.1 in c:\\users\\adnan\\anaconda3\\lib\\site-packages (from pandas->fastbook) (2.8.2)\n",
|
51 |
+
"Requirement already satisfied: pytz>=2020.1 in c:\\users\\adnan\\anaconda3\\lib\\site-packages (from pandas->fastbook) (2022.1)\n",
|
52 |
+
"Requirement already satisfied: tokenizers!=0.11.3,<0.13,>=0.11.1 in c:\\users\\adnan\\anaconda3\\lib\\site-packages (from transformers->fastbook) (0.12.1)\n",
|
53 |
+
"Requirement already satisfied: filelock in c:\\users\\adnan\\anaconda3\\lib\\site-packages (from transformers->fastbook) (3.6.0)\n",
|
54 |
+
"Requirement already satisfied: regex!=2019.12.17 in c:\\users\\adnan\\anaconda3\\lib\\site-packages (from transformers->fastbook) (2022.7.9)\n",
|
55 |
+
"Requirement already satisfied: typing-extensions>=3.7.4.3 in c:\\users\\adnan\\anaconda3\\lib\\site-packages (from huggingface-hub<1.0.0,>=0.1.0->datasets->fastbook) (4.3.0)\n",
|
56 |
+
"Requirement already satisfied: six>=1.5 in c:\\users\\adnan\\anaconda3\\lib\\site-packages (from python-dateutil>=2.8.1->pandas->fastbook) (1.16.0)\n",
|
57 |
+
"Requirement already satisfied: preshed<3.1.0,>=3.0.2 in c:\\users\\adnan\\anaconda3\\lib\\site-packages (from spacy<4->fastai>=2.6->fastbook) (3.0.7)\n",
|
58 |
+
"Requirement already satisfied: langcodes<4.0.0,>=3.2.0 in c:\\users\\adnan\\anaconda3\\lib\\site-packages (from spacy<4->fastai>=2.6->fastbook) (3.3.0)\n",
|
59 |
+
"Requirement already satisfied: jinja2 in c:\\users\\adnan\\anaconda3\\lib\\site-packages (from spacy<4->fastai>=2.6->fastbook) (2.11.3)\n",
|
60 |
+
"Requirement already satisfied: spacy-legacy<3.1.0,>=3.0.9 in c:\\users\\adnan\\anaconda3\\lib\\site-packages (from spacy<4->fastai>=2.6->fastbook) (3.0.10)\n",
|
61 |
+
"Requirement already satisfied: pathy>=0.3.5 in c:\\users\\adnan\\anaconda3\\lib\\site-packages (from spacy<4->fastai>=2.6->fastbook) (0.6.2)\n",
|
62 |
+
"Requirement already satisfied: thinc<8.2.0,>=8.1.0 in c:\\users\\adnan\\anaconda3\\lib\\site-packages (from spacy<4->fastai>=2.6->fastbook) (8.1.1)\n",
|
63 |
+
"Requirement already satisfied: wasabi<1.1.0,>=0.9.1 in c:\\users\\adnan\\anaconda3\\lib\\site-packages (from spacy<4->fastai>=2.6->fastbook) (0.10.1)\n",
|
64 |
+
"Requirement already satisfied: setuptools in c:\\users\\adnan\\anaconda3\\lib\\site-packages (from spacy<4->fastai>=2.6->fastbook) (63.4.1)\n",
|
65 |
+
"Requirement already satisfied: srsly<3.0.0,>=2.4.3 in c:\\users\\adnan\\anaconda3\\lib\\site-packages (from spacy<4->fastai>=2.6->fastbook) (2.4.4)\n",
|
66 |
+
"Requirement already satisfied: typer<0.5.0,>=0.3.0 in c:\\users\\adnan\\anaconda3\\lib\\site-packages (from spacy<4->fastai>=2.6->fastbook) (0.4.2)\n",
|
67 |
+
"Requirement already satisfied: pydantic!=1.8,!=1.8.1,<1.10.0,>=1.7.4 in c:\\users\\adnan\\anaconda3\\lib\\site-packages (from spacy<4->fastai>=2.6->fastbook) (1.9.2)\n",
|
68 |
+
"Requirement already satisfied: spacy-loggers<2.0.0,>=1.0.0 in c:\\users\\adnan\\anaconda3\\lib\\site-packages (from spacy<4->fastai>=2.6->fastbook) (1.0.3)\n",
|
69 |
+
"Requirement already satisfied: cymem<2.1.0,>=2.0.2 in c:\\users\\adnan\\anaconda3\\lib\\site-packages (from spacy<4->fastai>=2.6->fastbook) (2.0.6)\n",
|
70 |
+
"Requirement already satisfied: catalogue<2.1.0,>=2.0.6 in c:\\users\\adnan\\anaconda3\\lib\\site-packages (from spacy<4->fastai>=2.6->fastbook) (2.0.8)\n",
|
71 |
+
"Requirement already satisfied: murmurhash<1.1.0,>=0.28.0 in c:\\users\\adnan\\anaconda3\\lib\\site-packages (from spacy<4->fastai>=2.6->fastbook) (1.0.8)\n",
|
72 |
+
"Requirement already satisfied: colorama in c:\\users\\adnan\\anaconda3\\lib\\site-packages (from tqdm>=4.62.1->datasets->fastbook) (0.4.5)\n",
|
73 |
+
"Requirement already satisfied: yarl<2.0,>=1.0 in c:\\users\\adnan\\anaconda3\\lib\\site-packages (from aiohttp->datasets->fastbook) (1.8.1)\n",
|
74 |
+
"Requirement already satisfied: async-timeout<5.0,>=4.0.0a3 in c:\\users\\adnan\\anaconda3\\lib\\site-packages (from aiohttp->datasets->fastbook) (4.0.1)\n",
|
75 |
+
"Requirement already satisfied: aiosignal>=1.1.2 in c:\\users\\adnan\\anaconda3\\lib\\site-packages (from aiohttp->datasets->fastbook) (1.2.0)\n",
|
76 |
+
"Requirement already satisfied: attrs>=17.3.0 in c:\\users\\adnan\\anaconda3\\lib\\site-packages (from aiohttp->datasets->fastbook) (21.4.0)\n",
|
77 |
+
"Requirement already satisfied: frozenlist>=1.1.1 in c:\\users\\adnan\\anaconda3\\lib\\site-packages (from aiohttp->datasets->fastbook) (1.2.0)\n",
|
78 |
+
"Requirement already satisfied: multidict<7.0,>=4.5 in c:\\users\\adnan\\anaconda3\\lib\\site-packages (from aiohttp->datasets->fastbook) (5.2.0)\n",
|
79 |
+
"Requirement already satisfied: cycler>=0.10 in c:\\users\\adnan\\anaconda3\\lib\\site-packages (from matplotlib->fastai>=2.6->fastbook) (0.11.0)\n",
|
80 |
+
"Requirement already satisfied: fonttools>=4.22.0 in c:\\users\\adnan\\anaconda3\\lib\\site-packages (from matplotlib->fastai>=2.6->fastbook) (4.25.0)\n",
|
81 |
+
"Requirement already satisfied: kiwisolver>=1.0.1 in c:\\users\\adnan\\anaconda3\\lib\\site-packages (from matplotlib->fastai>=2.6->fastbook) (1.4.2)\n",
|
82 |
+
"Requirement already satisfied: threadpoolctl>=2.0.0 in c:\\users\\adnan\\anaconda3\\lib\\site-packages (from scikit-learn->fastai>=2.6->fastbook) (2.2.0)\n",
|
83 |
+
"Requirement already satisfied: joblib>=1.0.0 in c:\\users\\adnan\\anaconda3\\lib\\site-packages (from scikit-learn->fastai>=2.6->fastbook) (1.1.0)\n",
|
84 |
+
"Requirement already satisfied: smart-open<6.0.0,>=5.2.1 in c:\\users\\adnan\\anaconda3\\lib\\site-packages (from pathy>=0.3.5->spacy<4->fastai>=2.6->fastbook) (5.2.1)\n",
|
85 |
+
"Requirement already satisfied: blis<0.10.0,>=0.7.8 in c:\\users\\adnan\\anaconda3\\lib\\site-packages (from thinc<8.2.0,>=8.1.0->spacy<4->fastai>=2.6->fastbook) (0.9.1)\n",
|
86 |
+
"Requirement already satisfied: confection<1.0.0,>=0.0.1 in c:\\users\\adnan\\anaconda3\\lib\\site-packages (from thinc<8.2.0,>=8.1.0->spacy<4->fastai>=2.6->fastbook) (0.0.1)\n",
|
87 |
+
"Requirement already satisfied: click<9.0.0,>=7.1.1 in c:\\users\\adnan\\anaconda3\\lib\\site-packages (from typer<0.5.0,>=0.3.0->spacy<4->fastai>=2.6->fastbook) (8.0.4)\n",
|
88 |
+
"Requirement already satisfied: MarkupSafe>=0.23 in c:\\users\\adnan\\anaconda3\\lib\\site-packages (from jinja2->spacy<4->fastai>=2.6->fastbook) (2.0.1)\n",
|
89 |
+
"Note: you may need to restart the kernel to use updated packages.\n"
|
90 |
+
]
|
91 |
+
},
|
92 |
+
{
|
93 |
+
"name": "stdout",
|
94 |
+
"output_type": "stream",
|
95 |
+
"text": [
|
96 |
+
"Note: you may need to restart the kernel to use updated packages.\n"
|
97 |
+
]
|
98 |
+
}
|
99 |
+
],
|
100 |
+
"source": [
|
101 |
+
"%pip install -q gradio\n",
|
102 |
+
"%pip install fastbook\n",
|
103 |
+
"%pip install -Uqq fastai"
|
104 |
+
]
|
105 |
+
},
|
106 |
+
{
|
107 |
+
"cell_type": "code",
|
108 |
+
"execution_count": 2,
|
109 |
+
"id": "a89a7628",
|
110 |
+
"metadata": {},
|
111 |
+
"outputs": [],
|
112 |
+
"source": [
|
113 |
+
"import fastbook\n",
|
114 |
+
"fastbook.setup_book()\n",
|
115 |
+
"from fastbook import *\n",
|
116 |
+
"from fastai.vision.widgets import *\n",
|
117 |
+
"from fastai.vision.all import *\n",
|
118 |
+
"import gradio as gr"
|
119 |
+
]
|
120 |
+
},
|
121 |
+
{
|
122 |
+
"cell_type": "code",
|
123 |
+
"execution_count": 3,
|
124 |
+
"id": "8c95d6bd",
|
125 |
+
"metadata": {},
|
126 |
+
"outputs": [],
|
127 |
+
"source": [
|
128 |
+
"#!pip uninstall Pillow\n",
|
129 |
+
"#!pip install Pillow\n",
|
130 |
+
"# import PIL.Image\n",
|
131 |
+
"# if not hasattr(PIL.Image, 'Resampling'): # Pillow<9.0\n",
|
132 |
+
"# PIL.Image.Resampling = PIL.Image\n",
|
133 |
+
"# Now PIL.Image.Resampling.BICUBIC is always recognized."
|
134 |
+
]
|
135 |
+
},
|
136 |
+
{
|
137 |
+
"cell_type": "code",
|
138 |
+
"execution_count": 5,
|
139 |
+
"id": "fe4889a5",
|
140 |
+
"metadata": {},
|
141 |
+
"outputs": [],
|
142 |
+
"source": [
|
143 |
+
"import pathlib\n",
|
144 |
+
"temp = pathlib.PosixPath\n",
|
145 |
+
"pathlib.PosixPath = pathlib.WindowsPath"
|
146 |
+
]
|
147 |
+
},
|
148 |
+
{
|
149 |
+
"cell_type": "code",
|
150 |
+
"execution_count": 8,
|
151 |
+
"id": "d1d0d596",
|
152 |
+
"metadata": {},
|
153 |
+
"outputs": [
|
154 |
+
{
|
155 |
+
"name": "stdout",
|
156 |
+
"output_type": "stream",
|
157 |
+
"text": [
|
158 |
+
"Running on local URL: http://127.0.0.1:7865\n",
|
159 |
+
"\n",
|
160 |
+
"To create a public link, set `share=True` in `launch()`.\n"
|
161 |
+
]
|
162 |
+
},
|
163 |
+
{
|
164 |
+
"data": {
|
165 |
+
"text/plain": [
|
166 |
+
"(<gradio.routes.App at 0x193c6d19670>, 'http://127.0.0.1:7865/', None)"
|
167 |
+
]
|
168 |
+
},
|
169 |
+
"execution_count": 8,
|
170 |
+
"metadata": {},
|
171 |
+
"output_type": "execute_result"
|
172 |
+
},
|
173 |
+
{
|
174 |
+
"data": {
|
175 |
+
"text/html": [
|
176 |
+
"\n",
|
177 |
+
"<style>\n",
|
178 |
+
" /* Turns off some styling */\n",
|
179 |
+
" progress {\n",
|
180 |
+
" /* gets rid of default border in Firefox and Opera. */\n",
|
181 |
+
" border: none;\n",
|
182 |
+
" /* Needs to be in here for Safari polyfill so background images work as expected. */\n",
|
183 |
+
" background-size: auto;\n",
|
184 |
+
" }\n",
|
185 |
+
" progress:not([value]), progress:not([value])::-webkit-progress-bar {\n",
|
186 |
+
" background: repeating-linear-gradient(45deg, #7e7e7e, #7e7e7e 10px, #5c5c5c 10px, #5c5c5c 20px);\n",
|
187 |
+
" }\n",
|
188 |
+
" .progress-bar-interrupted, .progress-bar-interrupted::-webkit-progress-bar {\n",
|
189 |
+
" background: #F44336;\n",
|
190 |
+
" }\n",
|
191 |
+
"</style>\n"
|
192 |
+
],
|
193 |
+
"text/plain": [
|
194 |
+
"<IPython.core.display.HTML object>"
|
195 |
+
]
|
196 |
+
},
|
197 |
+
"metadata": {},
|
198 |
+
"output_type": "display_data"
|
199 |
+
},
|
200 |
+
{
|
201 |
+
"data": {
|
202 |
+
"text/html": [],
|
203 |
+
"text/plain": [
|
204 |
+
"<IPython.core.display.HTML object>"
|
205 |
+
]
|
206 |
+
},
|
207 |
+
"metadata": {},
|
208 |
+
"output_type": "display_data"
|
209 |
+
}
|
210 |
+
],
|
211 |
+
"source": [
|
212 |
+
"learn_inf = load_learner('NovaOrToastModel.pkl')\n",
|
213 |
+
"learn_inf.dls.vocab # Reminds us of the categories\n",
|
214 |
+
"categories = learn_inf.dls.vocab\n",
|
215 |
+
"\n",
|
216 |
+
"def classify_image(img):\n",
|
217 |
+
" pred, idx, probs = learn_inf.predict(img)\n",
|
218 |
+
" return dict(zip(categories, map(float,probs)))\n",
|
219 |
+
"\n",
|
220 |
+
"image = gr.inputs.Image(shape=(192,192)) \n",
|
221 |
+
"label = gr.outputs.Label()\n",
|
222 |
+
"examples = [\"ToastTest.jpeg\"]\n",
|
223 |
+
"\n",
|
224 |
+
"intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples)\n",
|
225 |
+
"intf.launch(inline=False)"
|
226 |
+
]
|
227 |
+
}
|
228 |
+
],
|
229 |
+
"metadata": {
|
230 |
+
"kernelspec": {
|
231 |
+
"display_name": "Python 3 (ipykernel)",
|
232 |
+
"language": "python",
|
233 |
+
"name": "python3"
|
234 |
+
},
|
235 |
+
"language_info": {
|
236 |
+
"codemirror_mode": {
|
237 |
+
"name": "ipython",
|
238 |
+
"version": 3
|
239 |
+
},
|
240 |
+
"file_extension": ".py",
|
241 |
+
"mimetype": "text/x-python",
|
242 |
+
"name": "python",
|
243 |
+
"nbconvert_exporter": "python",
|
244 |
+
"pygments_lexer": "ipython3",
|
245 |
+
"version": "3.9.12"
|
246 |
+
}
|
247 |
+
},
|
248 |
+
"nbformat": 4,
|
249 |
+
"nbformat_minor": 5
|
250 |
+
}
|
NovaOrToast.py
ADDED
@@ -0,0 +1,59 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#!/usr/bin/env python
|
2 |
+
# coding: utf-8
|
3 |
+
|
4 |
+
# In[1]:
|
5 |
+
|
6 |
+
|
7 |
+
get_ipython().run_line_magic('pip', 'install -q gradio')
|
8 |
+
get_ipython().run_line_magic('pip', 'install fastbook')
|
9 |
+
get_ipython().run_line_magic('pip', 'install -Uqq fastai')
|
10 |
+
|
11 |
+
|
12 |
+
# In[2]:
|
13 |
+
|
14 |
+
|
15 |
+
import fastbook
|
16 |
+
fastbook.setup_book()
|
17 |
+
from fastbook import *
|
18 |
+
from fastai.vision.widgets import *
|
19 |
+
from fastai.vision.all import *
|
20 |
+
import gradio as gr
|
21 |
+
|
22 |
+
|
23 |
+
# In[3]:
|
24 |
+
|
25 |
+
|
26 |
+
#!pip uninstall Pillow
|
27 |
+
#!pip install Pillow
|
28 |
+
# import PIL.Image
|
29 |
+
# if not hasattr(PIL.Image, 'Resampling'): # Pillow<9.0
|
30 |
+
# PIL.Image.Resampling = PIL.Image
|
31 |
+
# Now PIL.Image.Resampling.BICUBIC is always recognized.
|
32 |
+
|
33 |
+
|
34 |
+
# In[5]:
|
35 |
+
|
36 |
+
|
37 |
+
import pathlib
|
38 |
+
temp = pathlib.PosixPath
|
39 |
+
pathlib.PosixPath = pathlib.WindowsPath
|
40 |
+
|
41 |
+
|
42 |
+
# In[8]:
|
43 |
+
|
44 |
+
|
45 |
+
learn_inf = load_learner('NovaOrToastModel.pkl')
|
46 |
+
learn_inf.dls.vocab # Reminds us of the categories
|
47 |
+
categories = learn_inf.dls.vocab
|
48 |
+
|
49 |
+
def classify_image(img):
|
50 |
+
pred, idx, probs = learn_inf.predict(img)
|
51 |
+
return dict(zip(categories, map(float,probs)))
|
52 |
+
|
53 |
+
image = gr.inputs.Image(shape=(192,192))
|
54 |
+
label = gr.outputs.Label()
|
55 |
+
examples = ["ToastTest.jpeg"]
|
56 |
+
|
57 |
+
intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples)
|
58 |
+
intf.launch(inline=False)
|
59 |
+
|
NovaOrToastModel.pkl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:b641ba347028bfccca155933fdd6edf4268a76f358c6f5f77f2e3f4f4d5e67b5
|
3 |
+
size 46956079
|
ToastTest.jpeg
ADDED
![]() |