Nishant Aswani commited on
Commit
49ea899
1 Parent(s): 0537064

First attempt

Browse files
Files changed (5) hide show
  1. .devcontainer/devcontainer.json +46 -0
  2. Dockerfile +4 -2
  3. app.py +253 -86
  4. classes.txt +1000 -0
  5. requirements.txt +6 -2
.devcontainer/devcontainer.json ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // For format details, see https://aka.ms/devcontainer.json. For config options, see the
2
+ // README at: https://github.com/devcontainers/templates/tree/main/src/python
3
+ {
4
+ "name": "Python 3",
5
+ // Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
6
+ "build": {
7
+ "context": "..",
8
+ // Path is relative to the devcontainer.json file.
9
+ "dockerfile": "../Dockerfile"
10
+ },
11
+ "runArgs": [
12
+ // "--gpus",
13
+ // "all",
14
+ "--network=host",
15
+ "--ipc=host",
16
+ "--ulimit",
17
+ "memlock=-1",
18
+ "--ulimit",
19
+ "stack=67108864"
20
+ ],
21
+ // "mounts": [ // Add this if you need to mount your project directory
22
+ // "source=/mnt,target=/mnt,type=bind",
23
+ // "source=${localEnv:HOME}/datasets/,target=/root/datasets,type=bind",
24
+ // "source=${localWorkspaceFolder},target=/app,type=bind"
25
+ // ],
26
+ "customizations": {
27
+ "vscode": {
28
+ "extensions": [
29
+ "shiro.pythonpack",
30
+ "charliermarsh.ruff"
31
+ ]
32
+ }
33
+ }
34
+ // Use 'forwardPorts' to make a list of ports inside the container available locally.
35
+ // "forwardPorts": [
36
+ // 8080
37
+ // ]
38
+ // Features to add to the dev container. More info: https://containers.dev/features.
39
+ // "features": {},
40
+ // Use 'postCreateCommand' to run commands after the container is created.
41
+ // "postCreateCommand": "pip3 install --user -r requirements.txt",
42
+ // Configure tool-specific properties.
43
+ // "customizations": {},
44
+ // Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
45
+ // "remoteUser": "root"
46
+ }
Dockerfile CHANGED
@@ -1,14 +1,16 @@
1
  FROM python:3.11
2
 
 
 
3
  WORKDIR /code
4
 
5
  COPY ./requirements.txt /code/requirements.txt
6
  RUN python3 -m pip install --no-cache-dir --upgrade pip
7
- RUN python3 -m pip install --no-cache-dir --upgrade -r /code/requirements.txt
8
 
9
  COPY . .
10
 
11
- CMD ["panel", "serve", "/code/app.py", "--address", "0.0.0.0", "--port", "7860", "--allow-websocket-origin", "*"]
12
 
13
  RUN mkdir /.cache
14
  RUN chmod 777 /.cache
 
1
  FROM python:3.11
2
 
3
+ ENV PIP_PROGRESS_BAR=on
4
+
5
  WORKDIR /code
6
 
7
  COPY ./requirements.txt /code/requirements.txt
8
  RUN python3 -m pip install --no-cache-dir --upgrade pip
9
+ # RUN python3 -m pip install --no-cache-dir --upgrade -r /code/requirements.txt
10
 
11
  COPY . .
12
 
13
+ # CMD ["panel", "serve", "/code/app.py", "--address", "0.0.0.0", "--port", "7860", "--allow-websocket-origin", "*"]
14
 
15
  RUN mkdir /.cache
16
  RUN chmod 777 /.cache
app.py CHANGED
@@ -1,147 +1,314 @@
1
  import io
2
  import random
 
3
  from typing import List, Tuple
4
 
5
  import aiohttp
6
  import panel as pn
7
- from PIL import Image
8
- from transformers import CLIPModel, CLIPProcessor
9
-
10
- pn.extension(design="bootstrap", sizing_mode="stretch_width")
11
 
12
- ICON_URLS = {
13
- "brand-github": "https://github.com/holoviz/panel",
14
- "brand-twitter": "https://twitter.com/Panel_Org",
15
- "brand-linkedin": "https://www.linkedin.com/company/panel-org",
16
- "message-circle": "https://discourse.holoviz.org/",
17
- "brand-discord": "https://discord.gg/AXRHnJU6sP",
18
- }
19
 
 
20
 
21
- async def random_url(_):
22
- pet = random.choice(["cat", "dog"])
23
- api_url = f"https://api.the{pet}api.com/v1/images/search"
24
- async with aiohttp.ClientSession() as session:
25
- async with session.get(api_url) as resp:
26
- return (await resp.json())[0]["url"]
27
 
28
 
29
  @pn.cache
30
  def load_processor_model(
31
  processor_name: str, model_name: str
32
- ) -> Tuple[CLIPProcessor, CLIPModel]:
33
- processor = CLIPProcessor.from_pretrained(processor_name)
34
- model = CLIPModel.from_pretrained(model_name)
35
  return processor, model
36
 
37
 
38
- async def open_image_url(image_url: str) -> Image:
39
- async with aiohttp.ClientSession() as session:
40
- async with session.get(image_url) as resp:
41
- return Image.open(io.BytesIO(await resp.read()))
 
42
 
 
 
 
 
 
 
 
 
 
 
43
 
44
- def get_similarity_scores(class_items: List[str], image: Image) -> List[float]:
 
45
  processor, model = load_processor_model(
46
- "openai/clip-vit-base-patch32", "openai/clip-vit-base-patch32"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
47
  )
