meraj12 commited on
Commit
de69472
·
verified ·
1 Parent(s): 4e4a97a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -1
app.py CHANGED
@@ -35,9 +35,13 @@ def predict(image):
35
  img = transform(image).unsqueeze(0)
36
  with torch.no_grad():
37
  outputs = model(img)
38
- _, predicted = torch.max(outputs, 1)
 
 
 
39
  return class_names[predicted.item()]
40
 
 
41
  # Save history
42
  def save_history(image, result):
43
  timestamp = datetime.now().strftime("%Y%m%d_%H%M%S")
 
35
  img = transform(image).unsqueeze(0)
36
  with torch.no_grad():
37
  outputs = model(img)
38
+ probs = torch.nn.functional.softmax(outputs, dim=1)
39
+ confidence, predicted = torch.max(probs, 1)
40
+ print("Probabilities:", probs.numpy())
41
+ print("Confidence:", confidence.item())
42
  return class_names[predicted.item()]
43
 
44
+
45
  # Save history
46
  def save_history(image, result):
47
  timestamp = datetime.now().strftime("%Y%m%d_%H%M%S")