Upload 509 files
Browse filesThis view is limited to 50 files because it contains too many changes.
See raw diff
- .gitattributes +3 -0
- app.ipynb +229 -0
- pokemon-model_transferlearning.keras +3 -0
- pokemon/train/Dratini/00000000.jpg +0 -0
- pokemon/train/Dratini/00000006.jpg +0 -0
- pokemon/train/Dratini/00000011.jpg +0 -0
- pokemon/train/Dratini/00000015.jpg +0 -0
- pokemon/train/Dratini/00000016.jpg +0 -0
- pokemon/train/Dratini/00000020.jpg +0 -0
- pokemon/train/Dratini/00000023.jpg +0 -0
- pokemon/train/Dratini/00000028.jpg +0 -0
- pokemon/train/Dratini/00000033.jpg +0 -0
- pokemon/train/Dratini/00000044.jpg +0 -0
- pokemon/train/Dratini/00000051.jpg +0 -0
- pokemon/train/Dratini/00000056.jpg +0 -0
- pokemon/train/Dratini/00000060.jpeg +0 -0
- pokemon/train/Dratini/00000065.jpg +0 -0
- pokemon/train/Dratini/00000066.jpg +0 -0
- pokemon/train/Dratini/00000076.jpg +0 -0
- pokemon/train/Dratini/00000094.jpg +0 -0
- pokemon/train/Dratini/00000105.jpg +0 -0
- pokemon/train/Dratini/00000110.jpg +0 -0
- pokemon/train/Dratini/00000115.jpg +0 -0
- pokemon/train/Dratini/00000138.jpg +0 -0
- pokemon/train/Dratini/00000144.jpg +0 -0
- pokemon/train/Dratini/00000145.jpg +0 -0
- pokemon/train/Dratini/00000147.jpg +0 -0
- pokemon/train/Dratini/00000148.jpg +0 -0
- pokemon/train/Dratini/00000151.jpg +0 -0
- pokemon/train/Dratini/00000153.jpg +0 -0
- pokemon/train/Dratini/00000168.jpg +0 -0
- pokemon/train/Dratini/00000172.jpg +0 -0
- pokemon/train/Dratini/00000190.jpg +0 -0
- pokemon/train/Dratini/00000194.jpg +0 -0
- pokemon/train/Dratini/00000195.jpg +0 -0
- pokemon/train/Dratini/00000198.jpg +0 -0
- pokemon/train/Dratini/00000199.jpg +0 -0
- pokemon/train/Dratini/00000205.jpg +0 -0
- pokemon/train/Dratini/00000209.jpg +0 -0
- pokemon/train/Dratini/00000214.jpg +0 -0
- pokemon/train/Dratini/00000216.jpg +0 -0
- pokemon/train/Dratini/00000225.jpg +0 -0
- pokemon/train/Dratini/00000226.jpg +0 -0
- pokemon/train/Dratini/00000231.jpg +0 -0
- pokemon/train/Dratini/08f8168539c54bfa8fb5641842183d5c.jpg +0 -0
- pokemon/train/Dratini/0d664bb18e884eeba0d6190809a8c9c6.jpg +0 -0
- pokemon/train/Dratini/0f1fadb82e564fcd929dadd909d16115.jpg +0 -0
- pokemon/train/Dratini/18fb20e1e5ad4891aff89d3dfc14efe6.jpg +0 -0
- pokemon/train/Dratini/19efc0ebbb4f4633b7a67fb72cf13071.jpg +0 -0
- pokemon/train/Dratini/203afd4980494b8b9638e3e0916a9fd9.jpg +0 -0
.gitattributes
CHANGED
@@ -33,3 +33,6 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
36 |
+
pokemon-model_transferlearning.keras filter=lfs diff=lfs merge=lfs -text
|
37 |
+
pokemon/train/Jolteon/00000036.jpg filter=lfs diff=lfs merge=lfs -text
|
38 |
+
pokemon/val/Jolteon/00000036.jpg filter=lfs diff=lfs merge=lfs -text
|
app.ipynb
ADDED
@@ -0,0 +1,229 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"cells": [
|
3 |
+
{
|
4 |
+
"cell_type": "code",
|
5 |
+
"execution_count": 9,
|
6 |
+
"metadata": {},
|
7 |
+
"outputs": [],
|
8 |
+
"source": [
|
9 |
+
"import gradio as gr\n",
|
10 |
+
"import tensorflow as tf\n",
|
11 |
+
"import numpy as np\n",
|
12 |
+
"from PIL import Image"
|
13 |
+
]
|
14 |
+
},
|
15 |
+
{
|
16 |
+
"cell_type": "code",
|
17 |
+
"execution_count": 17,
|
18 |
+
"metadata": {},
|
19 |
+
"outputs": [],
|
20 |
+
"source": [
|
21 |
+
"# Define the core prediction function\n",
|
22 |
+
"def predict_cat_dog(image):\n",
|
23 |
+
" # Preprocess image\n",
|
24 |
+
" print(type(image))\n",
|
25 |
+
" image = Image.fromarray(image.astype('uint8')) # Convert numpy array to PIL image\n",
|
26 |
+
" image = image.resize((150, 150)) #resize the image to 28x28 and converts it to gray scale\n",
|
27 |
+
" image = np.array(image)\n",
|
28 |
+
" image = np.expand_dims(image, axis=0) # same as image[None, ...]\n",
|
29 |
+
" \n",
|
30 |
+
" # Predict\n",
|
31 |
+
" prediction = model.predict(image)\n",
|
32 |
+
" \n",
|
33 |
+
" # Because the output layer was dense(0) without an activation function, we need to apply sigmoid to get the probability\n",
|
34 |
+
" # we could also change the output layer to dense(1, activation='sigmoid')\n",
|
35 |
+
" prediction = np.round(float(tf.sigmoid(prediction)), 2)\n",
|
36 |
+
" p_jolteon = prediction\n",
|
37 |
+
" p_eevee = (1 - prediction)\n",
|
38 |
+
" p_dratini = (2 - prediction)\n",
|
39 |
+
" return {'jolteon': p_jolteon, 'eevee': p_eevee, 'dratini': p_dratini}"
|
40 |
+
]
|
41 |
+
},
|
42 |
+
{
|
43 |
+
"cell_type": "code",
|
44 |
+
"execution_count": 20,
|
45 |
+
"metadata": {},
|
46 |
+
"outputs": [
|
47 |
+
{
|
48 |
+
"name": "stdout",
|
49 |
+
"output_type": "stream",
|
50 |
+
"text": [
|
51 |
+
"Running on local URL: http://127.0.0.1:7862\n",
|
52 |
+
"\n",
|
53 |
+
"To create a public link, set `share=True` in `launch()`.\n"
|
54 |
+
]
|
55 |
+
},
|
56 |
+
{
|
57 |
+
"data": {
|
58 |
+
"text/html": [
|
59 |
+
"<div><iframe src=\"http://127.0.0.1:7862/\" width=\"100%\" height=\"500\" allow=\"autoplay; camera; microphone; clipboard-read; clipboard-write;\" frameborder=\"0\" allowfullscreen></iframe></div>"
|
60 |
+
],
|
61 |
+
"text/plain": [
|
62 |
+
"<IPython.core.display.HTML object>"
|
63 |
+
]
|
64 |
+
},
|
65 |
+
"metadata": {},
|
66 |
+
"output_type": "display_data"
|
67 |
+
},
|
68 |
+
{
|
69 |
+
"data": {
|
70 |
+
"text/plain": []
|
71 |
+
},
|
72 |
+
"execution_count": 20,
|
73 |
+
"metadata": {},
|
74 |
+
"output_type": "execute_result"
|
75 |
+
},
|
76 |
+
{
|
77 |
+
"name": "stdout",
|
78 |
+
"output_type": "stream",
|
79 |
+
"text": [
|
80 |
+
"<class 'numpy.ndarray'>\n"
|
81 |
+
]
|
82 |
+
},
|
83 |
+
{
|
84 |
+
"name": "stderr",
|
85 |
+
"output_type": "stream",
|
86 |
+
"text": [
|
87 |
+
"Traceback (most recent call last):\n",
|
88 |
+
" File \"c:\\Users\\dom-k\\anaconda3\\envs\\KIA\\lib\\site-packages\\gradio\\queueing.py\", line 527, in process_events\n",
|
89 |
+
" response = await route_utils.call_process_api(\n",
|
90 |
+
" File \"c:\\Users\\dom-k\\anaconda3\\envs\\KIA\\lib\\site-packages\\gradio\\route_utils.py\", line 270, in call_process_api\n",
|
91 |
+
" output = await app.get_blocks().process_api(\n",
|
92 |
+
" File \"c:\\Users\\dom-k\\anaconda3\\envs\\KIA\\lib\\site-packages\\gradio\\blocks.py\", line 1847, in process_api\n",
|
93 |
+
" result = await self.call_function(\n",
|
94 |
+
" File \"c:\\Users\\dom-k\\anaconda3\\envs\\KIA\\lib\\site-packages\\gradio\\blocks.py\", line 1433, in call_function\n",
|
95 |
+
" prediction = await anyio.to_thread.run_sync(\n",
|
96 |
+
" File \"c:\\Users\\dom-k\\anaconda3\\envs\\KIA\\lib\\site-packages\\anyio\\to_thread.py\", line 56, in run_sync\n",
|
97 |
+
" return await get_async_backend().run_sync_in_worker_thread(\n",
|
98 |
+
" File \"c:\\Users\\dom-k\\anaconda3\\envs\\KIA\\lib\\site-packages\\anyio\\_backends\\_asyncio.py\", line 2134, in run_sync_in_worker_thread\n",
|
99 |
+
" return await future\n",
|
100 |
+
" File \"c:\\Users\\dom-k\\anaconda3\\envs\\KIA\\lib\\site-packages\\anyio\\_backends\\_asyncio.py\", line 851, in run\n",
|
101 |
+
" result = context.run(func, *args)\n",
|
102 |
+
" File \"c:\\Users\\dom-k\\anaconda3\\envs\\KIA\\lib\\site-packages\\gradio\\utils.py\", line 805, in wrapper\n",
|
103 |
+
" response = f(*args, **kwargs)\n",
|
104 |
+
" File \"C:\\Users\\dom-k\\AppData\\Local\\Temp\\ipykernel_33600\\3230146116.py\", line 11, in predict_cat_dog\n",
|
105 |
+
" prediction = model.predict(image)\n",
|
106 |
+
"NameError: name 'model' is not defined\n"
|
107 |
+
]
|
108 |
+
}
|
109 |
+
],
|
110 |
+
"source": [
|
111 |
+
"# Create the Gradio interface\n",
|
112 |
+
"input_image = gr.Image()\n",
|
113 |
+
"iface = gr.Interface(\n",
|
114 |
+
" fn=predict_cat_dog,\n",
|
115 |
+
" inputs=input_image, \n",
|
116 |
+
" outputs=gr.Label(),\n",
|
117 |
+
" examples=[\"images_pokemon/Dratini1.png\", \"images_pokemon/Dratini2.png\", \"images_pokemon/Dratini3.png\", \"images_pokemon/Dratini4.png\", \"images_pokemon/Dratini5.png\",\n",
|
118 |
+
" \"images_pokemon/Eevee1.png\", \"images_pokemon/Eevee2.png\", \"images_pokemon/Eevee3.png\", \"images_pokemon/Eevee4.png\", \"images_pokemon/Eevee5.png\",\n",
|
119 |
+
" \"images_pokemon/Jolteon1.png\", \"images_pokemon/Jolteon2.png\", \"images_pokemon/Jolteon3.png\", \"images_pokemon/Jolteon4.png\", \"images_pokemon/Jolteon5.png\"], \n",
|
120 |
+
" description=\"A simple mlp classification model for image classification using the mnist dataset.\")\n",
|
121 |
+
"iface.launch()"
|
122 |
+
]
|
123 |
+
},
|
124 |
+
{
|
125 |
+
"cell_type": "code",
|
126 |
+
"execution_count": 21,
|
127 |
+
"metadata": {},
|
128 |
+
"outputs": [
|
129 |
+
{
|
130 |
+
"name": "stdout",
|
131 |
+
"output_type": "stream",
|
132 |
+
"text": [
|
133 |
+
"Running on local URL: http://127.0.0.1:7863\n",
|
134 |
+
"\n",
|
135 |
+
"To create a public link, set `share=True` in `launch()`.\n"
|
136 |
+
]
|
137 |
+
},
|
138 |
+
{
|
139 |
+
"data": {
|
140 |
+
"text/html": [
|
141 |
+
"<div><iframe src=\"http://127.0.0.1:7863/\" width=\"100%\" height=\"500\" allow=\"autoplay; camera; microphone; clipboard-read; clipboard-write;\" frameborder=\"0\" allowfullscreen></iframe></div>"
|
142 |
+
],
|
143 |
+
"text/plain": [
|
144 |
+
"<IPython.core.display.HTML object>"
|
145 |
+
]
|
146 |
+
},
|
147 |
+
"metadata": {},
|
148 |
+
"output_type": "display_data"
|
149 |
+
},
|
150 |
+
{
|
151 |
+
"data": {
|
152 |
+
"text/plain": []
|
153 |
+
},
|
154 |
+
"execution_count": 21,
|
155 |
+
"metadata": {},
|
156 |
+
"output_type": "execute_result"
|
157 |
+
},
|
158 |
+
{
|
159 |
+
"name": "stdout",
|
160 |
+
"output_type": "stream",
|
161 |
+
"text": [
|
162 |
+
"<class 'numpy.ndarray'>\n"
|
163 |
+
]
|
164 |
+
},
|
165 |
+
{
|
166 |
+
"name": "stderr",
|
167 |
+
"output_type": "stream",
|
168 |
+
"text": [
|
169 |
+
"Traceback (most recent call last):\n",
|
170 |
+
" File \"c:\\Users\\dom-k\\anaconda3\\envs\\KIA\\lib\\site-packages\\gradio\\queueing.py\", line 527, in process_events\n",
|
171 |
+
" response = await route_utils.call_process_api(\n",
|
172 |
+
" File \"c:\\Users\\dom-k\\anaconda3\\envs\\KIA\\lib\\site-packages\\gradio\\route_utils.py\", line 270, in call_process_api\n",
|
173 |
+
" output = await app.get_blocks().process_api(\n",
|
174 |
+
" File \"c:\\Users\\dom-k\\anaconda3\\envs\\KIA\\lib\\site-packages\\gradio\\blocks.py\", line 1847, in process_api\n",
|
175 |
+
" result = await self.call_function(\n",
|
176 |
+
" File \"c:\\Users\\dom-k\\anaconda3\\envs\\KIA\\lib\\site-packages\\gradio\\blocks.py\", line 1433, in call_function\n",
|
177 |
+
" prediction = await anyio.to_thread.run_sync(\n",
|
178 |
+
" File \"c:\\Users\\dom-k\\anaconda3\\envs\\KIA\\lib\\site-packages\\anyio\\to_thread.py\", line 56, in run_sync\n",
|
179 |
+
" return await get_async_backend().run_sync_in_worker_thread(\n",
|
180 |
+
" File \"c:\\Users\\dom-k\\anaconda3\\envs\\KIA\\lib\\site-packages\\anyio\\_backends\\_asyncio.py\", line 2134, in run_sync_in_worker_thread\n",
|
181 |
+
" return await future\n",
|
182 |
+
" File \"c:\\Users\\dom-k\\anaconda3\\envs\\KIA\\lib\\site-packages\\anyio\\_backends\\_asyncio.py\", line 851, in run\n",
|
183 |
+
" result = context.run(func, *args)\n",
|
184 |
+
" File \"c:\\Users\\dom-k\\anaconda3\\envs\\KIA\\lib\\site-packages\\gradio\\utils.py\", line 805, in wrapper\n",
|
185 |
+
" response = f(*args, **kwargs)\n",
|
186 |
+
" File \"C:\\Users\\dom-k\\AppData\\Local\\Temp\\ipykernel_33600\\3230146116.py\", line 11, in predict_cat_dog\n",
|
187 |
+
" prediction = model.predict(image)\n",
|
188 |
+
"NameError: name 'model' is not defined\n"
|
189 |
+
]
|
190 |
+
}
|
191 |
+
],
|
192 |
+
"source": [
|
193 |
+
"import gradio as gr\n",
|
194 |
+
"\n",
|
195 |
+
"def greet(name, intensity):\n",
|
196 |
+
" return \"Hello, \" + name + \"!\" * int(intensity)\n",
|
197 |
+
"\n",
|
198 |
+
"demo = gr.Interface(\n",
|
199 |
+
" fn=greet,\n",
|
200 |
+
" inputs=[\"text\", \"slider\"],\n",
|
201 |
+
" outputs=[\"text\"],\n",
|
202 |
+
")\n",
|
203 |
+
"\n",
|
204 |
+
"demo.launch()\n"
|
205 |
+
]
|
206 |
+
}
|
207 |
+
],
|
208 |
+
"metadata": {
|
209 |
+
"kernelspec": {
|
210 |
+
"display_name": "venv_new",
|
211 |
+
"language": "python",
|
212 |
+
"name": "python3"
|
213 |
+
},
|
214 |
+
"language_info": {
|
215 |
+
"codemirror_mode": {
|
216 |
+
"name": "ipython",
|
217 |
+
"version": 3
|
218 |
+
},
|
219 |
+
"file_extension": ".py",
|
220 |
+
"mimetype": "text/x-python",
|
221 |
+
"name": "python",
|
222 |
+
"nbconvert_exporter": "python",
|
223 |
+
"pygments_lexer": "ipython3",
|
224 |
+
"version": "3.10.14"
|
225 |
+
}
|
226 |
+
},
|
227 |
+
"nbformat": 4,
|
228 |
+
"nbformat_minor": 2
|
229 |
+
}
|
pokemon-model_transferlearning.keras
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:c4db26ce9bd748b77178d57bdc74acbd4e39e4e14f5a7e54a13caf0ba5953619
|
3 |
+
size 250560147
|
pokemon/train/Dratini/00000000.jpg
ADDED
pokemon/train/Dratini/00000006.jpg
ADDED
pokemon/train/Dratini/00000011.jpg
ADDED
pokemon/train/Dratini/00000015.jpg
ADDED
pokemon/train/Dratini/00000016.jpg
ADDED
pokemon/train/Dratini/00000020.jpg
ADDED
pokemon/train/Dratini/00000023.jpg
ADDED
pokemon/train/Dratini/00000028.jpg
ADDED
pokemon/train/Dratini/00000033.jpg
ADDED
pokemon/train/Dratini/00000044.jpg
ADDED
pokemon/train/Dratini/00000051.jpg
ADDED
pokemon/train/Dratini/00000056.jpg
ADDED
pokemon/train/Dratini/00000060.jpeg
ADDED
pokemon/train/Dratini/00000065.jpg
ADDED
pokemon/train/Dratini/00000066.jpg
ADDED
pokemon/train/Dratini/00000076.jpg
ADDED
pokemon/train/Dratini/00000094.jpg
ADDED
pokemon/train/Dratini/00000105.jpg
ADDED
pokemon/train/Dratini/00000110.jpg
ADDED
pokemon/train/Dratini/00000115.jpg
ADDED
pokemon/train/Dratini/00000138.jpg
ADDED
pokemon/train/Dratini/00000144.jpg
ADDED
pokemon/train/Dratini/00000145.jpg
ADDED
pokemon/train/Dratini/00000147.jpg
ADDED
pokemon/train/Dratini/00000148.jpg
ADDED
pokemon/train/Dratini/00000151.jpg
ADDED
pokemon/train/Dratini/00000153.jpg
ADDED
pokemon/train/Dratini/00000168.jpg
ADDED
pokemon/train/Dratini/00000172.jpg
ADDED
pokemon/train/Dratini/00000190.jpg
ADDED
pokemon/train/Dratini/00000194.jpg
ADDED
pokemon/train/Dratini/00000195.jpg
ADDED
pokemon/train/Dratini/00000198.jpg
ADDED
pokemon/train/Dratini/00000199.jpg
ADDED
pokemon/train/Dratini/00000205.jpg
ADDED
pokemon/train/Dratini/00000209.jpg
ADDED
pokemon/train/Dratini/00000214.jpg
ADDED
pokemon/train/Dratini/00000216.jpg
ADDED
pokemon/train/Dratini/00000225.jpg
ADDED
pokemon/train/Dratini/00000226.jpg
ADDED
pokemon/train/Dratini/00000231.jpg
ADDED
pokemon/train/Dratini/08f8168539c54bfa8fb5641842183d5c.jpg
ADDED
pokemon/train/Dratini/0d664bb18e884eeba0d6190809a8c9c6.jpg
ADDED
pokemon/train/Dratini/0f1fadb82e564fcd929dadd909d16115.jpg
ADDED
pokemon/train/Dratini/18fb20e1e5ad4891aff89d3dfc14efe6.jpg
ADDED
pokemon/train/Dratini/19efc0ebbb4f4633b7a67fb72cf13071.jpg
ADDED
pokemon/train/Dratini/203afd4980494b8b9638e3e0916a9fd9.jpg
ADDED