48
- inputs = processor(
49
- text=class_items,
50
- images=[image],
51
- return_tensors="pt", # pytorch tensors
 
 
 
 
 
 
 
 
 
 
52
  )
53
- outputs = model(**inputs)
54
- logits_per_image = outputs.logits_per_image
55
- class_likelihoods = logits_per_image.softmax(dim=1).detach().numpy()
56
- return class_likelihoods[0]
57
 
58
 
59
- async def process_inputs(class_names: List[str], image_url: str):
60
  """
61
  High level function that takes in the user inputs and returns the
62
  classification results as panel objects.
63
  """
64
  try:
65
  main.disabled = True
66
- if not image_url:
67
- yield "##### ⚠️ Provide an image URL"
 
68
  return
69
-
70
  yield "##### ⚙ Fetching image and running model..."
71
  try:
72
- pil_img = await open_image_url(image_url)
73
- img = pn.pane.Image(pil_img, height=400, align="center")
 
 
 
 
 
 
74
  except Exception as e:
75
- yield f"##### 😔 Something went wrong, please try a different URL!"
76
  return
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
77
 
78
- class_items = class_names.split(",")
79
- class_likelihoods = get_similarity_scores(class_items, pil_img)
80
-
81
- # build the results column
82
- results = pn.Column("##### 🎉 Here are the results!", img)
83
-
84
- for class_item, class_likelihood in zip(class_items, class_likelihoods):
85
- row_label = pn.widgets.StaticText(
86
- name=class_item.strip(), value=f"{class_likelihood:.2%}", align="center"
87
- )
88
- row_bar = pn.indicators.Progress(
89
- value=int(class_likelihood * 100),
90
- sizing_mode="stretch_width",
91
- bar_color="secondary",
92
- margin=(0, 10),
93
- design=pn.theme.Material,
94
- )
95
- results.append(pn.Column(row_label, row_bar))
96
  yield results
 
 
 
 
 
97
  finally:
98
  main.disabled = False
99
 
100
 
101
- # create widgets
102
- randomize_url = pn.widgets.Button(name="Randomize URL", align="end")
 
 
 
 
103
 
104
- image_url = pn.widgets.TextInput(
105
- name="Image URL to classify",
106
- value=pn.bind(random_url, randomize_url),
107
- )
108
- class_names = pn.widgets.TextInput(
109
- name="Comma separated class names",
110
- placeholder="Enter possible class names, e.g. cat, dog",
111
- value="cat, dog, parrot",
112
  )
113
 
 
 
 
 
 
 
114
  input_widgets = pn.Column(
115
- "##### 😊 Click randomize or paste a URL to start classifying!",
116
- pn.Row(image_url, randomize_url),
117
- class_names,
 
 
 
 
118
  )
119
 
120
- # add interactivity
121
  interactive_result = pn.panel(
122
- pn.bind(process_inputs, image_url=image_url, class_names=class_names),
 
 
123
  height=600,
124
  )
125
 
126
- # add footer
127
- footer_row = pn.Row(pn.Spacer(), align="center")
128
- for icon, url in ICON_URLS.items():
129
- href_button = pn.widgets.Button(icon=icon, width=35, height=35)
130
- href_button.js_on_click(code=f"window.open('{url}')")
131
- footer_row.append(href_button)
132
- footer_row.append(pn.Spacer())
133
 
134
- # create dashboard
135
  main = pn.WidgetBox(
136
  input_widgets,
137
  interactive_result,
138
- footer_row,
139
  )
140
 
141
- title = "Panel Demo - Image Classification"
 
142
  pn.template.BootstrapTemplate(
143
  title=title,
144
  main=main,
145
  main_max_width="min(50%, 698px)",
146
- header_background="#F08080",
147
- ).servable(title=title)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import io
2
  import random
3
+ from io import BytesIO
4
  from typing import List, Tuple
5
 
6
  import aiohttp
7
  import panel as pn
8
+ import torch
9
+ from bokeh.themes import Theme
 
 
10
 
11
+ # import torchvision.transforms.functional as TVF
12
+ import torch.nn.functional as F
13
+ from PIL import Image
14
+ from transformers import AutoImageProcessor, ResNetForImageClassification
15
+ from transformers.image_transforms import to_pil_image
 
 
16
 
17
+ DEVICE = "cpu"
18
 
19
+ pn.extension("mathjax", design="bootstrap", sizing_mode="stretch_width")
 
 
 
 
 
20
 
21
 
22
  @pn.cache
23
  def load_processor_model(
24
  processor_name: str, model_name: str
25
+ ) -> Tuple[AutoImageProcessor, ResNetForImageClassification]:
26
+ processor = AutoImageProcessor.from_pretrained(processor_name)
27
+ model = ResNetForImageClassification.from_pretrained(model_name)
28
  return processor, model
29
 
30
 
31
+ def denormalize(image, mean, std):
32
+ mean = torch.tensor(mean).view(1, -1, 1, 1) # Reshape for broadcasting
33
+ std = torch.tensor(std).view(1, -1, 1, 1)
34
+ return image * std + mean
35
+
36
 
37
+ # FGSM attack code
38
+ def fgsm_attack(image, epsilon, data_grad):
39
+ # Collect the element-wise sign of the data gradient
40
+ sign_data_grad = data_grad.sign()
41
+ # Create the perturbed image by adjusting each pixel of the input image
42
+ perturbed_image = image + epsilon * sign_data_grad
43
+ # Adding clipping to maintain [0,1] range
44
+ perturbed_image = torch.clamp(perturbed_image, 0, 1)
45
+ # Return the perturbed image
46
+ return perturbed_image.detach()
47
 
