Spaces:
Running
Running
Update app.py
Browse files
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:
|
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'
|