versae commited on
Commit
6ff355b
1 Parent(s): 88121b8

Adding samples

Browse files
Files changed (1) hide show
  1. app.py +11 -0
app.py CHANGED
@@ -8,8 +8,18 @@ from torch import nn
8
  import gradio as gr
9
  import requests
10
  from PIL import Image, ImageFile
 
11
  ImageFile.LOAD_TRUNCATED_IMAGES = True
12
 
 
 
 
 
 
 
 
 
 
13
 
14
  LABELS = Path('class_names.txt').read_text().splitlines()
15
  class_model = nn.Sequential(
@@ -117,6 +127,7 @@ interface = gr.Interface(
117
  outputs=[gr.outputs.Label(num_top_classes=3)] + 3 * [gr.outputs.Image(type="file")],
118
  title=title,
119
  description=description,
 
120
  live=True
121
  )
122
  interface.launch(debug=True)
 
8
  import gradio as gr
9
  import requests
10
  from PIL import Image, ImageFile
11
+ from urllib.request import urlretrieve
12
  ImageFile.LOAD_TRUNCATED_IMAGES = True
13
 
14
+ # Download sample images
15
+ urlretrieve("https://www.sciencemag.org/sites/default/files/styles/article_main_large/public/cc_BE6RJF_16x9.jpg?itok=nP17Fm9H","monkey.jpg")
16
+ urlretrieve("https://www.discoverboating.com/sites/default/files/inline-images/buying-a-sailboat-checklist.jpg","sailboat.jpg")
17
+ urlretrieve("https://external-preview.redd.it/lG5mI_9Co1obw2TiY0e-oChlXfEQY3tsRaIjpYjERqs.jpg?auto=webp&s=ea81982f44b83efbb803c8cff8953ee547624f70","bicycle.jpg")
18
+ sample_images = [
19
+ ["monkey.jpg"],
20
+ ["sailboat.jpg"],
21
+ ["bicycle.jpg"],
22
+ ]
23
 
24
  LABELS = Path('class_names.txt').read_text().splitlines()
25
  class_model = nn.Sequential(
 
127
  outputs=[gr.outputs.Label(num_top_classes=3)] + 3 * [gr.outputs.Image(type="file")],
128
  title=title,
129
  description=description,
130
+ examples=sample_images,
131
  live=True
132
  )
133
  interface.launch(debug=True)