48
+
49
+ def run_forward_backward(image: Image, epsilon):
50
  processor, model = load_processor_model(
51
+ "microsoft/resnet-18", "microsoft/resnet-18"
52
+ )
53
+
54
+ # Grab input
55
+ input_tensor = processor(image, return_tensors="pt")["pixel_values"]
56
+ input_tensor.requires_grad_(True)
57
+
58
+ # Run inference
59
+ output = model(input_tensor)
60
+ output = output.logits
61
+
62
+ # Top target
63
+ top_pred = output.max(1, keepdim=False)[1]
64
+
65
+ # Get NLL loss and backward
66
+ loss = F.cross_entropy(output, top_pred)
67
+ model.zero_grad()
68
+ loss.backward()
69
+
70
+ # Denormalize input
71
+ mean = torch.tensor(processor.image_mean).view(1, -1, 1, 1)
72
+ std = torch.tensor(processor.image_std).view(1, -1, 1, 1)
73
+ input_tensor_denorm = input_tensor.detach() * std + mean
74
+
75
+ # FGSM attack
76
+ adv_input_tensor_denorm = fgsm_attack(
77
+ image=input_tensor_denorm, epsilon=epsilon, data_grad=input_tensor.grad.data
78
  )
79
+
80
+ # Normalize adversarial input tensor back to the input range
81
+ adv_input_tensor = (adv_input_tensor_denorm - mean) / std
82
+
83
+ # Inference on adversarial image
84
+ adv_output = model(adv_input_tensor)
85
+ adv_output = adv_output.logits
86
+
87
+
88
+ return (
89
+ output,
90
+ adv_output,
91
+ input_tensor_denorm.squeeze(),
92
+ adv_input_tensor_denorm.squeeze(),
93
  )
 
 
 
 
94
 
95
 
96
+ async def process_inputs(button_event, image_data: bytes, epsilon: float):
97
  """
98
  High level function that takes in the user inputs and returns the
99
  classification results as panel objects.
100
  """
101
  try:
102
  main.disabled = True
103
+ # if not button_event or (button_event and not isinstance(image_data, bytes)):
104
+ if not isinstance(image_data, bytes):
105
+ yield "##### 👋 Upload an image to proceed"
106
  return
107
+
108
  yield "##### ⚙ Fetching image and running model..."
109
  try:
110
+ # Open the image using PIL
111
+ pil_img = Image.open(BytesIO(image_data))
112
+
113
+ # Run forward + FGSM
114
+ clean_logits, adv_logits, input_tensor, adv_input_tensor = run_forward_backward(
115
+ image=pil_img, epsilon=epsilon
116
+ )
117
+
118
  except Exception as e:
119
+ yield f"##### Something went wrong, please try a different image! \n {e}"
120
  return
121
+
122
+ img = pn.pane.Image(
123
+ to_pil_image(input_tensor, do_rescale=True),
124
+ height=350,
125
+ align="center",
126
+ )
127
+
128
+ # Convert image for visualizing
129
+ adv_img = pn.pane.Image(
130
+ to_pil_image(adv_input_tensor, do_rescale=True),
131
+ height=350,
132
+ align="center",
133
+ )
134
+
135
+ # Build the results column
136
+ k_val = 5
137
+ results = pn.Column(
138
+ pn.Row("###### Uploaded", "###### Adversarial"), pn.Row(img, adv_img), f" ###### Top {k_val} class predictions",
139
+ )
140
+
141
+ # Get likelihoods
142
+ likelihoods = [
143
+ F.softmax(clean_logits, dim=1).squeeze(),
144
+ F.softmax(adv_logits, dim=1).squeeze(),
145
+ ]
146
+
147
+ label_bars_rows = pn.Row()
148
+
149
+ for likelihood_tensor in likelihoods:
150
+ # Get top k values and indices
151
+ vals_topk_clean, idx_topk_clean = torch.topk(likelihood_tensor, k=k_val)
152
+ label_bars = pn.Column()
153
+
154
+ for idx, val in zip(idx_topk_clean, vals_topk_clean):
155
+ prob = val.item()
156
+ row_label = pn.widgets.StaticText(
157
+ name=f"{classes[idx]}",
158
+ value=f"{prob:.2%}",
159
+ align="center"
160
+ )
161
+ row_bar = pn.indicators.Progress(
162
+ value=int(prob * 100),
163
+ sizing_mode="stretch_width",
164
+ bar_color="success" if prob > 0.7 else "warning", # Dynamic color based on value
165
+ margin=(0, 10),
166
+ design=pn.theme.Material,
167
+ )
168
+ label_bars.append(pn.Column(row_label, row_bar))
169
+
170
+ # for likelihood_tensor in likelihoods:
171
+ # # Get top
172
+ # vals_topk_clean, idx_topk_clean = torch.topk(likelihood_tensor, k=k_val)
173
+ # label_bars = pn.Column()
174
+ # for idx, val in zip(idx_topk_clean, vals_topk_clean):
175
+ # prob = val.item()
176
+ # row_label = pn.widgets.StaticText(
177
+ # name=f"{classes[idx]}", value=f"{prob:.2%}", align="center"
178
+ # )
179
+ # row_bar = pn.indicators.Progress(
180
+ # value=int(prob * 100),
181
+ # sizing_mode="stretch_width",
182
+ # bar_color="secondary",
183
+ # margin=(0, 10),
184
+ # design=pn.theme.Material,
185
+ # )
186
+ # label_bars.append(pn.Column(row_label, row_bar))
187
+
188
+ label_bars_rows.append(label_bars)
189
 
190
+ results.append(label_bars_rows)
191
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
192
  yield results
