Spaces:
Sleeping
Sleeping
Muhammad Shoaib Shafiq
commited on
Commit
·
9700ba1
1
Parent(s):
30823e5
let's deploy to huggingface spaces
Browse files- .ipynb_checkpoints/app-checkpoint.ipynb +6 -0
- .ipynb_checkpoints/cloudy-checkpoint.jpg +0 -0
- .ipynb_checkpoints/rain-checkpoint.jpg +0 -0
- app.ipynb +232 -0
- app.py +11 -4
- cloudy.jpg +0 -0
- flagged/img/021e165a0faf70b4ed47/sunrise11.jpg +0 -0
- flagged/log.csv +2 -0
- model.pkl +3 -0
- model.pkl:Zone.Identifier +3 -0
- rain.jpg +0 -0
- shine.jpg +0 -0
- sunrise.jpg +0 -0
.ipynb_checkpoints/app-checkpoint.ipynb
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"cells": [],
|
3 |
+
"metadata": {},
|
4 |
+
"nbformat": 4,
|
5 |
+
"nbformat_minor": 5
|
6 |
+
}
|
.ipynb_checkpoints/cloudy-checkpoint.jpg
ADDED
![]() |
.ipynb_checkpoints/rain-checkpoint.jpg
ADDED
![]() |
app.ipynb
ADDED
@@ -0,0 +1,232 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"cells": [
|
3 |
+
{
|
4 |
+
"cell_type": "code",
|
5 |
+
"execution_count": null,
|
6 |
+
"id": "c483e658-eca5-48e4-ae77-d59403453d12",
|
7 |
+
"metadata": {},
|
8 |
+
"outputs": [],
|
9 |
+
"source": [
|
10 |
+
"#|default_exp app"
|
11 |
+
]
|
12 |
+
},
|
13 |
+
{
|
14 |
+
"cell_type": "code",
|
15 |
+
"execution_count": 2,
|
16 |
+
"id": "9ffc7d71-f919-4a81-9ba0-46edbe0c1f99",
|
17 |
+
"metadata": {},
|
18 |
+
"outputs": [],
|
19 |
+
"source": [
|
20 |
+
"#|export\n",
|
21 |
+
"\n",
|
22 |
+
"from fastai.vision.all import *\n",
|
23 |
+
"import gradio as gr"
|
24 |
+
]
|
25 |
+
},
|
26 |
+
{
|
27 |
+
"cell_type": "code",
|
28 |
+
"execution_count": 3,
|
29 |
+
"id": "06a2e43c-5935-45c7-aee1-bbe8594aff01",
|
30 |
+
"metadata": {},
|
31 |
+
"outputs": [],
|
32 |
+
"source": [
|
33 |
+
"#|export\n",
|
34 |
+
"learn = load_learner('model.pkl')"
|
35 |
+
]
|
36 |
+
},
|
37 |
+
{
|
38 |
+
"cell_type": "code",
|
39 |
+
"execution_count": 4,
|
40 |
+
"id": "b43a8038-20d4-41c1-b9c9-c05b35f2a491",
|
41 |
+
"metadata": {},
|
42 |
+
"outputs": [],
|
43 |
+
"source": [
|
44 |
+
"#|export\n",
|
45 |
+
"categories = ('Cloudy','Rain','Shine Or Partly Cloudy','Sunrise') \n",
|
46 |
+
"def classify_image(img):\n",
|
47 |
+
" pred,idx,probs = learn.predict(img)\n",
|
48 |
+
" return dict(zip(categories,map(float,probs)))"
|
49 |
+
]
|
50 |
+
},
|
51 |
+
{
|
52 |
+
"cell_type": "code",
|
53 |
+
"execution_count": 6,
|
54 |
+
"id": "49d4264f-ae56-4ac0-b0a4-a876385f5ee2",
|
55 |
+
"metadata": {},
|
56 |
+
"outputs": [
|
57 |
+
{
|
58 |
+
"data": {
|
59 |
+
"text/html": [
|
60 |
+
"\n",
|
61 |
+
"<style>\n",
|
62 |
+
" /* Turns off some styling */\n",
|
63 |
+
" progress {\n",
|
64 |
+
" /* gets rid of default border in Firefox and Opera. */\n",
|
65 |
+
" border: none;\n",
|
66 |
+
" /* Needs to be in here for Safari polyfill so background images work as expected. */\n",
|
67 |
+
" background-size: auto;\n",
|
68 |
+
" }\n",
|
69 |
+
" progress:not([value]), progress:not([value])::-webkit-progress-bar {\n",
|
70 |
+
" background: repeating-linear-gradient(45deg, #7e7e7e, #7e7e7e 10px, #5c5c5c 10px, #5c5c5c 20px);\n",
|
71 |
+
" }\n",
|
72 |
+
" .progress-bar-interrupted, .progress-bar-interrupted::-webkit-progress-bar {\n",
|
73 |
+
" background: #F44336;\n",
|
74 |
+
" }\n",
|
75 |
+
"</style>\n"
|
76 |
+
],
|
77 |
+
"text/plain": [
|
78 |
+
"<IPython.core.display.HTML object>"
|
79 |
+
]
|
80 |
+
},
|
81 |
+
"metadata": {},
|
82 |
+
"output_type": "display_data"
|
83 |
+
},
|
84 |
+
{
|
85 |
+
"data": {
|
86 |
+
"text/html": [],
|
87 |
+
"text/plain": [
|
88 |
+
"<IPython.core.display.HTML object>"
|
89 |
+
]
|
90 |
+
},
|
91 |
+
"metadata": {},
|
92 |
+
"output_type": "display_data"
|
93 |
+
},
|
94 |
+
{
|
95 |
+
"data": {
|
96 |
+
"text/plain": [
|
97 |
+
"('Rain', tensor(1), tensor([7.6823e-04, 9.9922e-01, 1.0592e-05, 4.4878e-08]))"
|
98 |
+
]
|
99 |
+
},
|
100 |
+
"execution_count": 6,
|
101 |
+
"metadata": {},
|
102 |
+
"output_type": "execute_result"
|
103 |
+
}
|
104 |
+
],
|
105 |
+
"source": [
|
106 |
+
"learn.predict('rain.jpg')"
|
107 |
+
]
|
108 |
+
},
|
109 |
+
{
|
110 |
+
"cell_type": "code",
|
111 |
+
"execution_count": 7,
|
112 |
+
"id": "a8794806-a335-4331-978a-2d8ba3ba8bff",
|
113 |
+
"metadata": {},
|
114 |
+
"outputs": [
|
115 |
+
{
|
116 |
+
"name": "stdout",
|
117 |
+
"output_type": "stream",
|
118 |
+
"text": [
|
119 |
+
"Running on local URL: http://127.0.0.1:7860\n",
|
120 |
+
"\n",
|
121 |
+
"To create a public link, set `share=True` in `launch()`.\n"
|
122 |
+
]
|
123 |
+
},
|
124 |
+
{
|
125 |
+
"data": {
|
126 |
+
"text/plain": []
|
127 |
+
},
|
128 |
+
"execution_count": 7,
|
129 |
+
"metadata": {},
|
130 |
+
"output_type": "execute_result"
|
131 |
+
},
|
132 |
+
{
|
133 |
+
"data": {
|
134 |
+
"text/html": [
|
135 |
+
"\n",
|
136 |
+
"<style>\n",
|
137 |
+
" /* Turns off some styling */\n",
|
138 |
+
" progress {\n",
|
139 |
+
" /* gets rid of default border in Firefox and Opera. */\n",
|
140 |
+
" border: none;\n",
|
141 |
+
" /* Needs to be in here for Safari polyfill so background images work as expected. */\n",
|
142 |
+
" background-size: auto;\n",
|
143 |
+
" }\n",
|
144 |
+
" progress:not([value]), progress:not([value])::-webkit-progress-bar {\n",
|
145 |
+
" background: repeating-linear-gradient(45deg, #7e7e7e, #7e7e7e 10px, #5c5c5c 10px, #5c5c5c 20px);\n",
|
146 |
+
" }\n",
|
147 |
+
" .progress-bar-interrupted, .progress-bar-interrupted::-webkit-progress-bar {\n",
|
148 |
+
" background: #F44336;\n",
|
149 |
+
" }\n",
|
150 |
+
"</style>\n"
|
151 |
+
],
|
152 |
+
"text/plain": [
|
153 |
+
"<IPython.core.display.HTML object>"
|
154 |
+
]
|
155 |
+
},
|
156 |
+
"metadata": {},
|
157 |
+
"output_type": "display_data"
|
158 |
+
},
|
159 |
+
{
|
160 |
+
"data": {
|
161 |
+
"text/html": [],
|
162 |
+
"text/plain": [
|
163 |
+
"<IPython.core.display.HTML object>"
|
164 |
+
]
|
165 |
+
},
|
166 |
+
"metadata": {},
|
167 |
+
"output_type": "display_data"
|
168 |
+
}
|
169 |
+
],
|
170 |
+
"source": [
|
171 |
+
"#|export\n",
|
172 |
+
"#image = gr.inputs.Image(shape=(192,192))\n",
|
173 |
+
"#label = gr.outputs.Label()\n",
|
174 |
+
"examples = ['cloudy.jpg','rain.jpg','shine.jpg','sunrise.jpg']\n",
|
175 |
+
"\n",
|
176 |
+
"intf = gr.Interface(fn=classify_image , inputs='image' , outputs = 'label' , examples=examples)\n",
|
177 |
+
"intf.launch(inline=False)"
|
178 |
+
]
|
179 |
+
},
|
180 |
+
{
|
181 |
+
"cell_type": "code",
|
182 |
+
"execution_count": 9,
|
183 |
+
"id": "6f6d0837-0f14-4d58-8ce3-13b7e25376b4",
|
184 |
+
"metadata": {},
|
185 |
+
"outputs": [
|
186 |
+
{
|
187 |
+
"ename": "ImportError",
|
188 |
+
"evalue": "cannot import name 'nbdev_export' from 'nbdev.export' (/home/shoaib/mambaforge/lib/python3.10/site-packages/nbdev/export.py)",
|
189 |
+
"output_type": "error",
|
190 |
+
"traceback": [
|
191 |
+
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
|
192 |
+
"\u001b[0;31mImportError\u001b[0m Traceback (most recent call last)",
|
193 |
+
"Cell \u001b[0;32mIn[9], line 1\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;21;01m.\u001b[39;00m\u001b[38;5;21;01mexport\u001b[39;00m \u001b[38;5;28;01mimport\u001b[39;00m nbdev_export\n",
|
194 |
+
"\u001b[0;31mImportError\u001b[0m: cannot import name 'nbdev_export' from 'nbdev.export' (/home/shoaib/mambaforge/lib/python3.10/site-packages/nbdev/export.py)"
|
195 |
+
]
|
196 |
+
}
|
197 |
+
],
|
198 |
+
"source": [
|
199 |
+
"from nbdev.export import notebook2script"
|
200 |
+
]
|
201 |
+
},
|
202 |
+
{
|
203 |
+
"cell_type": "code",
|
204 |
+
"execution_count": null,
|
205 |
+
"id": "9fa6c39c-a5e5-42e8-a4c3-122d6bdbeef1",
|
206 |
+
"metadata": {},
|
207 |
+
"outputs": [],
|
208 |
+
"source": []
|
209 |
+
}
|
210 |
+
],
|
211 |
+
"metadata": {
|
212 |
+
"kernelspec": {
|
213 |
+
"display_name": "Python 3 (ipykernel)",
|
214 |
+
"language": "python",
|
215 |
+
"name": "python3"
|
216 |
+
},
|
217 |
+
"language_info": {
|
218 |
+
"codemirror_mode": {
|
219 |
+
"name": "ipython",
|
220 |
+
"version": 3
|
221 |
+
},
|
222 |
+
"file_extension": ".py",
|
223 |
+
"mimetype": "text/x-python",
|
224 |
+
"name": "python",
|
225 |
+
"nbconvert_exporter": "python",
|
226 |
+
"pygments_lexer": "ipython3",
|
227 |
+
"version": "3.10.12"
|
228 |
+
}
|
229 |
+
},
|
230 |
+
"nbformat": 4,
|
231 |
+
"nbformat_minor": 5
|
232 |
+
}
|
app.py
CHANGED
@@ -1,7 +1,14 @@
|
|
|
|
1 |
import gradio as gr
|
2 |
|
3 |
-
|
4 |
-
return "Hello " + name + "!!"
|
5 |
|
6 |
-
|
7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from fastai.vision.all import *
|
2 |
import gradio as gr
|
3 |
|
4 |
+
learn = load_learner('model.pkl')
|
|
|
5 |
|
6 |
+
categories = ('Cloudy','Rain','Shine Or Partly Cloudy','Sunrise')
|
7 |
+
def classify_image(img):
|
8 |
+
pred,idx,probs = learn.predict(img)
|
9 |
+
return dict(zip(categories,map(float,probs)))
|
10 |
+
|
11 |
+
examples = ['cloudy.jpg','rain.jpg','shine.jpg','sunrise.jpg']
|
12 |
+
|
13 |
+
intf = gr.Interface(fn=classify_image , inputs='image' , outputs = 'label' , examples=examples)
|
14 |
+
intf.launch(inline=False)
|
cloudy.jpg
ADDED
![]() |
flagged/img/021e165a0faf70b4ed47/sunrise11.jpg
ADDED
![]() |
flagged/log.csv
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
img,output,flag,username,timestamp
|
2 |
+
"{""path"":""flagged/img/021e165a0faf70b4ed47/sunrise11.jpg"",""url"":""http://127.0.0.1:7860/file=/tmp/gradio/18ec15d2d98034992b07009ca7f865faefbea12d/sunrise11.jpg"",""size"":10013,""orig_name"":""sunrise11.jpg"",""mime_type"":""""}","{""label"":null,""confidences"":null}",,,2023-12-14 17:37:19.369506
|
model.pkl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:eab876af2c0c4295460df42ac3899defa86f6fb9ff6ca64d3279fed96cb094c2
|
3 |
+
size 46983550
|
model.pkl:Zone.Identifier
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
[ZoneTransfer]
|
2 |
+
ZoneId=3
|
3 |
+
HostUrl=about:internet
|
rain.jpg
ADDED
![]() |
shine.jpg
ADDED
![]() |
sunrise.jpg
ADDED
![]() |