IncreasingLoss commited on
Commit
14a7e6e
·
verified ·
1 Parent(s): d21e8d5

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -1
app.py CHANGED
@@ -190,13 +190,38 @@ def predict(img):
190
 
191
 
192
  """gradio interface"""
193
- demo = gr.Interface(
194
  fn=predict,
195
  inputs=gr.Image(type="pil", width=244, height=244),
196
  outputs="label",
197
  title="Animal Classifier",
198
  description="Classify 30 animal categories: antelope, buffalo, chimpanzee, cow, deer, dolphin, elephant, fox, giant+panda, giraffe, gorilla, grizzly+bear, hamster, hippopotamus, horse, humpback+whale, leopard, lion, moose, otter, ox, pig, polar+bear, rabbit, rhinoceros, seal, sheep, squirrel, tiger, zebra"
199
  )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
200
 
201
  """launch interface"""
202
  if __name__ == "__main__":
 
190
 
191
 
192
  """gradio interface"""
193
+ """demo = gr.Interface(
194
  fn=predict,
195
  inputs=gr.Image(type="pil", width=244, height=244),
196
  outputs="label",
197
  title="Animal Classifier",
198
  description="Classify 30 animal categories: antelope, buffalo, chimpanzee, cow, deer, dolphin, elephant, fox, giant+panda, giraffe, gorilla, grizzly+bear, hamster, hippopotamus, horse, humpback+whale, leopard, lion, moose, otter, ox, pig, polar+bear, rabbit, rhinoceros, seal, sheep, squirrel, tiger, zebra"
199
  )
200
+ """
201
+
202
+ with gr.Blocks() as demo:
203
+ gr.Markdown("## Animal Classifier")
204
+ gr.Markdown("Classify 30 animal categories: antelope, buffalo, chimpanzee, cow, deer, dolphin, elephant, fox, giant+panda, giraffe, gorilla, grizzly+bear, hamster, hippopotamus, horse, humpback+whale, leopard, lion, moose, otter, ox, pig, polar+bear, rabbit, rhinoceros, seal, sheep, squirrel, tiger, zebra")
205
+ with gr.Row():
206
+ upload = gr.File(
207
+ file_count="multiple",
208
+ file_types=["image"],
209
+ label="Upload Images"
210
+ )
211
+ submit = gr.Button("Classify")
212
+
213
+ with gr.Row():
214
+ gallery = gr.Gallery(label="Uploaded Images")
215
+ predictions = gr.Textbox(label="Predictions", interactive=False)
216
+
217
+ submit.click(
218
+ fn=lambda files: (
219
+ [f.name for f in files],
220
+ ", ".join([predict([file]) for file in files])
221
+ ),
222
+ inputs=upload,
223
+ outputs=[gallery, predictions]
224
+ )
225
 
226
  """launch interface"""
227
  if __name__ == "__main__":