193
+
194
+ except Exception as e:
195
+ yield f"##### Something went wrong! \n {e}"
196
+ return
197
+
198
  finally:
199
  main.disabled = False
200
 
201
 
202
+ ####################################################################################################################################
203
+ # Get classes
204
+ classes = []
205
+ with open("classes.txt", "r") as file:
206
+ classes = file.read()
207
+ classes = classes.split("\n")
208
 
209
+ # Create widgets
210
+ ############################################
211
+ # Fil upload widget
212
+ file_input = pn.widgets.FileInput(name="Upload a PNG image", accept=".png,.jpg")
213
+
214
+ # Epsilon
215
+ epsilon_slider = pn.widgets.FloatSlider(
216
+ name=r"$$\epsilon$$", start=0, end=0.1, step=0.005, value=0.05, format='1[.]000'
217
  )
218
 
219
+ # Upload button widget
220
+ upload_image = pn.widgets.Button(name="Upload image", align="end")
221
+
222
+ ############################################
223
+
224
+ # Organize widgets in a column
225
  input_widgets = pn.Column(
226
+ """
227
+ ###### Classify an image with a pre-trained [ResNet18](https://huggingface.co/microsoft/resnet-18) and generate an adversarial example.\n
228
+
229
+ Please be patient with the application, it is running on a low-resource device.
230
+ """,
231
+ file_input,
232
+ epsilon_slider,
233
  )
234
 
235
+ # Add interactivity
236
  interactive_result = pn.panel(
237
+ pn.bind(
238
+ process_inputs, upload_image, file_input.param.value, epsilon_slider.param.value
239
+ ),
240
  height=600,
241
  )
242
 
243
+ footer = pn.pane.Markdown(
244
+ """
245
+ <br><br><br><br>
246
+ Wondering where the class names come from? Find the full list [here](https://deeplearning.cms.waikato.ac.nz/user-guide/class-maps/IMAGENET/)
247
+ """
248
+ )
 
249
 
250
+ # Create dashboard
251
  main = pn.WidgetBox(
252
  input_widgets,
253
  interactive_result,
254
+ footer,
255
  )
256
 
