IncreasingLoss commited on
Commit
d21e8d5
·
verified ·
1 Parent(s): 7e8fb73

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -5
app.py CHANGED
@@ -180,9 +180,9 @@ def predict(img):
180
  transforms.Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225])
181
  ])
182
 
183
- img_tensor = preprocess(img).unsqueeze(0) # Fix spelling of unsqueeze
184
 
185
- with torch.inference_mode(): # Add parentheses
186
  logits = model(img_tensor)
187
  preds = logits.argmax(dim=1)
188
  return classes[preds.item()]
@@ -192,10 +192,10 @@ def predict(img):
192
  """gradio interface"""
193
  demo = gr.Interface(
194
  fn=predict,
195
- inputs=gr.Image(type="pil", width=244, height=244), # Input component
196
- outputs="label", # Output component
197
  title="Animal Classifier",
198
- description="Classify images into 30 animal categories"
199
  )
200
 
201
  """launch interface"""
 
180
  transforms.Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225])
181
  ])
182
 
183
+ img_tensor = preprocess(img).unsqueeze(0)
184
 
185
+ with torch.inference_mode():
186
  logits = model(img_tensor)
187
  preds = logits.argmax(dim=1)
188
  return classes[preds.item()]
 
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"""