exiomius commited on
Commit
73fc5dd
β€’
1 Parent(s): b77075d

First Attempt using NBdev notebook to file

Browse files
.ipynb_checkpoints/{NovaOrToast-checkpoint.ipynb β†’ app-checkpoint.ipynb} RENAMED
File without changes
NovaOrToast.ipynb DELETED
@@ -1,247 +0,0 @@
1
- {
2
- "cells": [
3
- {
4
- "cell_type": "markdown",
5
- "id": "738fc104",
6
- "metadata": {},
7
- "source": [
8
- "# This notebook is the .ipynb file for the model. \n",
9
- "The code has been commmented in order to explain various parts, including the unused commented out parts."
10
- ]
11
- },
12
- {
13
- "cell_type": "code",
14
- "execution_count": 1,
15
- "id": "3e06a8dc",
16
- "metadata": {},
17
- "outputs": [],
18
- "source": [
19
- "#|default_exp app"
20
- ]
21
- },
22
- {
23
- "cell_type": "code",
24
- "execution_count": 2,
25
- "id": "435a6f23",
26
- "metadata": {},
27
- "outputs": [],
28
- "source": [
29
- "# On my computer, I use Anaconda, where these packages are already installed, so there is no need to install them on the notebook\n",
30
- "# On HuggingFaceSpaces, these packages have been put into requirements.txt so that the website installs them\n",
31
- "# Therefore there is no need to install them \n",
32
- "\n",
33
- "#%pip install -q gradio\n",
34
- "#%pip install fastbook\n",
35
- "#%pip install -Uqq fastai"
36
- ]
37
- },
38
- {
39
- "cell_type": "code",
40
- "execution_count": 3,
41
- "id": "a89a7628",
42
- "metadata": {},
43
- "outputs": [],
44
- "source": [
45
- "#|export\n",
46
- "# Importing neccesary modules\n",
47
- "import fastbook\n",
48
- "fastbook.setup_book()\n",
49
- "from fastbook import *\n",
50
- "from fastai.vision.widgets import *\n",
51
- "from fastai.vision.all import *\n",
52
- "import gradio as gr"
53
- ]
54
- },
55
- {
56
- "cell_type": "code",
57
- "execution_count": 4,
58
- "id": "8c95d6bd",
59
- "metadata": {},
60
- "outputs": [],
61
- "source": [
62
- "# There was an error with the module Pillow, it was not updated and I attempted to update it within the notebook\n",
63
- "# This was not neccesary as I updated Pillow on my anaconda app and it fixed it.\n",
64
- "\n",
65
- "#!pip uninstall Pillow\n",
66
- "#!pip install Pillow"
67
- ]
68
- },
69
- {
70
- "cell_type": "code",
71
- "execution_count": 5,
72
- "id": "fe4889a5",
73
- "metadata": {},
74
- "outputs": [],
75
- "source": [
76
- "# There was an error the first time I ran this code on the notebook: \"NotImplementedError: cannot instantiate 'PosixPath' on your system\"\n",
77
- "# this code fixed it, but as it is suited for windows,\n",
78
- "# this causes an error on HuggingSpaceFaces, which likely uses linux. \n",
79
- "# Strangely, simply commenting this code out does not cause the initial error on HuggingFaceSpaces and works for it\n",
80
- "\n",
81
- "import pathlib\n",
82
- "temp = pathlib.PosixPath\n",
83
- "pathlib.PosixPath = pathlib.WindowsPath"
84
- ]
85
- },
86
- {
87
- "cell_type": "code",
88
- "execution_count": 6,
89
- "id": "d1d0d596",
90
- "metadata": {},
91
- "outputs": [
92
- {
93
- "name": "stderr",
94
- "output_type": "stream",
95
- "text": [
96
- "C:\\Users\\Adnan\\anaconda3\\lib\\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",
97
- " warnings.warn(\n",
98
- "C:\\Users\\Adnan\\anaconda3\\lib\\site-packages\\gradio\\deprecation.py:40: UserWarning: `optional` parameter is deprecated, and it has no effect\n",
99
- " warnings.warn(value)\n",
100
- "C:\\Users\\Adnan\\anaconda3\\lib\\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",
101
- " warnings.warn(\n",
102
- "C:\\Users\\Adnan\\anaconda3\\lib\\site-packages\\gradio\\deprecation.py:40: UserWarning: The 'type' parameter has been deprecated. Use the Number component instead.\n",
103
- " warnings.warn(value)\n"
104
- ]
105
- },
106
- {
107
- "name": "stdout",
108
- "output_type": "stream",
109
- "text": [
110
- "Running on local URL: http://127.0.0.1:7860\n",
111
- "\n",
112
- "To create a public link, set `share=True` in `launch()`.\n"
113
- ]
114
- },
115
- {
116
- "data": {
117
- "text/plain": [
118
- "(<gradio.routes.App at 0x1b3c1180ac0>, 'http://127.0.0.1:7860/', None)"
119
- ]
120
- },
121
- "execution_count": 6,
122
- "metadata": {},
123
- "output_type": "execute_result"
124
- }
125
- ],
126
- "source": [
127
- "#|export\n",
128
- "learn_inf = load_learner('NovaOrToastModel.pkl') # Loading the model\n",
129
- "learn_inf.dls.vocab # Returns a list of the categories\n",
130
- "categories = learn_inf.dls.vocab\n",
131
- "\n",
132
- "# Gradio code:\n",
133
- "\n",
134
- "# Function for Gradio to use to classify images\n",
135
- "def classify_image(img):\n",
136
- " pred, idx, probs = learn_inf.predict(img)\n",
137
- " return dict(zip(categories, map(float,probs)))\n",
138
- "\n",
139
- "image = gr.inputs.Image(shape=(192,192)) \n",
140
- "label = gr.outputs.Label()\n",
141
- "examples = [\"ToastTest.jpeg\"]\n",
142
- "\n",
143
- "intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples)\n",
144
- "intf.launch(inline=False)"
145
- ]
146
- },
147
- {
148
- "cell_type": "code",
149
- "execution_count": 8,
150
- "id": "87f44c7a",
151
- "metadata": {},
152
- "outputs": [],
153
- "source": [
154
- "from nbdev.export import notebook2script"
155
- ]
156
- },
157
- {
158
- "cell_type": "code",
159
- "execution_count": 15,
160
- "id": "680f2b28",
161
- "metadata": {},
162
- "outputs": [
163
- {
164
- "ename": "InterpolationMissingOptionError",
165
- "evalue": "Bad value substitution: option 'doc_host' in section 'DEFAULT' contains an interpolation key 'user' which is not a valid option name. Raw value: 'https://%(user)s.github.io'",
166
- "output_type": "error",
167
- "traceback": [
168
- "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
169
- "\u001b[1;31mInterpolationMissingOptionError\u001b[0m Traceback (most recent call last)",
170
- "Input \u001b[1;32mIn [15]\u001b[0m, in \u001b[0;36m<cell line: 3>\u001b[1;34m()\u001b[0m\n\u001b[0;32m 1\u001b[0m \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;21;01mnbdev\u001b[39;00m \u001b[38;5;28;01mimport\u001b[39;00m get_config\n\u001b[0;32m 2\u001b[0m \u001b[38;5;66;03m#get_config (cfg_name='settings.ini', path=None)\u001b[39;00m\n\u001b[1;32m----> 3\u001b[0m \u001b[43mget_config\u001b[49m\u001b[43m \u001b[49m\u001b[43m(\u001b[49m\u001b[43mcfg_name\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[38;5;124;43msettings.ini\u001b[39;49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[43m)\u001b[49m\n",
171
- "File \u001b[1;32m~\\anaconda3\\lib\\site-packages\\nbdev\\imports.py:30\u001b[0m, in \u001b[0;36mget_config\u001b[1;34m(cfg_name)\u001b[0m\n\u001b[0;32m 28\u001b[0m \u001b[38;5;28;01mwhile\u001b[39;00m cfg_path \u001b[38;5;241m!=\u001b[39m cfg_path\u001b[38;5;241m.\u001b[39mparent \u001b[38;5;129;01mand\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m (cfg_path\u001b[38;5;241m/\u001b[39mcfg_name)\u001b[38;5;241m.\u001b[39mexists(): cfg_path \u001b[38;5;241m=\u001b[39m cfg_path\u001b[38;5;241m.\u001b[39mparent\n\u001b[0;32m 29\u001b[0m config \u001b[38;5;241m=\u001b[39m Config(cfg_path, cfg_name\u001b[38;5;241m=\u001b[39mcfg_name)\n\u001b[1;32m---> 30\u001b[0m \u001b[43m_add_new_defaults\u001b[49m\u001b[43m(\u001b[49m\u001b[43mconfig\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43md\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mconfig\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mconfig_file\u001b[49m\u001b[43m,\u001b[49m\n\u001b[0;32m 31\u001b[0m \u001b[43m \u001b[49m\u001b[43mhost\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mgithub\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mdoc_host\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mhttps://\u001b[39;49m\u001b[38;5;132;43;01m%(user)s\u001b[39;49;00m\u001b[38;5;124;43m.github.io\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mdoc_baseurl\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43m/\u001b[39;49m\u001b[38;5;132;43;01m%(lib_name)s\u001b[39;49;00m\u001b[38;5;124;43m/\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m)\u001b[49m\n\u001b[0;32m 32\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m config\n",
172
- "File \u001b[1;32m~\\anaconda3\\lib\\site-packages\\nbdev\\imports.py:23\u001b[0m, in \u001b[0;36m_add_new_defaults\u001b[1;34m(cfg, file, **kwargs)\u001b[0m\n\u001b[0;32m 21\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m cfg\u001b[38;5;241m.\u001b[39mget(k, \u001b[38;5;28;01mNone\u001b[39;00m) \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m:\n\u001b[0;32m 22\u001b[0m cfg[k] \u001b[38;5;241m=\u001b[39m v\n\u001b[1;32m---> 23\u001b[0m \u001b[43msave_config_file\u001b[49m\u001b[43m(\u001b[49m\u001b[43mfile\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mcfg\u001b[49m\u001b[43m)\u001b[49m\n",
173
- "File \u001b[1;32m~\\anaconda3\\lib\\site-packages\\fastcore\\foundation.py:240\u001b[0m, in \u001b[0;36msave_config_file\u001b[1;34m(file, d, **kwargs)\u001b[0m\n\u001b[0;32m 238\u001b[0m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mWrite settings dict to a new config file, or overwrite the existing one.\u001b[39m\u001b[38;5;124m\"\u001b[39m\n\u001b[0;32m 239\u001b[0m config \u001b[38;5;241m=\u001b[39m ConfigParser(\u001b[38;5;241m*\u001b[39m\u001b[38;5;241m*\u001b[39mkwargs)\n\u001b[1;32m--> 240\u001b[0m config[\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mDEFAULT\u001b[39m\u001b[38;5;124m'\u001b[39m] \u001b[38;5;241m=\u001b[39m d\n\u001b[0;32m 241\u001b[0m config\u001b[38;5;241m.\u001b[39mwrite(\u001b[38;5;28mopen\u001b[39m(file, \u001b[38;5;124m'\u001b[39m\u001b[38;5;124mw\u001b[39m\u001b[38;5;124m'\u001b[39m))\n",
174
- "File \u001b[1;32m~\\anaconda3\\lib\\configparser.py:977\u001b[0m, in \u001b[0;36mRawConfigParser.__setitem__\u001b[1;34m(self, key, value)\u001b[0m\n\u001b[0;32m 975\u001b[0m \u001b[38;5;28;01melif\u001b[39;00m key \u001b[38;5;129;01min\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_sections:\n\u001b[0;32m 976\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_sections[key]\u001b[38;5;241m.\u001b[39mclear()\n\u001b[1;32m--> 977\u001b[0m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mread_dict\u001b[49m\u001b[43m(\u001b[49m\u001b[43m{\u001b[49m\u001b[43mkey\u001b[49m\u001b[43m:\u001b[49m\u001b[43m \u001b[49m\u001b[43mvalue\u001b[49m\u001b[43m}\u001b[49m\u001b[43m)\u001b[49m\n",
175
- "File \u001b[1;32m~\\anaconda3\\lib\\configparser.py:747\u001b[0m, in \u001b[0;36mRawConfigParser.read_dict\u001b[1;34m(self, dictionary, source)\u001b[0m\n\u001b[0;32m 745\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m\n\u001b[0;32m 746\u001b[0m elements_added\u001b[38;5;241m.\u001b[39madd(section)\n\u001b[1;32m--> 747\u001b[0m \u001b[38;5;28;01mfor\u001b[39;00m key, value \u001b[38;5;129;01min\u001b[39;00m keys\u001b[38;5;241m.\u001b[39mitems():\n\u001b[0;32m 748\u001b[0m key \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39moptionxform(\u001b[38;5;28mstr\u001b[39m(key))\n\u001b[0;32m 749\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m value \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m:\n",
176
- "File \u001b[1;32m~\\anaconda3\\lib\\_collections_abc.py:851\u001b[0m, in \u001b[0;36mItemsView.__iter__\u001b[1;34m(self)\u001b[0m\n\u001b[0;32m 849\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21m__iter__\u001b[39m(\u001b[38;5;28mself\u001b[39m):\n\u001b[0;32m 850\u001b[0m \u001b[38;5;28;01mfor\u001b[39;00m key \u001b[38;5;129;01min\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_mapping:\n\u001b[1;32m--> 851\u001b[0m \u001b[38;5;28;01myield\u001b[39;00m (key, \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_mapping\u001b[49m\u001b[43m[\u001b[49m\u001b[43mkey\u001b[49m\u001b[43m]\u001b[49m)\n",
177
- "File \u001b[1;32m~\\anaconda3\\lib\\configparser.py:1258\u001b[0m, in \u001b[0;36mSectionProxy.__getitem__\u001b[1;34m(self, key)\u001b[0m\n\u001b[0;32m 1256\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_parser\u001b[38;5;241m.\u001b[39mhas_option(\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_name, key):\n\u001b[0;32m 1257\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m \u001b[38;5;167;01mKeyError\u001b[39;00m(key)\n\u001b[1;32m-> 1258\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_parser\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mget\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_name\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mkey\u001b[49m\u001b[43m)\u001b[49m\n",
178
- "File \u001b[1;32m~\\anaconda3\\lib\\configparser.py:799\u001b[0m, in \u001b[0;36mRawConfigParser.get\u001b[1;34m(self, section, option, raw, vars, fallback)\u001b[0m\n\u001b[0;32m 797\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m value\n\u001b[0;32m 798\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[1;32m--> 799\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_interpolation\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mbefore_get\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43msection\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43moption\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mvalue\u001b[49m\u001b[43m,\u001b[49m\n\u001b[0;32m 800\u001b[0m \u001b[43m \u001b[49m\u001b[43md\u001b[49m\u001b[43m)\u001b[49m\n",
179
- "File \u001b[1;32m~\\anaconda3\\lib\\configparser.py:395\u001b[0m, in \u001b[0;36mBasicInterpolation.before_get\u001b[1;34m(self, parser, section, option, value, defaults)\u001b[0m\n\u001b[0;32m 393\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21mbefore_get\u001b[39m(\u001b[38;5;28mself\u001b[39m, parser, section, option, value, defaults):\n\u001b[0;32m 394\u001b[0m L \u001b[38;5;241m=\u001b[39m []\n\u001b[1;32m--> 395\u001b[0m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_interpolate_some\u001b[49m\u001b[43m(\u001b[49m\u001b[43mparser\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43moption\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mL\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mvalue\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43msection\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mdefaults\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m1\u001b[39;49m\u001b[43m)\u001b[49m\n\u001b[0;32m 396\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;124m'\u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;241m.\u001b[39mjoin(L)\n",
180
- "File \u001b[1;32m~\\anaconda3\\lib\\configparser.py:434\u001b[0m, in \u001b[0;36mBasicInterpolation._interpolate_some\u001b[1;34m(self, parser, option, accum, rest, section, map, depth)\u001b[0m\n\u001b[0;32m 432\u001b[0m v \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mmap\u001b[39m[var]\n\u001b[0;32m 433\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m \u001b[38;5;167;01mKeyError\u001b[39;00m:\n\u001b[1;32m--> 434\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m InterpolationMissingOptionError(\n\u001b[0;32m 435\u001b[0m option, section, rawval, var) \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;28mNone\u001b[39m\n\u001b[0;32m 436\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124m%\u001b[39m\u001b[38;5;124m\"\u001b[39m \u001b[38;5;129;01min\u001b[39;00m v:\n\u001b[0;32m 437\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_interpolate_some(parser, option, accum, v,\n\u001b[0;32m 438\u001b[0m section, \u001b[38;5;28mmap\u001b[39m, depth \u001b[38;5;241m+\u001b[39m \u001b[38;5;241m1\u001b[39m)\n",
181
- "\u001b[1;31mInterpolationMissingOptionError\u001b[0m: Bad value substitution: option 'doc_host' in section 'DEFAULT' contains an interpolation key 'user' which is not a valid option name. Raw value: 'https://%(user)s.github.io'"
182
- ]
183
- }
184
- ],
185
- "source": [
186
- "from nbdev import get_config\n",
187
- "#get_config (cfg_name='settings.ini', path=None)\n",
188
- "get_config (cfg_name='settings.ini')"
189
- ]
190
- },
191
- {
192
- "cell_type": "code",
193
- "execution_count": 10,
194
- "id": "475cb737",
195
- "metadata": {},
196
- "outputs": [
197
- {
198
- "ename": "InterpolationMissingOptionError",
199
- "evalue": "Bad value substitution: option 'doc_host' in section 'DEFAULT' contains an interpolation key 'user' which is not a valid option name. Raw value: 'https://%(user)s.github.io'",
200
- "output_type": "error",
201
- "traceback": [
202
- "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
203
- "\u001b[1;31mInterpolationMissingOptionError\u001b[0m Traceback (most recent call last)",
204
- "Input \u001b[1;32mIn [10]\u001b[0m, in \u001b[0;36m<cell line: 1>\u001b[1;34m()\u001b[0m\n\u001b[1;32m----> 1\u001b[0m \u001b[43mnotebook2script\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[38;5;124;43mNovaOrToast.ipynb\u001b[39;49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[43m)\u001b[49m\n",
205
- "File \u001b[1;32m~\\anaconda3\\lib\\site-packages\\nbdev\\export.py:444\u001b[0m, in \u001b[0;36mnotebook2script\u001b[1;34m(fname, silent, to_dict, bare)\u001b[0m\n\u001b[0;32m 442\u001b[0m files \u001b[38;5;241m=\u001b[39m nbglob(fname\u001b[38;5;241m=\u001b[39mfname)\n\u001b[0;32m 443\u001b[0m d \u001b[38;5;241m=\u001b[39m collections\u001b[38;5;241m.\u001b[39mdefaultdict(\u001b[38;5;28mlist\u001b[39m) \u001b[38;5;28;01mif\u001b[39;00m to_dict \u001b[38;5;28;01melse\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m\n\u001b[1;32m--> 444\u001b[0m modules \u001b[38;5;241m=\u001b[39m \u001b[43mcreate_mod_files\u001b[49m\u001b[43m(\u001b[49m\u001b[43mfiles\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mto_dict\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mbare\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mbare\u001b[49m\u001b[43m)\u001b[49m\n\u001b[0;32m 445\u001b[0m \u001b[38;5;28;01mfor\u001b[39;00m f \u001b[38;5;129;01min\u001b[39;00m \u001b[38;5;28msorted\u001b[39m(files): d \u001b[38;5;241m=\u001b[39m _notebook2script(f, modules, silent\u001b[38;5;241m=\u001b[39msilent, to_dict\u001b[38;5;241m=\u001b[39md, bare\u001b[38;5;241m=\u001b[39mbare)\n\u001b[0;32m 446\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m to_dict: \u001b[38;5;28;01mreturn\u001b[39;00m d\n",
206
- "File \u001b[1;32m~\\anaconda3\\lib\\site-packages\\nbdev\\export.py:327\u001b[0m, in \u001b[0;36mcreate_mod_files\u001b[1;34m(files, to_dict, bare)\u001b[0m\n\u001b[0;32m 325\u001b[0m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mCreate mod files for default exports found in `files`\u001b[39m\u001b[38;5;124m\"\u001b[39m\n\u001b[0;32m 326\u001b[0m modules \u001b[38;5;241m=\u001b[39m []\n\u001b[1;32m--> 327\u001b[0m \u001b[38;5;28;01mtry\u001b[39;00m: lib_path \u001b[38;5;241m=\u001b[39m \u001b[43mget_config\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\u001b[38;5;241m.\u001b[39mpath(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mlib_path\u001b[39m\u001b[38;5;124m\"\u001b[39m)\n\u001b[0;32m 328\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m \u001b[38;5;167;01mFileNotFoundError\u001b[39;00m: lib_path \u001b[38;5;241m=\u001b[39m Path()\n\u001b[0;32m 329\u001b[0m \u001b[38;5;28;01mtry\u001b[39;00m: nbs_path \u001b[38;5;241m=\u001b[39m get_config()\u001b[38;5;241m.\u001b[39mpath(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mnbs_path\u001b[39m\u001b[38;5;124m\"\u001b[39m)\n",
207
- "File \u001b[1;32m~\\anaconda3\\lib\\site-packages\\nbdev\\imports.py:30\u001b[0m, in \u001b[0;36mget_config\u001b[1;34m(cfg_name)\u001b[0m\n\u001b[0;32m 28\u001b[0m \u001b[38;5;28;01mwhile\u001b[39;00m cfg_path \u001b[38;5;241m!=\u001b[39m cfg_path\u001b[38;5;241m.\u001b[39mparent \u001b[38;5;129;01mand\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m (cfg_path\u001b[38;5;241m/\u001b[39mcfg_name)\u001b[38;5;241m.\u001b[39mexists(): cfg_path \u001b[38;5;241m=\u001b[39m cfg_path\u001b[38;5;241m.\u001b[39mparent\n\u001b[0;32m 29\u001b[0m config \u001b[38;5;241m=\u001b[39m Config(cfg_path, cfg_name\u001b[38;5;241m=\u001b[39mcfg_name)\n\u001b[1;32m---> 30\u001b[0m \u001b[43m_add_new_defaults\u001b[49m\u001b[43m(\u001b[49m\u001b[43mconfig\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43md\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mconfig\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mconfig_file\u001b[49m\u001b[43m,\u001b[49m\n\u001b[0;32m 31\u001b[0m \u001b[43m \u001b[49m\u001b[43mhost\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mgithub\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mdoc_host\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mhttps://\u001b[39;49m\u001b[38;5;132;43;01m%(user)s\u001b[39;49;00m\u001b[38;5;124;43m.github.io\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mdoc_baseurl\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43m/\u001b[39;49m\u001b[38;5;132;43;01m%(lib_name)s\u001b[39;49;00m\u001b[38;5;124;43m/\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m)\u001b[49m\n\u001b[0;32m 32\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m config\n",
208
- "File \u001b[1;32m~\\anaconda3\\lib\\site-packages\\nbdev\\imports.py:23\u001b[0m, in \u001b[0;36m_add_new_defaults\u001b[1;34m(cfg, file, **kwargs)\u001b[0m\n\u001b[0;32m 21\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m cfg\u001b[38;5;241m.\u001b[39mget(k, \u001b[38;5;28;01mNone\u001b[39;00m) \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m:\n\u001b[0;32m 22\u001b[0m cfg[k] \u001b[38;5;241m=\u001b[39m v\n\u001b[1;32m---> 23\u001b[0m \u001b[43msave_config_file\u001b[49m\u001b[43m(\u001b[49m\u001b[43mfile\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mcfg\u001b[49m\u001b[43m)\u001b[49m\n",
209
- "File \u001b[1;32m~\\anaconda3\\lib\\site-packages\\fastcore\\foundation.py:240\u001b[0m, in \u001b[0;36msave_config_file\u001b[1;34m(file, d, **kwargs)\u001b[0m\n\u001b[0;32m 238\u001b[0m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mWrite settings dict to a new config file, or overwrite the existing one.\u001b[39m\u001b[38;5;124m\"\u001b[39m\n\u001b[0;32m 239\u001b[0m config \u001b[38;5;241m=\u001b[39m ConfigParser(\u001b[38;5;241m*\u001b[39m\u001b[38;5;241m*\u001b[39mkwargs)\n\u001b[1;32m--> 240\u001b[0m config[\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mDEFAULT\u001b[39m\u001b[38;5;124m'\u001b[39m] \u001b[38;5;241m=\u001b[39m d\n\u001b[0;32m 241\u001b[0m config\u001b[38;5;241m.\u001b[39mwrite(\u001b[38;5;28mopen\u001b[39m(file, \u001b[38;5;124m'\u001b[39m\u001b[38;5;124mw\u001b[39m\u001b[38;5;124m'\u001b[39m))\n",
210
- "File \u001b[1;32m~\\anaconda3\\lib\\configparser.py:977\u001b[0m, in \u001b[0;36mRawConfigParser.__setitem__\u001b[1;34m(self, key, value)\u001b[0m\n\u001b[0;32m 975\u001b[0m \u001b[38;5;28;01melif\u001b[39;00m key \u001b[38;5;129;01min\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_sections:\n\u001b[0;32m 976\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_sections[key]\u001b[38;5;241m.\u001b[39mclear()\n\u001b[1;32m--> 977\u001b[0m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mread_dict\u001b[49m\u001b[43m(\u001b[49m\u001b[43m{\u001b[49m\u001b[43mkey\u001b[49m\u001b[43m:\u001b[49m\u001b[43m \u001b[49m\u001b[43mvalue\u001b[49m\u001b[43m}\u001b[49m\u001b[43m)\u001b[49m\n",
211
- "File \u001b[1;32m~\\anaconda3\\lib\\configparser.py:747\u001b[0m, in \u001b[0;36mRawConfigParser.read_dict\u001b[1;34m(self, dictionary, source)\u001b[0m\n\u001b[0;32m 745\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m\n\u001b[0;32m 746\u001b[0m elements_added\u001b[38;5;241m.\u001b[39madd(section)\n\u001b[1;32m--> 747\u001b[0m \u001b[38;5;28;01mfor\u001b[39;00m key, value \u001b[38;5;129;01min\u001b[39;00m keys\u001b[38;5;241m.\u001b[39mitems():\n\u001b[0;32m 748\u001b[0m key \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39moptionxform(\u001b[38;5;28mstr\u001b[39m(key))\n\u001b[0;32m 749\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m value \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m:\n",
212
- "File \u001b[1;32m~\\anaconda3\\lib\\_collections_abc.py:851\u001b[0m, in \u001b[0;36mItemsView.__iter__\u001b[1;34m(self)\u001b[0m\n\u001b[0;32m 849\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21m__iter__\u001b[39m(\u001b[38;5;28mself\u001b[39m):\n\u001b[0;32m 850\u001b[0m \u001b[38;5;28;01mfor\u001b[39;00m key \u001b[38;5;129;01min\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_mapping:\n\u001b[1;32m--> 851\u001b[0m \u001b[38;5;28;01myield\u001b[39;00m (key, \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_mapping\u001b[49m\u001b[43m[\u001b[49m\u001b[43mkey\u001b[49m\u001b[43m]\u001b[49m)\n",
213
- "File \u001b[1;32m~\\anaconda3\\lib\\configparser.py:1258\u001b[0m, in \u001b[0;36mSectionProxy.__getitem__\u001b[1;34m(self, key)\u001b[0m\n\u001b[0;32m 1256\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_parser\u001b[38;5;241m.\u001b[39mhas_option(\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_name, key):\n\u001b[0;32m 1257\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m \u001b[38;5;167;01mKeyError\u001b[39;00m(key)\n\u001b[1;32m-> 1258\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_parser\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mget\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_name\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mkey\u001b[49m\u001b[43m)\u001b[49m\n",
214
- "File \u001b[1;32m~\\anaconda3\\lib\\configparser.py:799\u001b[0m, in \u001b[0;36mRawConfigParser.get\u001b[1;34m(self, section, option, raw, vars, fallback)\u001b[0m\n\u001b[0;32m 797\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m value\n\u001b[0;32m 798\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[1;32m--> 799\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_interpolation\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mbefore_get\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43msection\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43moption\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mvalue\u001b[49m\u001b[43m,\u001b[49m\n\u001b[0;32m 800\u001b[0m \u001b[43m \u001b[49m\u001b[43md\u001b[49m\u001b[43m)\u001b[49m\n",
215
- "File \u001b[1;32m~\\anaconda3\\lib\\configparser.py:395\u001b[0m, in \u001b[0;36mBasicInterpolation.before_get\u001b[1;34m(self, parser, section, option, value, defaults)\u001b[0m\n\u001b[0;32m 393\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21mbefore_get\u001b[39m(\u001b[38;5;28mself\u001b[39m, parser, section, option, value, defaults):\n\u001b[0;32m 394\u001b[0m L \u001b[38;5;241m=\u001b[39m []\n\u001b[1;32m--> 395\u001b[0m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_interpolate_some\u001b[49m\u001b[43m(\u001b[49m\u001b[43mparser\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43moption\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mL\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mvalue\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43msection\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mdefaults\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m1\u001b[39;49m\u001b[43m)\u001b[49m\n\u001b[0;32m 396\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;124m'\u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;241m.\u001b[39mjoin(L)\n",
216
- "File \u001b[1;32m~\\anaconda3\\lib\\configparser.py:434\u001b[0m, in \u001b[0;36mBasicInterpolation._interpolate_some\u001b[1;34m(self, parser, option, accum, rest, section, map, depth)\u001b[0m\n\u001b[0;32m 432\u001b[0m v \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mmap\u001b[39m[var]\n\u001b[0;32m 433\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m \u001b[38;5;167;01mKeyError\u001b[39;00m:\n\u001b[1;32m--> 434\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m InterpolationMissingOptionError(\n\u001b[0;32m 435\u001b[0m option, section, rawval, var) \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;28mNone\u001b[39m\n\u001b[0;32m 436\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124m%\u001b[39m\u001b[38;5;124m\"\u001b[39m \u001b[38;5;129;01min\u001b[39;00m v:\n\u001b[0;32m 437\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_interpolate_some(parser, option, accum, v,\n\u001b[0;32m 438\u001b[0m section, \u001b[38;5;28mmap\u001b[39m, depth \u001b[38;5;241m+\u001b[39m \u001b[38;5;241m1\u001b[39m)\n",
217
- "\u001b[1;31mInterpolationMissingOptionError\u001b[0m: Bad value substitution: option 'doc_host' in section 'DEFAULT' contains an interpolation key 'user' which is not a valid option name. Raw value: 'https://%(user)s.github.io'"
218
- ]
219
- }
220
- ],
221
- "source": [
222
- "notebook2script('NovaOrToast.ipynb')"
223
- ]
224
- }
225
- ],
226
- "metadata": {
227
- "kernelspec": {
228
- "display_name": "Python 3 (ipykernel)",
229
- "language": "python",
230
- "name": "python3"
231
- },
232
- "language_info": {
233
- "codemirror_mode": {
234
- "name": "ipython",
235
- "version": 3
236
- },
237
- "file_extension": ".py",
238
- "mimetype": "text/x-python",
239
- "name": "python",
240
- "nbconvert_exporter": "python",
241
- "pygments_lexer": "ipython3",
242
- "version": "3.9.12"
243
- }
244
- },
245
- "nbformat": 4,
246
- "nbformat_minor": 5
247
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app.ipynb ADDED
@@ -0,0 +1,201 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "markdown",
5
+ "id": "fb0b148e",
6
+ "metadata": {},
7
+ "source": [
8
+ "# This notebook is the .ipynb file for the model. \n",
9
+ "The code has been commmented in order to explain various parts, including the unused commented out parts."
10
+ ]
11
+ },
12
+ {
13
+ "cell_type": "code",
14
+ "execution_count": 10,
15
+ "id": "e39e2ed1",
16
+ "metadata": {},
17
+ "outputs": [],
18
+ "source": [
19
+ "#|default_exp app"
20
+ ]
21
+ },
22
+ {
23
+ "cell_type": "code",
24
+ "execution_count": 11,
25
+ "id": "435a6f23",
26
+ "metadata": {},
27
+ "outputs": [],
28
+ "source": [
29
+ "# On my computer, I use Anaconda, where these packages are already installed, so there is no need to install them on the notebook\n",
30
+ "# On HuggingFaceSpaces, these packages have been put into requirements.txt so that the website installs them\n",
31
+ "# Therefore there is no need to install them \n",
32
+ "\n",
33
+ "#%pip install -q gradio\n",
34
+ "#%pip install fastbook\n",
35
+ "#%pip install -Uqq fastai"
36
+ ]
37
+ },
38
+ {
39
+ "cell_type": "code",
40
+ "execution_count": 12,
41
+ "id": "a89a7628",
42
+ "metadata": {},
43
+ "outputs": [],
44
+ "source": [
45
+ "#|export\n",
46
+ "# Importing neccesary modules\n",
47
+ "import fastbook\n",
48
+ "fastbook.setup_book()\n",
49
+ "from fastbook import *\n",
50
+ "from fastai.vision.widgets import *\n",
51
+ "from fastai.vision.all import *\n",
52
+ "import gradio as gr"
53
+ ]
54
+ },
55
+ {
56
+ "cell_type": "code",
57
+ "execution_count": 13,
58
+ "id": "8c95d6bd",
59
+ "metadata": {},
60
+ "outputs": [],
61
+ "source": [
62
+ "# There was an error with the module Pillow, it was not updated and I attempted to update it within the notebook\n",
63
+ "# This was not neccesary as I updated Pillow on my anaconda app and it fixed it.\n",
64
+ "\n",
65
+ "#!pip uninstall Pillow\n",
66
+ "#!pip install Pillow"
67
+ ]
68
+ },
69
+ {
70
+ "cell_type": "code",
71
+ "execution_count": 14,
72
+ "id": "fe4889a5",
73
+ "metadata": {},
74
+ "outputs": [],
75
+ "source": [
76
+ "# There was an error the first time I ran this code on the notebook: \"NotImplementedError: cannot instantiate 'PosixPath' on your system\"\n",
77
+ "# this code fixed it, but as it is suited for windows,\n",
78
+ "# this causes an error on HuggingSpaceFaces, which likely uses linux. \n",
79
+ "# Strangely, simply commenting this code out does not cause the initial error on HuggingFaceSpaces and works for it\n",
80
+ "\n",
81
+ "import pathlib\n",
82
+ "temp = pathlib.PosixPath\n",
83
+ "pathlib.PosixPath = pathlib.WindowsPath"
84
+ ]
85
+ },
86
+ {
87
+ "cell_type": "code",
88
+ "execution_count": 15,
89
+ "id": "d1d0d596",
90
+ "metadata": {},
91
+ "outputs": [
92
+ {
93
+ "name": "stderr",
94
+ "output_type": "stream",
95
+ "text": [
96
+ "C:\\Users\\Adnan\\anaconda3\\lib\\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",
97
+ " warnings.warn(\n",
98
+ "C:\\Users\\Adnan\\anaconda3\\lib\\site-packages\\gradio\\deprecation.py:40: UserWarning: `optional` parameter is deprecated, and it has no effect\n",
99
+ " warnings.warn(value)\n",
100
+ "C:\\Users\\Adnan\\anaconda3\\lib\\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",
101
+ " warnings.warn(\n",
102
+ "C:\\Users\\Adnan\\anaconda3\\lib\\site-packages\\gradio\\deprecation.py:40: UserWarning: The 'type' parameter has been deprecated. Use the Number component instead.\n",
103
+ " warnings.warn(value)\n"
104
+ ]
105
+ },
106
+ {
107
+ "name": "stdout",
108
+ "output_type": "stream",
109
+ "text": [
110
+ "Running on local URL: http://127.0.0.1:7861\n",
111
+ "\n",
112
+ "To create a public link, set `share=True` in `launch()`.\n"
113
+ ]
114
+ },
115
+ {
116
+ "data": {
117
+ "text/plain": [
118
+ "(<gradio.routes.App at 0x2b1d5af4640>, 'http://127.0.0.1:7861/', None)"
119
+ ]
120
+ },
121
+ "execution_count": 15,
122
+ "metadata": {},
123
+ "output_type": "execute_result"
124
+ }
125
+ ],
126
+ "source": [
127
+ "#|export\n",
128
+ "learn_inf = load_learner('NovaOrToastModel.pkl') # Loading the model\n",
129
+ "learn_inf.dls.vocab # Returns a list of the categories\n",
130
+ "categories = learn_inf.dls.vocab\n",
131
+ "\n",
132
+ "# Gradio code:\n",
133
+ "\n",
134
+ "# Function for Gradio to use to classify images\n",
135
+ "def classify_image(img):\n",
136
+ " pred, idx, probs = learn_inf.predict(img)\n",
137
+ " return dict(zip(categories, map(float,probs)))\n",
138
+ "\n",
139
+ "image = gr.inputs.Image(shape=(192,192)) \n",
140
+ "label = gr.outputs.Label()\n",
141
+ "examples = [\"ToastTest.jpeg\"]\n",
142
+ "\n",
143
+ "intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples)\n",
144
+ "intf.launch(inline=False)"
145
+ ]
146
+ },
147
+ {
148
+ "cell_type": "code",
149
+ "execution_count": 16,
150
+ "id": "300585db",
151
+ "metadata": {},
152
+ "outputs": [],
153
+ "source": [
154
+ "from nbdev.export import notebook2script"
155
+ ]
156
+ },
157
+ {
158
+ "cell_type": "code",
159
+ "execution_count": 17,
160
+ "id": "72d6a182",
161
+ "metadata": {},
162
+ "outputs": [],
163
+ "source": [
164
+ "#from nbdev import get_config\n",
165
+ "#get_config (cfg_name='settings.ini', path=None)\n",
166
+ "#get_config (cfg_name='settings.ini')"
167
+ ]
168
+ },
169
+ {
170
+ "cell_type": "code",
171
+ "execution_count": 19,
172
+ "id": "fad6e0cf",
173
+ "metadata": {},
174
+ "outputs": [],
175
+ "source": [
176
+ "notebook2script('NovaOrToast.ipynb')"
177
+ ]
178
+ }
179
+ ],
180
+ "metadata": {
181
+ "kernelspec": {
182
+ "display_name": "Python 3 (ipykernel)",
183
+ "language": "python",
184
+ "name": "python3"
185
+ },
186
+ "language_info": {
187
+ "codemirror_mode": {
188
+ "name": "ipython",
189
+ "version": 3
190
+ },
191
+ "file_extension": ".py",
192
+ "mimetype": "text/x-python",
193
+ "name": "python",
194
+ "nbconvert_exporter": "python",
195
+ "pygments_lexer": "ipython3",
196
+ "version": "3.9.12"
197
+ }
198
+ },
199
+ "nbformat": 4,
200
+ "nbformat_minor": 5
201
+ }
app.py CHANGED
@@ -1,17 +1,9 @@
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 *
@@ -19,41 +11,21 @@ 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
-
 
