UCMe commited on
Commit
4ab02c1
·
1 Parent(s): 2e40e03

Upload folder using huggingface_hub

Browse files
Files changed (6) hide show
  1. .ipynb_checkpoints/deploy-checkpoint.ipynb +191 -0
  2. README.md +2 -8
  3. app.py +11 -0
  4. deploy.ipynb +191 -0
  5. mode.pkl +3 -0
  6. requirements.txt +1 -0
.ipynb_checkpoints/deploy-checkpoint.ipynb ADDED
@@ -0,0 +1,191 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "code",
5
+ "execution_count": 1,
6
+ "id": "f7574cf0",
7
+ "metadata": {},
8
+ "outputs": [],
9
+ "source": [
10
+ "from fastcore.all import *"
11
+ ]
12
+ },
13
+ {
14
+ "cell_type": "code",
15
+ "execution_count": 2,
16
+ "id": "70c6d38b",
17
+ "metadata": {},
18
+ "outputs": [],
19
+ "source": [
20
+ "from fastai.vision.all import *"
21
+ ]
22
+ },
23
+ {
24
+ "cell_type": "code",
25
+ "execution_count": 7,
26
+ "id": "e6cf2649",
27
+ "metadata": {},
28
+ "outputs": [],
29
+ "source": [
30
+ "learn = load_learner('mode.pkl')"
31
+ ]
32
+ },
33
+ {
34
+ "cell_type": "code",
35
+ "execution_count": 8,
36
+ "id": "31dd1521",
37
+ "metadata": {},
38
+ "outputs": [],
39
+ "source": [
40
+ "labels = learn.dls.vocab"
41
+ ]
42
+ },
43
+ {
44
+ "cell_type": "code",
45
+ "execution_count": 9,
46
+ "id": "6cb8e202",
47
+ "metadata": {},
48
+ "outputs": [],
49
+ "source": [
50
+ "def predict(img) :\n",
51
+ " pred,id,probs = learn.predict(PILImage.create(img))\n",
52
+ " return {labels[i] : float(probs[i]) for i in range(len(labels)) }"
53
+ ]
54
+ },
55
+ {
56
+ "cell_type": "code",
57
+ "execution_count": 10,
58
+ "id": "ad1e5548",
59
+ "metadata": {},
60
+ "outputs": [],
61
+ "source": [
62
+ "from gradio.components import Image , Label"
63
+ ]
64
+ },
65
+ {
66
+ "cell_type": "code",
67
+ "execution_count": 11,
68
+ "id": "675ef28b",
69
+ "metadata": {},
70
+ "outputs": [],
71
+ "source": [
72
+ "import gradio as gr"
73
+ ]
74
+ },
75
+ {
76
+ "cell_type": "code",
77
+ "execution_count": 12,
78
+ "id": "fa536164",
79
+ "metadata": {},
80
+ "outputs": [
81
+ {
82
+ "name": "stdout",
83
+ "output_type": "stream",
84
+ "text": [
85
+ "Running on local URL: http://127.0.0.1:7866\n",
86
+ "Running on public URL: https://fc407041673570426e.gradio.live\n",
87
+ "\n",
88
+ "This share link expires in 72 hours. For free permanent hosting and GPU upgrades, run `gradio deploy` from Terminal to deploy to Spaces (https://huggingface.co/spaces)\n"
89
+ ]
90
+ },
91
+ {
92
+ "data": {
93
+ "text/html": [
94
+ "<div><iframe src=\"https://fc407041673570426e.gradio.live\" width=\"100%\" height=\"500\" allow=\"autoplay; camera; microphone; clipboard-read; clipboard-write;\" frameborder=\"0\" allowfullscreen></iframe></div>"
95
+ ],
96
+ "text/plain": [
97
+ "<IPython.core.display.HTML object>"
98
+ ]
99
+ },
100
+ "metadata": {},
101
+ "output_type": "display_data"
102
+ },
103
+ {
104
+ "data": {
105
+ "text/plain": []
106
+ },
107
+ "execution_count": 12,
108
+ "metadata": {},
109
+ "output_type": "execute_result"
110
+ },
111
+ {
112
+ "name": "stderr",
113
+ "output_type": "stream",
114
+ "text": [
115
+ "C:\\Users\\akshi\\anaconda3\\Lib\\site-packages\\fastai\\torch_core.py:263: UserWarning: 'has_mps' is deprecated, please use 'torch.backends.mps.is_built()'\n",
116
+ " return getattr(torch, 'has_mps', False)\n"
117
+ ]
118
+ },
119
+ {
120
+ "data": {
121
+ "text/html": [
122
+ "\n",
123
+ "<style>\n",
124
+ " /* Turns off some styling */\n",
125
+ " progress {\n",
126
+ " /* gets rid of default border in Firefox and Opera. */\n",
127
+ " border: none;\n",
128
+ " /* Needs to be in here for Safari polyfill so background images work as expected. */\n",
129
+ " background-size: auto;\n",
130
+ " }\n",
131
+ " progress:not([value]), progress:not([value])::-webkit-progress-bar {\n",
132
+ " background: repeating-linear-gradient(45deg, #7e7e7e, #7e7e7e 10px, #5c5c5c 10px, #5c5c5c 20px);\n",
133
+ " }\n",
134
+ " .progress-bar-interrupted, .progress-bar-interrupted::-webkit-progress-bar {\n",
135
+ " background: #F44336;\n",
136
+ " }\n",
137
+ "</style>\n"
138
+ ],
139
+ "text/plain": [
140
+ "<IPython.core.display.HTML object>"
141
+ ]
142
+ },
143
+ "metadata": {},
144
+ "output_type": "display_data"
145
+ },
146
+ {
147
+ "data": {
148
+ "text/html": [],
149
+ "text/plain": [
150
+ "<IPython.core.display.HTML object>"
151
+ ]
152
+ },
153
+ "metadata": {},
154
+ "output_type": "display_data"
155
+ }
156
+ ],
157
+ "source": [
158
+ "gr.Interface(fn=predict , inputs=Image(), outputs=Label(num_top_classes=2)).launch(share=True)"
159
+ ]
160
+ },
161
+ {
162
+ "cell_type": "code",
163
+ "execution_count": null,
164
+ "id": "c8797535",
165
+ "metadata": {},
166
+ "outputs": [],
167
+ "source": []
168
+ }
169
+ ],
170
+ "metadata": {
171
+ "kernelspec": {
172
+ "display_name": "Python 3 (ipykernel)",
173
+ "language": "python",
174
+ "name": "python3"
175
+ },
176
+ "language_info": {
177
+ "codemirror_mode": {
178
+ "name": "ipython",
179
+ "version": 3
180
+ },
181
+ "file_extension": ".py",
182
+ "mimetype": "text/x-python",
183
+ "name": "python",
184
+ "nbconvert_exporter": "python",
185
+ "pygments_lexer": "ipython3",
186
+ "version": "3.11.4"
187
+ }
188
+ },
189
+ "nbformat": 4,
190
+ "nbformat_minor": 5
191
+ }
README.md CHANGED
@@ -1,12 +1,6 @@
1
  ---
