DawnC commited on
Commit
e28b46e
1 Parent(s): 9c3253b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +1 -1
app.py CHANGED
@@ -46,7 +46,7 @@ def classify_image(image):
46
  probabilities, indices = torch.topk(outputs, k=3) # 取得前3個預測
47
  probabilities = torch.nn.functional.softmax(probabilities, dim=1) # 將結果轉換為機率
48
  predictions = [(class_names[idx], prob.item()) for idx, prob in zip(indices[0], probabilities[0])]
49
- return {class_name: f"{prob * 100:.2f}%" for class_name, prob in predictions}
50
 
51
  # 設置 examples 路徑
52
  examples_path = './examples'
 
46
  probabilities, indices = torch.topk(outputs, k=3) # 取得前3個預測
47
  probabilities = torch.nn.functional.softmax(probabilities, dim=1) # 將結果轉換為機率
48
  predictions = [(class_names[idx], prob.item()) for idx, prob in zip(indices[0], probabilities[0])]
49
+ return {class_name: prob for class_name, prob in predictions} # Return raw float numbers
50
 
51
  # 設置 examples 路徑
52
  examples_path = './examples'