1
+ # AUTOGENERATED! DO NOT EDIT! File to edit: nbs/app.ipynb (unless otherwise specified).
 
 
 
 
 
 
 
 
 
 
 
2
 
3
+ __all__ = ['classify_image', 'learn_inf', 'categories', 'image', 'label', 'examples', 'intf']
4
 
5
+ # Cell
6
+ # Importing neccesary modules
7
  import fastbook
8
  fastbook.setup_book()
9
  from fastbook import *
 
11
  from fastai.vision.all import *
12
  import gradio as gr
13
 
14
+ # Cell
15
+ learn_inf = load_learner('NovaOrToastModel.pkl') # Loading the model
16
+ learn_inf.dls.vocab # Returns a list of the categories
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
17
  categories = learn_inf.dls.vocab
18
 
19
+ # Gradio code:
20
+
21
+ # Function for Gradio to use to classify images
22
  def classify_image(img):
23
  pred, idx, probs = learn_inf.predict(img)
24
  return dict(zip(categories, map(float,probs)))
25
 
26
+ image = gr.inputs.Image(shape=(192,192))
27
  label = gr.outputs.Label()
28
  examples = ["ToastTest.jpeg"]
29
 
30
  intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples)
31
+ intf.launch(inline=False)
 
oldapp.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
+
settings.ini ADDED
@@ -0,0 +1,71 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [DEFAULT]
2
+ lib_name = nbdev
3
+ repo = nbdev
4
+ description = Create delightful software with Jupyter Notebooks
5
+ copyright = 2020 onwards, Jeremy Howard
6
+ keywords = nbdev fastai jupyter notebook export
7
+ user = fastai
8
+ author = Jeremy Howard and Hamel Husain
9
+ author_email = j@fast.ai
10
+ branch = master
11
+ min_python = 3.7
12
+ version = 2.3.3
13
+ audience = Developers
14
+ language = English
15
+ custom_sidebar = True
16
+ license = apache2
17
+ status = 2
18
+ requirements = fastcore>=1.5.24 execnb>=0.1.3 astunparse ghapi>=1.0.3 watchdog asttokens
19
+ pip_requirements = PyYAML
20
+ conda_requirements = pyyaml
21
+ conda_user = fastai
22
+ dev_requirements = nbdev-numpy nbdev-stdlib pandas matplotlib black svg.py jupyter
23
+ console_scripts = nbdev_create_config=nbdev.config:nbdev_create_config
24
+ nbdev_update=nbdev.sync:nbdev_update
25
+ nbdev_export=nbdev.doclinks:nbdev_export
26
+ nbdev_fix=nbdev.merge:nbdev_fix
27
+ nbdev_merge=nbdev.merge:nbdev_merge
28
+ nbdev_trust=nbdev.clean:nbdev_trust
29
+ nbdev_clean=nbdev.clean:nbdev_clean
30
+ nbdev_install_hooks=nbdev.clean:nbdev_install_hooks
31
+ nbdev_filter=nbdev.cli:nbdev_filter
32
+ nbdev_sidebar=nbdev.quarto:nbdev_sidebar
33
+ nbdev_test=nbdev.test:nbdev_test
34
+ nbdev_new=nbdev.cli:nbdev_new
35
+ nbdev_migrate=nbdev.migrate:nbdev_migrate
36
+ nbdev_install_quarto=nbdev.quarto:install_quarto
37
+ nbdev_install=nbdev.quarto:install
38
+ nbdev_docs=nbdev.quarto:nbdev_docs
39
+ nbdev_preview=nbdev.quarto:nbdev_preview
40
+ nbdev_deploy=nbdev.quarto:deploy
41
+ nbdev_prepare=nbdev.quarto:prepare
42
+ nbdev_readme=nbdev.quarto:nbdev_readme
43
+ nbdev_release_gh=nbdev.release:release_gh
44
+ nbdev_release_git=nbdev.release:release_git
45
+ nbdev_changelog=nbdev.release:changelog
46
+ nbdev_pypi=nbdev.release:release_pypi
47
+ nbdev_conda=nbdev.release:release_conda
48
+ nbdev_release_both=nbdev.release:release_both
49
+ nbdev_bump_version=nbdev.release:nbdev_bump_version
50
+ nbdev_proc_nbs=nbdev.serve:proc_nbs
51
+ nbdev_help=nbdev.cli:chelp
52
+ tst_flags = notest
53
+ nbs_path = nbs
54
+ doc_path = _docs
55
+ recursive = True
56
+ doc_host = https://nbdev.fast.ai
57
+ doc_baseurl = /
58
+ git_url = https://github.com/fastai/nbdev
59
+ lib_path = nbdev
60
+ title = nbdev
61
+ black_formatting = False
62
+ readme_nb = getting_started.ipynb
63
+ allowed_metadata_keys =
64
+ allowed_cell_metadata_keys =
65
+ jupyter_hooks = True
66
+ clean_ids = False
67
+ custom_quarto_yml = True
68
+ clear_all = False
69
+ put_version_in_init = True
70
+ host = github
71
+