2
- title: Thesis Thin Film Defects
3
- emoji: 🔥
4
- colorFrom: purple
5
- colorTo: gray
6
  sdk: gradio
7
  sdk_version: 4.13.0
8
- app_file: app.py
9
- pinned: false
10
  ---
11
-
12
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
1
  ---
2
+ title: Thesis_Thin_Film_Defects
3
+ app_file: app.py
 
 
4
  sdk: gradio
5
  sdk_version: 4.13.0
 
 
6
  ---
 
 
app.py ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from fastcore.all import *
2
+ from fastai.vision.all import *
3
+ learn = load_learner('mode.pkl')
4
+ labels = learn.dls.vocab
5
+ def predict(img) :
6
+ pred,id,probs = learn.predict(PILImage.create(img))
7
+ return {labels[i] : float(probs[i]) for i in range(len(labels)) }
8
+
9
+ import gradio as gr
10
+ from gradio.components import Image , Label
11
+ gr.Interface(fn=predict , inputs=Image(), outputs=Label(num_top_classes=2)).launch(share=True)
deploy.ipynb ADDED
@@ -0,0 +1,191 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "code",
5
+ "execution_count": 1,
6
+ "id": "f7574cf0",
7
+ "metadata": {},
8
+ "outputs": [],
9
+ "source": [
10
+ "from fastcore.all import *"
11
+ ]
12
+ },
13
+ {
14
+ "cell_type": "code",
15
+ "execution_count": 2,
16
+ "id": "70c6d38b",
17
+ "metadata": {},
18
+ "outputs": [],
19
+ "source": [
20
+ "from fastai.vision.all import *"
21
+ ]
22
+ },
23
+ {
24
+ "cell_type": "code",
25
+ "execution_count": 7,
26
+ "id": "e6cf2649",
27
+ "metadata": {},
28
+ "outputs": [],
29
+ "source": [
30
+ "learn = load_learner('mode.pkl')"
31
+ ]
32
+ },
33
+ {
34
+ "cell_type": "code",
35
+ "execution_count": 8,
36
+ "id": "31dd1521",
37
+ "metadata": {},
38
+ "outputs": [],
39
+ "source": [
40
+ "labels = learn.dls.vocab"
41
+ ]
42
+ },
43
+ {
44
+ "cell_type": "code",
45
+ "execution_count": 9,
46
+ "id": "6cb8e202",
47
+ "metadata": {},
48
+ "outputs": [],
49
+ "source": [
50
+ "def predict(img) :\n",
51
+ " pred,id,probs = learn.predict(PILImage.create(img))\n",
52
+ " return {labels[i] : float(probs[i]) for i in range(len(labels)) }"
53
+ ]
54
+ },
55
+ {
56
+ "cell_type": "code",
57
+ "execution_count": 10,
58
+ "id": "ad1e5548",
59
+ "metadata": {},
60
+ "outputs": [],
61
+ "source": [
62
+ "from gradio.components import Image , Label"
63
+ ]
64
+ },
65
+ {
66
+ "cell_type": "code",
67
+ "execution_count": 11,
68
+ "id": "675ef28b",
69
+ "metadata": {},
70
+ "outputs": [],
71
+ "source": [
72
+ "import gradio as gr"
73
+ ]
74
+ },
75
+ {
76
+ "cell_type": "code",
77
+ "execution_count": 12,
78
+ "id": "fa536164",
79
+ "metadata": {},
80
+ "outputs": [
81
+ {
82
+ "name": "stdout",
83
+ "output_type": "stream",
84
+ "text": [
85
+ "Running on local URL: http://127.0.0.1:7866\n",
86
+ "Running on public URL: https://fc407041673570426e.gradio.live\n",
87
+ "\n",
88
+ "This share link expires in 72 hours. For free permanent hosting and GPU upgrades, run `gradio deploy` from Terminal to deploy to Spaces (https://huggingface.co/spaces)\n"
89
+ ]
90
+ },
91
+ {
92
+ "data": {
93
+ "text/html": [
94
+ "<div><iframe src=\"https://fc407041673570426e.gradio.live\" width=\"100%\" height=\"500\" allow=\"autoplay; camera; microphone; clipboard-read; clipboard-write;\" frameborder=\"0\" allowfullscreen></iframe></div>"
95
+ ],
96
+ "text/plain": [
97
+ "<IPython.core.display.HTML object>"
98
+ ]
99
+ },
100
+ "metadata": {},
101
+ "output_type": "display_data"
102
+ },
103
+ {
104
+ "data": {
105
+ "text/plain": []
106
+ },
107
+ "execution_count": 12,
108
+ "metadata": {},
109
+ "output_type": "execute_result"
110
+ },
111
+ {
112
+ "name": "stderr",
113
+ "output_type": "stream",
114
+ "text": [
115
+ "C:\\Users\\akshi\\anaconda3\\Lib\\site-packages\\fastai\\torch_core.py:263: UserWarning: 'has_mps' is deprecated, please use 'torch.backends.mps.is_built()'\n",
116
+ " return getattr(torch, 'has_mps', False)\n"
117
+ ]
118
+ },
119
+ {
120
+ "data": {
121
+ "text/html": [
122
+ "\n",
123
+ "<style>\n",
124
+ " /* Turns off some styling */\n",
125
+ " progress {\n",
126
+ " /* gets rid of default border in Firefox and Opera. */\n",
127
+ " border: none;\n",
128
+ " /* Needs to be in here for Safari polyfill so background images work as expected. */\n",
129
+ " background-size: auto;\n",
130
+ " }\n",
131
+ " progress:not([value]), progress:not([value])::-webkit-progress-bar {\n",
132
+ " background: repeating-linear-gradient(45deg, #7e7e7e, #7e7e7e 10px, #5c5c5c 10px, #5c5c5c 20px);\n",
133
+ " }\n",
134
+ " .progress-bar-interrupted, .progress-bar-interrupted::-webkit-progress-bar {\n",
135
+ " background: #F44336;\n",
136
+ " }\n",
137
+ "</style>\n"
138
+ ],
139
+ "text/plain": [
140
+ "<IPython.core.display.HTML object>"
141
+ ]
142
+ },
143
+ "metadata": {},
144
+ "output_type": "display_data"
145
+ },
146
+ {
147
+ "data": {
148
+ "text/html": [],
149
+ "text/plain": [
150
+ "<IPython.core.display.HTML object>"
151
+ ]
152
+ },
153
+ "metadata": {},
154
+ "output_type": "display_data"
155
+ }
156
+ ],
157
+ "source": [
158
+ "gr.Interface(fn=predict , inputs=Image(), outputs=Label(num_top_classes=2)).launch(share=True)"
159
+ ]
160
+ },
161
+ {
162
+ "cell_type": "code",
163
+ "execution_count": null,
164
+ "id": "c8797535",
165
+ "metadata": {},
166
+ "outputs": [],
167
+ "source": []
168
+ }
169
+ ],
170
+ "metadata": {
171
+ "kernelspec": {
172
+ "display_name": "Python 3 (ipykernel)",
173
+ "language": "python",
174
+ "name": "python3"
175
+ },
176
+ "language_info": {
177
+ "codemirror_mode": {
178
+ "name": "ipython",
179
+ "version": 3
180
+ },
181
+ "file_extension": ".py",
182
+ "mimetype": "text/x-python",
183
+ "name": "python",
184
+ "nbconvert_exporter": "python",
185
+ "pygments_lexer": "ipython3",
186
+ "version": "3.11.4"
187
+ }
188
+ },
189
+ "nbformat": 4,
190
+ "nbformat_minor": 5
191
+ }
mode.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:28e51be2a880a41155b3d4066b48761633d7ac593e95bcc79e72d40ed9a0a02c
3
+ size 47216303
requirements.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ fastai