pksx01 commited on
Commit
34989ce
1 Parent(s): bad1e90

Adding files for Deploying gradio app to Huggingface spaces

Browse files
Files changed (3) hide show
  1. app.ipynb +444 -0
  2. lambo2.jpg +0 -0
  3. requirements.txt +2 -0
app.ipynb ADDED
@@ -0,0 +1,444 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "code",
5
+ "execution_count": 1,
6
+ "metadata": {},
7
+ "outputs": [],
8
+ "source": [
9
+ "#|default_exp app"
10
+ ]
11
+ },
12
+ {
13
+ "cell_type": "code",
14
+ "execution_count": 2,
15
+ "metadata": {},
16
+ "outputs": [
17
+ {
18
+ "name": "stdout",
19
+ "output_type": "stream",
20
+ "text": [
21
+ "Collecting gradio\n",
22
+ " Downloading gradio-3.2-py3-none-any.whl (6.1 MB)\n",
23
+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m6.1/6.1 MB\u001b[0m \u001b[31m16.5 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m00:01\u001b[0m00:01\u001b[0m\n",
24
+ "\u001b[?25hCollecting pycryptodome\n",
25
+ " Downloading pycryptodome-3.15.0.tar.gz (4.5 MB)\n",
26
+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m4.5/4.5 MB\u001b[0m \u001b[31m28.4 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m00:01\u001b[0m00:01\u001b[0m\n",
27
+ "\u001b[?25h Preparing metadata (setup.py) ... \u001b[?25ldone\n",
28
+ "\u001b[?25hCollecting ffmpy\n",
29
+ " Downloading ffmpy-0.3.0.tar.gz (4.8 kB)\n",
30
+ " Preparing metadata (setup.py) ... \u001b[?25ldone\n",
31
+ "\u001b[?25hCollecting pydub\n",
32
+ " Downloading pydub-0.25.1-py2.py3-none-any.whl (32 kB)\n",
33
+ "Collecting orjson\n",
34
+ " Downloading orjson-3.8.0-cp310-cp310-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl (483 kB)\n",
35
+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m483.2/483.2 kB\u001b[0m \u001b[31m17.5 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
36
+ "\u001b[?25hRequirement already satisfied: pillow in /Users/rudra/mambaforge/lib/python3.10/site-packages (from gradio) (9.2.0)\n",
37
+ "Collecting fastapi\n",
38
+ " Downloading fastapi-0.82.0-py3-none-any.whl (55 kB)\n",
39
+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m55.3/55.3 kB\u001b[0m \u001b[31m2.3 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
40
+ "\u001b[?25hRequirement already satisfied: Jinja2 in /Users/rudra/mambaforge/lib/python3.10/site-packages (from gradio) (3.1.2)\n",
41
+ "Collecting analytics-python\n",
42
+ " Downloading analytics_python-1.4.0-py2.py3-none-any.whl (15 kB)\n",
43
+ "Collecting websockets\n",
44
+ " Downloading websockets-10.3-cp310-cp310-macosx_11_0_arm64.whl (97 kB)\n",
45
+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m97.3/97.3 kB\u001b[0m \u001b[31m4.1 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
46
+ "\u001b[?25hRequirement already satisfied: matplotlib in /Users/rudra/mambaforge/lib/python3.10/site-packages (from gradio) (3.5.3)\n",
47
+ "Collecting aiohttp\n",
48
+ " Downloading aiohttp-3.8.1-cp310-cp310-macosx_11_0_arm64.whl (552 kB)\n",
49
+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m552.5/552.5 kB\u001b[0m \u001b[31m15.6 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
50
+ "\u001b[?25hRequirement already satisfied: numpy in /Users/rudra/mambaforge/lib/python3.10/site-packages (from gradio) (1.23.2)\n",
51
+ "Requirement already satisfied: requests in /Users/rudra/mambaforge/lib/python3.10/site-packages (from gradio) (2.28.1)\n",
52
+ "Collecting markdown-it-py[linkify,plugins]\n",
53
+ " Downloading markdown_it_py-2.1.0-py3-none-any.whl (84 kB)\n",
54
+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m84.5/84.5 kB\u001b[0m \u001b[31m3.3 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
55
+ "\u001b[?25hCollecting fsspec\n",
56
+ " Downloading fsspec-2022.8.2-py3-none-any.whl (140 kB)\n",
57
+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m140.8/140.8 kB\u001b[0m \u001b[31m5.6 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
58
+ "\u001b[?25hRequirement already satisfied: pydantic in /Users/rudra/mambaforge/lib/python3.10/site-packages (from gradio) (1.9.2)\n",
59
+ "Collecting paramiko\n",
60
+ " Downloading paramiko-2.11.0-py2.py3-none-any.whl (212 kB)\n",
61
+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m212.9/212.9 kB\u001b[0m \u001b[31m2.4 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0ma \u001b[36m0:00:01\u001b[0m\n",
62
+ "\u001b[?25hCollecting python-multipart\n",
63
+ " Downloading python-multipart-0.0.5.tar.gz (32 kB)\n",
64
+ " Preparing metadata (setup.py) ... \u001b[?25ldone\n",
65
+ "\u001b[?25hCollecting h11<0.13,>=0.11\n",
66
+ " Downloading h11-0.12.0-py3-none-any.whl (54 kB)\n",
67
+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m54.9/54.9 kB\u001b[0m \u001b[31m2.2 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
68
+ "\u001b[?25hCollecting httpx\n",
69
+ " Downloading httpx-0.23.0-py3-none-any.whl (84 kB)\n",
70
+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m84.8/84.8 kB\u001b[0m \u001b[31m3.6 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
71
+ "\u001b[?25hRequirement already satisfied: pandas in /Users/rudra/mambaforge/lib/python3.10/site-packages (from gradio) (1.4.4)\n",
72
+ "Collecting uvicorn\n",
73
+ " Downloading uvicorn-0.18.3-py3-none-any.whl (57 kB)\n",
74
+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m57.4/57.4 kB\u001b[0m \u001b[31m1.7 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
75
+ "\u001b[?25hCollecting multidict<7.0,>=4.5\n",
76
+ " Downloading multidict-6.0.2-cp310-cp310-macosx_11_0_arm64.whl (29 kB)\n",
77
+ "Collecting aiosignal>=1.1.2\n",
78
+ " Downloading aiosignal-1.2.0-py3-none-any.whl (8.2 kB)\n",
79
+ "Collecting yarl<2.0,>=1.0\n",
80
+ " Downloading yarl-1.8.1-cp310-cp310-macosx_11_0_arm64.whl (57 kB)\n",
81
+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m57.7/57.7 kB\u001b[0m \u001b[31m2.3 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
82
+ "\u001b[?25hCollecting frozenlist>=1.1.1\n",
83
+ " Downloading frozenlist-1.3.1-cp310-cp310-macosx_11_0_arm64.whl (34 kB)\n",
84
+ "Requirement already satisfied: attrs>=17.3.0 in /Users/rudra/mambaforge/lib/python3.10/site-packages (from aiohttp->gradio) (22.1.0)\n",
85
+ "Collecting async-timeout<5.0,>=4.0.0a3\n",
86
+ " Downloading async_timeout-4.0.2-py3-none-any.whl (5.8 kB)\n",
87
+ "Requirement already satisfied: charset-normalizer<3.0,>=2.0 in /Users/rudra/mambaforge/lib/python3.10/site-packages (from aiohttp->gradio) (2.1.1)\n",
88
+ "Requirement already satisfied: python-dateutil>2.1 in /Users/rudra/mambaforge/lib/python3.10/site-packages (from analytics-python->gradio) (2.8.2)\n",
89
+ "Requirement already satisfied: six>=1.5 in /Users/rudra/mambaforge/lib/python3.10/site-packages (from analytics-python->gradio) (1.16.0)\n",
90
+ "Collecting backoff==1.10.0\n",
91
+ " Downloading backoff-1.10.0-py2.py3-none-any.whl (31 kB)\n",
92
+ "Collecting monotonic>=1.5\n",
93
+ " Downloading monotonic-1.6-py2.py3-none-any.whl (8.2 kB)\n",
94
+ "Requirement already satisfied: urllib3<1.27,>=1.21.1 in /Users/rudra/mambaforge/lib/python3.10/site-packages (from requests->gradio) (1.26.11)\n",
95
+ "Requirement already satisfied: idna<4,>=2.5 in /Users/rudra/mambaforge/lib/python3.10/site-packages (from requests->gradio) (3.3)\n",
96
+ "Requirement already satisfied: certifi>=2017.4.17 in /Users/rudra/mambaforge/lib/python3.10/site-packages (from requests->gradio) (2022.6.15)\n",
97
+ "Collecting starlette==0.19.1\n",
98
+ " Downloading starlette-0.19.1-py3-none-any.whl (63 kB)\n",
99
+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m63.3/63.3 kB\u001b[0m \u001b[31m2.5 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
100
+ "\u001b[?25hCollecting anyio<5,>=3.4.0\n",
101
+ " Downloading anyio-3.6.1-py3-none-any.whl (80 kB)\n",
102
+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m80.6/80.6 kB\u001b[0m \u001b[31m3.2 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
103
+ "\u001b[?25hRequirement already satisfied: typing-extensions>=3.7.4.3 in /Users/rudra/mambaforge/lib/python3.10/site-packages (from pydantic->gradio) (4.3.0)\n",
104
+ "Collecting sniffio\n",
105
+ " Downloading sniffio-1.3.0-py3-none-any.whl (10 kB)\n",
106
+ "Collecting httpcore<0.16.0,>=0.15.0\n",
107
+ " Downloading httpcore-0.15.0-py3-none-any.whl (68 kB)\n",
108
+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m68.4/68.4 kB\u001b[0m \u001b[31m2.4 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
109
+ "\u001b[?25hCollecting rfc3986[idna2008]<2,>=1.3\n",
110
+ " Downloading rfc3986-1.5.0-py2.py3-none-any.whl (31 kB)\n",
111
+ "Requirement already satisfied: MarkupSafe>=2.0 in /Users/rudra/mambaforge/lib/python3.10/site-packages (from Jinja2->gradio) (2.1.1)\n",
112
+ "Collecting mdurl~=0.1\n",
113
+ " Downloading mdurl-0.1.2-py3-none-any.whl (10.0 kB)\n",
114
+ "Collecting mdit-py-plugins\n",
115
+ " Downloading mdit_py_plugins-0.3.0-py3-none-any.whl (43 kB)\n",
116
+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m43.7/43.7 kB\u001b[0m \u001b[31m1.5 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
117
+ "\u001b[?25hCollecting linkify-it-py~=1.0\n",
118
+ " Downloading linkify_it_py-1.0.3-py3-none-any.whl (19 kB)\n",
119
+ "Requirement already satisfied: packaging>=20.0 in /Users/rudra/mambaforge/lib/python3.10/site-packages (from matplotlib->gradio) (21.3)\n",
120
+ "Requirement already satisfied: cycler>=0.10 in /Users/rudra/mambaforge/lib/python3.10/site-packages (from matplotlib->gradio) (0.11.0)\n",
121
+ "Requirement already satisfied: pyparsing>=2.2.1 in /Users/rudra/mambaforge/lib/python3.10/site-packages (from matplotlib->gradio) (3.0.9)\n",
122
+ "Requirement already satisfied: fonttools>=4.22.0 in /Users/rudra/mambaforge/lib/python3.10/site-packages (from matplotlib->gradio) (4.37.1)\n",
123
+ "Requirement already satisfied: kiwisolver>=1.0.1 in /Users/rudra/mambaforge/lib/python3.10/site-packages (from matplotlib->gradio) (1.4.4)\n",
124
+ "Requirement already satisfied: pytz>=2020.1 in /Users/rudra/mambaforge/lib/python3.10/site-packages (from pandas->gradio) (2022.2.1)\n",
125
+ "Collecting pynacl>=1.0.1\n",
126
+ " Downloading PyNaCl-1.5.0-cp36-abi3-macosx_10_10_universal2.whl (349 kB)\n",
127
+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m349.9/349.9 kB\u001b[0m \u001b[31m13.4 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
128
+ "\u001b[?25hRequirement already satisfied: cryptography>=2.5 in /Users/rudra/mambaforge/lib/python3.10/site-packages (from paramiko->gradio) (37.0.4)\n"
129
+ ]
130
+ },
131
+ {
132
+ "name": "stdout",
133
+ "output_type": "stream",
134
+ "text": [
135
+ "Collecting bcrypt>=3.1.3\n",
136
+ " Downloading bcrypt-4.0.0-cp36-abi3-macosx_10_10_universal2.whl (475 kB)\n",
137
+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m475.0/475.0 kB\u001b[0m \u001b[31m16.7 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
138
+ "\u001b[?25hRequirement already satisfied: click>=7.0 in /Users/rudra/mambaforge/lib/python3.10/site-packages (from uvicorn->gradio) (8.1.3)\n",
139
+ "Requirement already satisfied: cffi>=1.12 in /Users/rudra/mambaforge/lib/python3.10/site-packages (from cryptography>=2.5->paramiko->gradio) (1.15.1)\n",
140
+ "Collecting uc-micro-py\n",
141
+ " Downloading uc_micro_py-1.0.1-py3-none-any.whl (6.2 kB)\n",
142
+ "Requirement already satisfied: pycparser in /Users/rudra/mambaforge/lib/python3.10/site-packages (from cffi>=1.12->cryptography>=2.5->paramiko->gradio) (2.21)\n",
143
+ "Building wheels for collected packages: ffmpy, pycryptodome, python-multipart\n",
144
+ " Building wheel for ffmpy (setup.py) ... \u001b[?25ldone\n",
145
+ "\u001b[?25h Created wheel for ffmpy: filename=ffmpy-0.3.0-py3-none-any.whl size=4693 sha256=cca6ffaeb95611efa462dd6db688783feed1689cfaf3dc0f4fdadff6b795d6f1\n",
146
+ " Stored in directory: /Users/rudra/Library/Caches/pip/wheels/0c/c2/0e/3b9c6845c6a4e35beb90910cc70d9ac9ab5d47402bd62af0df\n",
147
+ " Building wheel for pycryptodome (setup.py) ... \u001b[?25ldone\n",
148
+ "\u001b[?25h Created wheel for pycryptodome: filename=pycryptodome-3.15.0-cp35-abi3-macosx_11_0_arm64.whl size=1531792 sha256=4d20b21a578e519808e9790f3165eaa567e7948a7efb8ad2a95167b503b66c97\n",
149
+ " Stored in directory: /Users/rudra/Library/Caches/pip/wheels/cc/09/af/5da58a51ca5bf4bd4a37747a0658984c196aa2badf61236a35\n",
150
+ " Building wheel for python-multipart (setup.py) ... \u001b[?25ldone\n",
151
+ "\u001b[?25h Created wheel for python-multipart: filename=python_multipart-0.0.5-py3-none-any.whl size=31671 sha256=74cbcfb82ca96c926b3312fdff0ee48229ecef1fc306cf1b79eca31112851db6\n",
152
+ " Stored in directory: /Users/rudra/Library/Caches/pip/wheels/ae/3f/03/fa4bd98cd7f4a25e63b6a0b61a7a8352e0f874cd9de1f3390d\n",
153
+ "Successfully built ffmpy pycryptodome python-multipart\n",
154
+ "Installing collected packages: rfc3986, pydub, monotonic, ffmpy, websockets, uc-micro-py, sniffio, python-multipart, pycryptodome, orjson, multidict, mdurl, h11, fsspec, frozenlist, bcrypt, backoff, async-timeout, yarl, uvicorn, pynacl, markdown-it-py, linkify-it-py, anyio, analytics-python, aiosignal, starlette, paramiko, mdit-py-plugins, httpcore, aiohttp, httpx, fastapi, gradio\n",
155
+ "Successfully installed aiohttp-3.8.1 aiosignal-1.2.0 analytics-python-1.4.0 anyio-3.6.1 async-timeout-4.0.2 backoff-1.10.0 bcrypt-4.0.0 fastapi-0.82.0 ffmpy-0.3.0 frozenlist-1.3.1 fsspec-2022.8.2 gradio-3.2 h11-0.12.0 httpcore-0.15.0 httpx-0.23.0 linkify-it-py-1.0.3 markdown-it-py-2.1.0 mdit-py-plugins-0.3.0 mdurl-0.1.2 monotonic-1.6 multidict-6.0.2 orjson-3.8.0 paramiko-2.11.0 pycryptodome-3.15.0 pydub-0.25.1 pynacl-1.5.0 python-multipart-0.0.5 rfc3986-1.5.0 sniffio-1.3.0 starlette-0.19.1 uc-micro-py-1.0.1 uvicorn-0.18.3 websockets-10.3 yarl-1.8.1\n"
156
+ ]
157
+ }
158
+ ],
159
+ "source": [
160
+ "#!pip install gradio"
161
+ ]
162
+ },
163
+ {
164
+ "cell_type": "markdown",
165
+ "metadata": {},
166
+ "source": [
167
+ "# Lamborghini vs Mercedes"
168
+ ]
169
+ },
170
+ {
171
+ "cell_type": "code",
172
+ "execution_count": 3,
173
+ "metadata": {},
174
+ "outputs": [
175
+ {
176
+ "name": "stderr",
177
+ "output_type": "stream",
178
+ "text": [
179
+ "/Users/rudra/mambaforge/lib/python3.10/site-packages/tqdm/auto.py:22: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html\n",
180
+ " from .autonotebook import tqdm as notebook_tqdm\n"
181
+ ]
182
+ }
183
+ ],
184
+ "source": [
185
+ "#|export\n",
186
+ "\n",
187
+ "from fastai.vision.all import *\n",
188
+ "import gradio as gr"
189
+ ]
190
+ },
191
+ {
192
+ "cell_type": "code",
193
+ "execution_count": 6,
194
+ "metadata": {},
195
+ "outputs": [],
196
+ "source": [
197
+ "#|export\n",
198
+ "learn = load_learner('lamborghini_vs_mercedes_model.pkl')"
199
+ ]
200
+ },
201
+ {
202
+ "cell_type": "code",
203
+ "execution_count": 7,
204
+ "metadata": {},
205
+ "outputs": [],
206
+ "source": [
207
+ "#|export\n",
208
+ "categories = ('lamborghini', 'mercedes')\n",
209
+ "\n",
210
+ "def predict(img):\n",
211
+ " pred, idx, prob = learn.predict(img)\n",
212
+ " return dict(zip(categories, map(float, prob)))"
213
+ ]
214
+ },
215
+ {
216
+ "cell_type": "code",
217
+ "execution_count": 9,
218
+ "metadata": {},
219
+ "outputs": [
220
+ {
221
+ "data": {
222
+ "text/html": [
223
+ "\n",
224
+ "<style>\n",
225
+ " /* Turns off some styling */\n",
226
+ " progress {\n",
227
+ " /* gets rid of default border in Firefox and Opera. */\n",
228
+ " border: none;\n",
229
+ " /* Needs to be in here for Safari polyfill so background images work as expected. */\n",
230
+ " background-size: auto;\n",
231
+ " }\n",
232
+ " progress:not([value]), progress:not([value])::-webkit-progress-bar {\n",
233
+ " background: repeating-linear-gradient(45deg, #7e7e7e, #7e7e7e 10px, #5c5c5c 10px, #5c5c5c 20px);\n",
234
+ " }\n",
235
+ " .progress-bar-interrupted, .progress-bar-interrupted::-webkit-progress-bar {\n",
236
+ " background: #F44336;\n",
237
+ " }\n",
238
+ "</style>\n"
239
+ ],
240
+ "text/plain": [
241
+ "<IPython.core.display.HTML object>"
242
+ ]
243
+ },
244
+ "metadata": {},
245
+ "output_type": "display_data"
246
+ },
247
+ {
248
+ "data": {
249
+ "text/html": [],
250
+ "text/plain": [
251
+ "<IPython.core.display.HTML object>"
252
+ ]
253
+ },
254
+ "metadata": {},
255
+ "output_type": "display_data"
256
+ },
257
+ {
258
+ "data": {
259
+ "text/plain": [
260
+ "{'lamborghini': 1.0, 'mercedes': 6.128332508126277e-09}"
261
+ ]
262
+ },
263
+ "execution_count": 9,
264
+ "metadata": {},
265
+ "output_type": "execute_result"
266
+ }
267
+ ],
268
+ "source": [
269
+ "img = PILImage.create('lambo1.jpg')\n",
270
+ "predict(img)"
271
+ ]
272
+ },
273
+ {
274
+ "cell_type": "code",
275
+ "execution_count": 10,
276
+ "metadata": {},
277
+ "outputs": [
278
+ {
279
+ "name": "stderr",
280
+ "output_type": "stream",
281
+ "text": [
282
+ "/Users/rudra/mambaforge/lib/python3.10/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",
283
+ " warnings.warn(\n",
284
+ "/Users/rudra/mambaforge/lib/python3.10/site-packages/gradio/deprecation.py:40: UserWarning: `optional` parameter is deprecated, and it has no effect\n",
285
+ " warnings.warn(value)\n",
286
+ "/Users/rudra/mambaforge/lib/python3.10/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",
287
+ " warnings.warn(\n",
288
+ "/Users/rudra/mambaforge/lib/python3.10/site-packages/gradio/deprecation.py:40: UserWarning: The 'type' parameter has been deprecated. Use the Number component instead.\n",
289
+ " warnings.warn(value)\n"
290
+ ]
291
+ },
292
+ {
293
+ "name": "stdout",
294
+ "output_type": "stream",
295
+ "text": [
296
+ "Running on local URL: http://127.0.0.1:7861/\n",
297
+ "\n",
298
+ "To create a public link, set `share=True` in `launch()`.\n"
299
+ ]
300
+ },
301
+ {
302
+ "data": {
303
+ "text/plain": [
304
+ "(<gradio.routes.App at 0x154cb0cd0>, 'http://127.0.0.1:7861/', None)"
305
+ ]
306
+ },
307
+ "execution_count": 10,
308
+ "metadata": {},
309
+ "output_type": "execute_result"
310
+ },
311
+ {
312
+ "data": {
313
+ "text/html": [
314
+ "\n",
315
+ "<style>\n",
316
+ " /* Turns off some styling */\n",
317
+ " progress {\n",
318
+ " /* gets rid of default border in Firefox and Opera. */\n",
319
+ " border: none;\n",
320
+ " /* Needs to be in here for Safari polyfill so background images work as expected. */\n",
321
+ " background-size: auto;\n",
322
+ " }\n",
323
+ " progress:not([value]), progress:not([value])::-webkit-progress-bar {\n",
324
+ " background: repeating-linear-gradient(45deg, #7e7e7e, #7e7e7e 10px, #5c5c5c 10px, #5c5c5c 20px);\n",
325
+ " }\n",
326
+ " .progress-bar-interrupted, .progress-bar-interrupted::-webkit-progress-bar {\n",
327
+ " background: #F44336;\n",
328
+ " }\n",
329
+ "</style>\n"
330
+ ],
331
+ "text/plain": [
332
+ "<IPython.core.display.HTML object>"
333
+ ]
334
+ },
335
+ "metadata": {},
336
+ "output_type": "display_data"
337
+ },
338
+ {
339
+ "data": {
340
+ "text/html": [],
341
+ "text/plain": [
342
+ "<IPython.core.display.HTML object>"
343
+ ]
344
+ },
345
+ "metadata": {},
346
+ "output_type": "display_data"
347
+ },
348
+ {
349
+ "data": {
350
+ "text/html": [
351
+ "\n",
352
+ "<style>\n",
353
+ " /* Turns off some styling */\n",
354
+ " progress {\n",
355
+ " /* gets rid of default border in Firefox and Opera. */\n",
356
+ " border: none;\n",
357
+ " /* Needs to be in here for Safari polyfill so background images work as expected. */\n",
358
+ " background-size: auto;\n",
359
+ " }\n",
360
+ " progress:not([value]), progress:not([value])::-webkit-progress-bar {\n",
361
+ " background: repeating-linear-gradient(45deg, #7e7e7e, #7e7e7e 10px, #5c5c5c 10px, #5c5c5c 20px);\n",
362
+ " }\n",
363
+ " .progress-bar-interrupted, .progress-bar-interrupted::-webkit-progress-bar {\n",
364
+ " background: #F44336;\n",
365
+ " }\n",
366
+ "</style>\n"
367
+ ],
368
+ "text/plain": [
369
+ "<IPython.core.display.HTML object>"
370
+ ]
371
+ },
372
+ "metadata": {},
373
+ "output_type": "display_data"
374
+ },
375
+ {
376
+ "data": {
377
+ "text/html": [],
378
+ "text/plain": [
379
+ "<IPython.core.display.HTML object>"
380
+ ]
381
+ },
382
+ "metadata": {},
383
+ "output_type": "display_data"
384
+ }
385
+ ],
386
+ "source": [
387
+ "#|export\n",
388
+ "image = gr.inputs.Image(shape=(192,192))\n",
389
+ "label = gr.outputs.Label()\n",
390
+ "\n",
391
+ "interface = gr.Interface(fn=predict, inputs=image, outputs=label, examples=['lambo1.jpg', 'mercedes1.jpg'])\n",
392
+ "interface.launch(inline=False)"
393
+ ]
394
+ },
395
+ {
396
+ "cell_type": "markdown",
397
+ "metadata": {},
398
+ "source": [
399
+ "# Export"
400
+ ]
401
+ },
402
+ {
403
+ "cell_type": "code",
404
+ "execution_count": 20,
405
+ "metadata": {},
406
+ "outputs": [],
407
+ "source": [
408
+ "from nbdev.export import nb_export\n",
409
+ "nb_export('app.ipynb', '.')"
410
+ ]
411
+ },
412
+ {
413
+ "cell_type": "code",
414
+ "execution_count": null,
415
+ "metadata": {},
416
+ "outputs": [],
417
+ "source": []
418
+ }
419
+ ],
420
+ "metadata": {
421
+ "interpreter": {
422
+ "hash": "a03200ae361ba04b33dfbb7697ae27a1e19c2e9be6094bfaf79232177e8f3033"
423
+ },
424
+ "kernelspec": {
425
+ "display_name": "Python 3 (ipykernel)",
426
+ "language": "python",
427
+ "name": "python3"
428
+ },
429
+ "language_info": {
430
+ "codemirror_mode": {
431
+ "name": "ipython",
432
+ "version": 3
433
+ },
434
+ "file_extension": ".py",
435
+ "mimetype": "text/x-python",
436
+ "name": "python",
437
+ "nbconvert_exporter": "python",
438
+ "pygments_lexer": "ipython3",
439
+ "version": "3.10.6"
440
+ }
441
+ },
442
+ "nbformat": 4,
443
+ "nbformat_minor": 2
444
+ }
lambo2.jpg ADDED
requirements.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ fastai
2
+ scikit-image