neerajprad commited on
Commit
7f96e03
·
1 Parent(s): bb65d6b

Colab update - fix classify

Browse files
Files changed (1) hide show
  1. app.py +2 -3
app.py CHANGED
@@ -11,8 +11,7 @@ labels = dataset['train'].features['labels'].names
11
 
12
  def classify(im):
13
  features = feature_extractor(im, return_tensors='pt')
14
- inp = model(**features)
15
- logits = torch.nn.functional.softmax(inp.logits, dim=-1)
16
  probability = torch.nn.functional.softmax(logits, dim=-1)
17
  probs = probability[0].detach().numpy()
18
  confidences = {label: float(probs[i]) for i, label in enumerate(labels)}
@@ -22,7 +21,7 @@ def classify(im):
22
  interface = gr.Interface(
23
  title="Leaf Spot Classifier",
24
  description="Classify the leaf into one of: angular_leaf_spot, bean_rust, healthy",
25
- examples="examples"
26
  fn=classify,
27
  inputs=gr.Image(shape=(224, 224)),
28
  outputs=gr.Label(num_top_classes=3),
 
11
 
12
  def classify(im):
13
  features = feature_extractor(im, return_tensors='pt')
14
+ logits = model(features["pixel_values"])[-1]
 
15
  probability = torch.nn.functional.softmax(logits, dim=-1)
16
  probs = probability[0].detach().numpy()
17
  confidences = {label: float(probs[i]) for i, label in enumerate(labels)}
 
21
  interface = gr.Interface(
22
  title="Leaf Spot Classifier",
23
  description="Classify the leaf into one of: angular_leaf_spot, bean_rust, healthy",
24
+ examples="examples",
25
  fn=classify,
26
  inputs=gr.Image(shape=(224, 224)),
27
  outputs=gr.Label(num_top_classes=3),