257
+ title = "Adversarial Sample Generation"
258
+
259
  pn.template.BootstrapTemplate(
260
  title=title,
261
  main=main,
262
  main_max_width="min(50%, 698px)",
263
+ header_background="#101820",
264
+ ).servable(title=title)
265
+
266
+
267
+ # Functions from original demo
268
+
269
+ # ICON_URLS = {
270
+ # "brand-github": "https://github.com/holoviz/panel",
271
+ # "brand-twitter": "https://twitter.com/Panel_Org",
272
+ # "brand-linkedin": "https://www.linkedin.com/company/panel-org",
273
+ # "message-circle": "https://discourse.holoviz.org/",
274
+ # "brand-discord": "https://discord.gg/AXRHnJU6sP",
275
+ # }
276
+
277
+
278
+ # async def random_url(_):
279
+ # pet = random.choice(["cat", "dog"])
280
+ # api_url = f"https://api.the{pet}api.com/v1/images/search"
281
+ # async with aiohttp.ClientSession() as session:
282
+ # async with session.get(api_url) as resp:
283
+ # return (await resp.json())[0]["url"]
284
+
285
+
286
+ # @pn.cache
287
+ # def load_processor_model(
288
+ # processor_name: str, model_name: str
289
+ # ) -> Tuple[CLIPProcessor, CLIPModel]:
290
+ # processor = CLIPProcessor.from_pretrained(processor_name)
291
+ # model = CLIPModel.from_pretrained(model_name)
292
+ # return processor, model
293
+
294
+
295
+ # async def open_image_url(image_url: str) -> Image:
296
+ # async with aiohttp.ClientSession() as session:
297
+ # async with session.get(image_url) as resp:
298
+ # return Image.open(io.BytesIO(await resp.read()))
299
+
300
+
301
+ # def get_similarity_scores(class_items: List[str], image: Image) -> List[float]:
302
+ # processor, model = load_processor_model(
303
+ # "openai/clip-vit-base-patch32", "openai/clip-vit-base-patch32"
304
+ # )
305
+ # inputs = processor(
306
+ # text=class_items,
307
+ # images=[image],
308
+ # return_tensors="pt", # pytorch tensors
309
+ # )
310
+ # print(inputs)
311
+ # outputs = model(**inputs)
312
+ # logits_per_image = outputs.logits_per_image
313
+ # class_likelihoods = logits_per_image.softmax(dim=1).detach().numpy()
314
+ # return class_likelihoods[0]
classes.txt ADDED
@@ -0,0 +1,1000 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ tench
2
+ goldfish
3
+ great white shark
4
+ tiger shark
5
+ hammerhead
6
+ electric ray
7
+ stingray
8
+ cock
9
+ hen
10
+ ostrich
11
+ brambling
12
+ goldfinch
13
+ house finch
14
+ junco
15
+ indigo bunting
16
+ robin
17
+ bulbul
18
+ jay
19
+ magpie
20
+ chickadee
21
+ water ouzel
22
+ kite
23
+ bald eagle
24
+ vulture
25
+ great grey owl
26
+ European fire salamander
27
+ common newt
28
+ eft
29
+ spotted salamander
30
+ axolotl
31
+ bullfrog
32
+ tree frog
33
+ tailed frog
34
+ loggerhead
35
+ leatherback turtle
36
+ mud turtle
37
+ terrapin
38
+ box turtle
39
+ banded gecko
40
+ common iguana
41
+ American chameleon
42
+ whiptail
43
+ agama
44
+ frilled lizard
45
+ alligator lizard
46
+ Gila monster
47
+ green lizard
48
+ African chameleon
49
+ Komodo dragon
50
+ African crocodile
51
+ American alligator
52
+ triceratops
53
+ thunder snake
54
+ ringneck snake
55
+ hognose snake
56
+ green snake
57
+ king snake
58
+ garter snake
59
+ water snake
60
+ vine snake
61
+ night snake
62
+ boa constrictor
63
+ rock python
64
+ Indian cobra
65
+ green mamba
66
+ sea snake
67
+ horned viper
68
+ diamondback
69
+ sidewinder
70
+ trilobite
71
+ harvestman
72
+ scorpion
73
+ black and gold garden spider
74
+ barn spider
75
+ garden spider
76
+ black widow
77
+ tarantula
78
+ wolf spider
79
+ tick
80
+ centipede
81
+ black grouse
82
+ ptarmigan
83
+ ruffed grouse
84
+ prairie chicken
85
+ peacock
86
+ quail
87
+ partridge
88
+ African grey
89
+ macaw
90
+ sulphur-crested cockatoo
91
+ lorikeet
92
+ coucal
93
+ bee eater
94
+ hornbill
95
+ hummingbird
96
+ jacamar
97
+ toucan
98
+ drake
99
+ red-breasted merganser
100
+ goose
101
+ black swan
102
+ tusker
103
+ echidna
104
+ platypus
105
+ wallaby
106
+ koala
107
+ wombat
108
+ jellyfish
109
+ sea anemone
110
+ brain coral
111
+ flatworm
112
+ nematode
113
+ conch
114
+ snail
115
+ slug
116
+ sea slug
117
+ chiton
118
+ chambered nautilus
119
+ Dungeness crab
120
+ rock crab
121
+ fiddler crab
122
+ king crab
123
+ American lobster
124
+ spiny lobster
125
+ crayfish
126
+ hermit crab
127
+ isopod
128
+ white stork
129
+ black stork
130
+ spoonbill
131
+ flamingo
132
+ little blue heron
133
+ American egret
134
+ bittern
135
+ crane
136
+ limpkin
137
+ European gallinule
138
+ American coot
139
+ bustard
140
+ ruddy turnstone
141
+ red-backed sandpiper
142
+ redshank
143
+ dowitcher
144
+ oystercatcher
145
+ pelican
146
+ king penguin
147
+ albatross
148
+ grey whale
149
+ killer whale
150
+ dugong
151
+ sea lion
152
+ Chihuahua
153
+ Japanese spaniel
154
+ Maltese dog
155
+ Pekinese
156
+ Shih-Tzu
157
+ Blenheim spaniel
158
+ papillon
159
+ toy terrier
160
+ Rhodesian ridgeback
161
+ Afghan hound
162
+ basset
163
+ beagle
164
+ bloodhound
165
+ bluetick
166
+ black-and-tan coonhound
167
+ Walker hound
168
+ English foxhound
169
+ redbone
170
+ borzoi
171
+ Irish wolfhound
172
+ Italian greyhound
173
+ whippet
174
+ Ibizan hound
175
+ Norwegian elkhound
176
+ otterhound
177
+ Saluki
178
+ Scottish deerhound
179
+ Weimaraner
180
+ Staffordshire bullterrier
181
+ American Staffordshire terrier
182
+ Bedlington terrier
183
+ Border terrier
184
+ Kerry blue terrier
185
+ Irish terrier
186
+ Norfolk terrier
187
+ Norwich terrier
188
+ Yorkshire terrier
189
+ wire-haired fox terrier
190
+ Lakeland terrier
191
+ Sealyham terrier
192
+ Airedale
193
+ cairn
194
+ Australian terrier
195
+ Dandie Dinmont
196
+ Boston bull
197
+ miniature schnauzer
198
+ giant schnauzer
199
+ standard schnauzer
200
+ Scotch terrier
201
+ Tibetan terrier
202
+ silky terrier
203
+ soft-coated wheaten terrier
204
+ West Highland white terrier
205
+ Lhasa
206
+ flat-coated retriever
207
+ curly-coated retriever
208
+ golden retriever
209
+ Labrador retriever
210
+ Chesapeake Bay retriever
211
+ German short-haired pointer
212
+ vizsla
213
+ English setter
214
+ Irish setter
215
+ Gordon setter
216
+ Brittany spaniel
217
+ clumber
218
+ English springer
219
+ Welsh springer spaniel
220
+ cocker spaniel
221
+ Sussex spaniel
222
+ Irish water spaniel
223
+ kuvasz
224
+ schipperke
225
+ groenendael
226
+ malinois
227
+ briard
228
+ kelpie
229
+ komondor
230
+ Old English sheepdog
231
+ Shetland sheepdog
232
+ collie
233
+ Border collie
234
+ Bouvier des Flandres
235
+ Rottweiler
236
+ German shepherd
237
+ Doberman
238
+ miniature pinscher
239
+ Greater Swiss Mountain dog
240
+ Bernese mountain dog
241
+ Appenzeller
242
+ EntleBucher
243
+ boxer
244
+ bull mastiff
245
+ Tibetan mastiff
246
+ French bulldog
247
+ Great Dane
248
+ Saint Bernard
249
+ Eskimo dog
250
+ malamute
251
+ Siberian husky
252
+ dalmatian
253
+ affenpinscher
254
+ basenji
255
+ pug
256
+ Leonberg
257
+ Newfoundland
258
+ Great Pyrenees
259
+ Samoyed
260
+ Pomeranian
261
+ chow
262
+ keeshond
263
+ Brabancon griffon
264
+ Pembroke
265
+ Cardigan
266
+ toy poodle
267
+ miniature poodle
268
+ standard poodle
269
+ Mexican hairless
270
+ timber wolf
271
+ white wolf
272
+ red wolf
273
+ coyote
274
+ dingo
275
+ dhole
276
+ African hunting dog
277
+ hyena
278
+ red fox
279
+ kit fox
280
+ Arctic fox
281
+ grey fox
282
+ tabby
283
+ tiger cat
284
+ Persian cat
285
+ Siamese cat
286
+ Egyptian cat
287
+ cougar
288
+ lynx
289
+ leopard
290
+ snow leopard
291
+ jaguar
292
+ lion
293
+ tiger
294
+ cheetah
295
+ brown bear
296
+ American black bear
297
+ ice bear
298
+ sloth bear
299
+ mongoose
300
+ meerkat
301
+ tiger beetle
302
+ ladybug
303
+ ground beetle
304
+ long-horned beetle
305
+ leaf beetle
306
+ dung beetle
307
+ rhinoceros beetle
308
+ weevil
309
+ fly
310
+ bee
311
+ ant
312
+ grasshopper
313
+ cricket
314
+ walking stick
315
+ cockroach
316
+ mantis
317
+ cicada
318
+ leafhopper
319
+ lacewing
320
+ dragonfly
321
+ damselfly
322
+ admiral
323
+ ringlet
324
+ monarch
325
+ cabbage butterfly
326
+ sulphur butterfly
327
+ lycaenid
328
+ starfish
329
+ sea urchin
330
+ sea cucumber
331
+ wood rabbit
332
+ hare
333
+ Angora
334
+ hamster
335
+ porcupine
336
+ fox squirrel
337
+ marmot
338
+ beaver
339
+ guinea pig
340
+ sorrel
341
+ zebra
342
+ hog
343
+ wild boar
344
+ warthog
345
+ hippopotamus
346
+ ox
347
+ water buffalo
348
+ bison
349
+ ram
350
+ bighorn
351
+ ibex
352
+ hartebeest
353
+ impala
354
+ gazelle
355
+ Arabian camel
356
+ llama
357
+ weasel
358
+ mink
359
+ polecat
360
+ black-footed ferret
361
+ otter
362
+ skunk
363
+ badger
364
+ armadillo
365
+ three-toed sloth
366
+ orangutan
367
+ gorilla
368
+ chimpanzee
369
+ gibbon
370
+ siamang
371
+ guenon
372
+ patas
373
+ baboon
374
+ macaque
375
+ langur
376
+ colobus
377
+ proboscis monkey
378
+ marmoset
379
+ capuchin
380
+ howler monkey
381
+ titi
382
+ spider monkey
383
+ squirrel monkey
384
+ Madagascar cat
385
+ indri
386
+ Indian elephant
387
+ African elephant
388
+ lesser panda
389
+ giant panda
390
+ barracouta
391
+ eel
392
+ coho
393
+ rock beauty
394
+ anemone fish
395
+ sturgeon
396
+ gar
397
+ lionfish
398
+ puffer
399
+ abacus
400
+ abaya
401
+ academic gown
402
+ accordion
403
+ acoustic guitar
404
+ aircraft carrier
405
+ airliner
406
+ airship
407
+ altar
408
+ ambulance
409
+ amphibian
410
+ analog clock
411
+ apiary
412
+ apron
413
+ ashcan
414
+ assault rifle
415
+ backpack
416
+ bakery
417
+ balance beam
418
+ balloon
419
+ ballpoint
420
+ Band Aid
421
+ banjo
422
+ bannister
423
+ barbell
424
+ barber chair
425
+ barbershop
426
+ barn
427
+ barometer
428
+ barrel
429
+ barrow
430
+ baseball
431
+ basketball
432
+ bassinet
433
+ bassoon
434
+ bathing cap
435
+ bath towel
436
+ bathtub
437
+ beach wagon
438
+ beacon
439
+ beaker
440
+ bearskin
441
+ beer bottle
442
+ beer glass
443
+ bell cote
444
+ bib
445
+ bicycle-built-for-two
446
+ bikini
447
+ binder
448
+ binoculars
449
+ birdhouse
450
+ boathouse
451
+ bobsled
452
+ bolo tie
453
+ bonnet
454
+ bookcase
455
+ bookshop
456
+ bottlecap
457
+ bow
458
+ bow tie
459
+ brass
460
+ brassiere
461
+ breakwater
462
+ breastplate
463
+ broom
464
+ bucket
465
+ buckle
466
+ bulletproof vest
467
+ bullet train
468
+ butcher shop
469
+ cab
470
+ caldron
471
+ candle
472
+ cannon
473
+ canoe
474
+ can opener
475
+ cardigan
476
+ car mirror
477
+ carousel
478
+ carpenter's kit
479
+ carton
480
+ car wheel
481
+ cash machine
482
+ cassette
483
+ cassette player
484
+ castle
485
+ catamaran
486
+ CD player
487
+ cello
488
+ cellular telephone
489
+ chain
490
+ chainlink fence
491
+ chain mail
492
+ chain saw
493
+ chest
494
+ chiffonier
495
+ chime
496
+ china cabinet
497
+ Christmas stocking
498
+ church
499
+ cinema
500
+ cleaver
501
+ cliff dwelling
502
+ cloak
503
+ clog
504
+ cocktail shaker
505
+ coffee mug
506
+ coffeepot
507
+ coil
508
+ combination lock
509
+ computer keyboard
510
+ confectionery
511
+ container ship
512
+ convertible
513
+ corkscrew
514
+ cornet
515
+ cowboy boot
516
+ cowboy hat
517
+ cradle
518
+ crane
519
+ crash helmet
520
+ crate
521
+ crib
522
+ Crock Pot
523
+ croquet ball
524
+ crutch
525
+ cuirass
526
+ dam
527
+ desk
528
+ desktop computer
529
+ dial telephone
530
+ diaper
531
+ digital clock
532
+ digital watch
533
+ dining table
534
+ dishrag
535
+ dishwasher
536
+ disk brake
537
+ dock
538
+ dogsled
539
+ dome
540
+ doormat
541
+ drilling platform
542
+ drum
543
+ drumstick
544
+ dumbbell
545
+ Dutch oven
546
+ electric fan
547
+ electric guitar
548
+ electric locomotive
549
+ entertainment center
550
+ envelope
551
+ espresso maker
552
+ face powder
553
+ feather boa
554
+ file
555
+ fireboat
556
+ fire engine
557
+ fire screen
558
+ flagpole
559
+ flute
560
+ folding chair
561
+ football helmet
562
+ forklift
563
+ fountain
564
+ fountain pen
565
+ four-poster
566
+ freight car
567
+ French horn
568
+ frying pan
569
+ fur coat
570
+ garbage truck
571
+ gasmask
572
+ gas pump
573
+ goblet
574
+ go-kart
575
+ golf ball
576
+ golfcart
577
+ gondola
578
+ gong
579
+ gown
580
+ grand piano
581
+ greenhouse
582
+ grille
583
+ grocery store
584
+ guillotine
585
+ hair slide
586
+ hair spray
587
+ half track
588
+ hammer
589
+ hamper
590
+ hand blower
591
+ hand-held computer
592
+ handkerchief
593
+ hard disc
594
+ harmonica
595
+ harp
596
+ harvester
597
+ hatchet
598
+ holster
599
+ home theater
600
+ honeycomb
601
+ hook
602
+ hoopskirt
603
+ horizontal bar
604
+ horse cart
605
+ hourglass
606
+ iPod
607
+ iron
608
+ jack-o'-lantern
609
+ jean
610
+ jeep
611
+ jersey
612
+ jigsaw puzzle
613
+ jinrikisha
614
+ joystick
615
+ kimono
616
+ knee pad
617
+ knot
618
+ lab coat
619
+ ladle
620
+ lampshade
621
+ laptop
622
+ lawn mower
623
+ lens cap
624
+ letter opener
625
+ library
626
+ lifeboat
627
+ lighter
628
+ limousine
629
+ liner
630
+ lipstick
631
+ Loafer
632
+ lotion
633
+ loudspeaker
634
+ loupe
635
+ lumbermill
636
+ magnetic compass
637
+ mailbag
638
+ mailbox
639
+ maillot
640
+ maillot
641
+ manhole cover
642
+ maraca
643
+ marimba
644
+ mask
645
+ matchstick
646
+ maypole
647
+ maze
648
+ measuring cup
649
+ medicine chest
650
+ megalith
651
+ microphone
652
+ microwave
653
+ military uniform
654
+ milk can
655
+ minibus
656
+ miniskirt
657
+ minivan
658
+ missile
659
+ mitten
660
+ mixing bowl
661
+ mobile home
662
+ Model T
663
+ modem
664
+ monastery
665
+ monitor
666
+ moped
667
+ mortar
668
+ mortarboard
669
+ mosque
670
+ mosquito net
671
+ motor scooter
672
+ mountain bike
673
+ mountain tent
674
+ mouse
675
+ mousetrap
676
+ moving van
677
+ muzzle
678
+ nail
679
+ neck brace
680
+ necklace
681
+ nipple
682
+ notebook
683
+ obelisk
684
+ oboe
685
+ ocarina
686
+ odometer
687
+ oil filter
688
+ organ
689
+ oscilloscope
690
+ overskirt
691
+ oxcart
692
+ oxygen mask
693
+ packet
694
+ paddle
695
+ paddlewheel
696
+ padlock
697
+ paintbrush
698
+ pajama
699
+ palace
700
+ panpipe
701
+ paper towel
702
+ parachute
703
+ parallel bars
704
+ park bench
705
+ parking meter
706
+ passenger car
707
+ patio
708
+ pay-phone
709
+ pedestal
710
+ pencil box
711
+ pencil sharpener
712
+ perfume
713
+ Petri dish
714
+ photocopier
715
+ pick
716
+ pickelhaube
717
+ picket fence
718
+ pickup
719
+ pier
720
+ piggy bank
721
+ pill bottle
722
+ pillow
723
+ ping-pong ball
724
+ pinwheel
725
+ pirate
726
+ pitcher
727
+ plane
728
+ planetarium
729
+ plastic bag
730
+ plate rack
731
+ plow
732
+ plunger
733
+ Polaroid camera
734
+ pole
735
+ police van
736
+ poncho
737
+ pool table
738
+ pop bottle
739
+ pot
740
+ potter's wheel
741
+ power drill
742
+ prayer rug
743
+ printer
744
+ prison
745
+ projectile
746
+ projector
747
+ puck
748
+ punching bag
749
+ purse
750
+ quill
751
+ quilt
752
+ racer
753
+ racket
754
+ radiator
755
+ radio
756
+ radio telescope
757
+ rain barrel
758
+ recreational vehicle
759
+ reel
760
+ reflex camera
761
+ refrigerator
762
+ remote control
763
+ restaurant
764
+ revolver
765
+ rifle
766
+ rocking chair
767
+ rotisserie
768
+ rubber eraser
769
+ rugby ball
770
+ rule
771
+ running shoe
772
+ safe
773
+ safety pin
774
+ saltshaker
775
+ sandal
776
+ sarong
777
+ sax
778
+ scabbard
779
+ scale
780
+ school bus
781
+ schooner
782
+ scoreboard
783
+ screen
784
+ screw
785
+ screwdriver
786
+ seat belt
787
+ sewing machine
788
+ shield
789
+ shoe shop
790
+ shoji
791
+ shopping basket
792
+ shopping cart
793
+ shovel
794
+ shower cap
795
+ shower curtain
796
+ ski
797
+ ski mask
798
+ sleeping bag
799
+ slide rule
800
+ sliding door
801
+ slot
802
+ snorkel
803
+ snowmobile
804
+ snowplow
805
+ soap dispenser
806
+ soccer ball
807
+ sock
808
+ solar dish
809
+ sombrero
810
+ soup bowl
811
+ space bar
812
+ space heater
813
+ space shuttle
814
+ spatula
815
+ speedboat
816
+ spider web
817
+ spindle
818
+ sports car
819
+ spotlight
820
+ stage
821
+ steam locomotive
822
+ steel arch bridge
823
+ steel drum
824
+ stethoscope
825
+ stole
826
+ stone wall
827
+ stopwatch
828
+ stove
829
+ strainer
830
+ streetcar
831
+ stretcher
832
+ studio couch
833
+ stupa
834
+ submarine
835
+ suit
836
+ sundial
837
+ sunglass
838
+ sunglasses
839
+ sunscreen
840
+ suspension bridge
841
+ swab
842
+ sweatshirt
843
+ swimming trunks
844
+ swing
845
+ switch
846
+ syringe
847
+ table lamp
848
+ tank
849
+ tape player
850
+ teapot
851
+ teddy
852
+ television
853
+ tennis ball
854
+ thatch
855
+ theater curtain
856
+ thimble
857
+ thresher
858
+ throne
859
+ tile roof
860
+ toaster
861
+ tobacco shop
862
+ toilet seat
863
+ torch
864
+ totem pole
865
+ tow truck
866
+ toyshop
867
+ tractor
868
+ trailer truck
869
+ tray
870
+ trench coat
871
+ tricycle
872
+ trimaran
873
+ tripod
874
+ triumphal arch
875
+ trolleybus
876
+ trombone
877
+ tub
878
+ turnstile
879
+ typewriter keyboard
880
+ umbrella
881
+ unicycle
882
+ upright
883
+ vacuum
884
+ vase
885
+ vault
886
+ velvet
887
+ vending machine
888
+ vestment
889
+ viaduct
890
+ violin
891
+ volleyball
892
+ waffle iron
893
+ wall clock
894
+ wallet
895
+ wardrobe
896
+ warplane
897
+ washbasin
898
+ washer
899
+ water bottle
900
+ water jug
901
+ water tower
902
+ whiskey jug
903
+ whistle
904
+ wig
905
+ window screen
906
+ window shade
907
+ Windsor tie
908
+ wine bottle
909
+ wing
910
+ wok
911
+ wooden spoon
912
+ wool
913
+ worm fence
914
+ wreck
915
+ yawl
916
+ yurt
917
+ web site
918
+ comic book
919
+ crossword puzzle
920
+ street sign
921
+ traffic light
922
+ book jacket
923
+ menu
924
+ plate
925
+ guacamole
926
+ consomme
927
+ hot pot
928
+ trifle
929
+ ice cream
930
+ ice lolly
931
+ French loaf
932
+ bagel
933
+ pretzel
934
+ cheeseburger
935
+ hotdog
936
+ mashed potato
937
+ head cabbage
938
+ broccoli
939
+ cauliflower
940
+ zucchini
941
+ spaghetti squash
942
+ acorn squash
943
+ butternut squash
944
+ cucumber
945
+ artichoke
946
+ bell pepper
947
+ cardoon
948
+ mushroom
949
+ Granny Smith
950
+ strawberry
951
+ orange
952
+ lemon
953
+ fig
954
+ pineapple
955
+ banana
956
+ jackfruit
957
+ custard apple
958
+ pomegranate
959
+ hay
960
+ carbonara
961
+ chocolate sauce
962
+ dough
963
+ meat loaf
964
+ pizza
965
+ potpie
966
+ burrito
967
+ red wine
968
+ espresso
969
+ cup
970
+ eggnog
971
+ alp
972
+ bubble
973
+ cliff
974
+ coral reef
975
+ geyser
976
+ lakeside
977
+ promontory
978
+ sandbar
979
+ seashore
980
+ valley
981
+ volcano
982
+ ballplayer
983
+ groom
984
+ scuba diver
985
+ rapeseed
986
+ daisy
987
+ yellow lady's slipper
988
+ corn
989
+ acorn
990
+ hip
991
+ buckeye
992
+ coral fungus
993
+ agaric
994
+ gyromitra
995
+ stinkhorn
996
+ earthstar
997
+ hen-of-the-woods
998
+ bolete
999
+ ear
1000
+ toilet tissue
requirements.txt CHANGED
@@ -1,6 +1,10 @@
 
 
 
 
 
1
  panel
2
  jupyter
3
- transformers
4
  numpy
5
- torch
6
  aiohttp
 
1
+ --find-links https://download.pytorch.org/whl/cpu
2
+ torch
3
+ torchvision
4
+ # torchaudio
5
+
6
  panel
7
  jupyter
8
+ transformers[torch]
9
  numpy
 
10
  aiohttp