Spaces:
Build error
Build error
Commit
·
fcab2ec
1
Parent(s):
f19c29f
Update app.py
Browse files
app.py
CHANGED
|
@@ -43,14 +43,14 @@ def predict(img) -> Tuple[Dict, float]:
|
|
| 43 |
start_time = timer()
|
| 44 |
|
| 45 |
# Transform the target image and add a batch dimension
|
| 46 |
-
|
| 47 |
pix = normalize_2d(np.array(img))
|
| 48 |
|
| 49 |
# Put model into evaluation mode and turn on inference mode
|
| 50 |
effnetb2.eval()
|
| 51 |
with torch.inference_mode():
|
| 52 |
# Pass the transformed image through the model and turn the prediction logits into prediction probabilities
|
| 53 |
-
pred_probs = torch.softmax(effnetb2(
|
| 54 |
|
| 55 |
# Create a prediction label and prediction probability dictionary for each prediction class (this is the required format for Gradio's output parameter)
|
| 56 |
pred_labels_and_probs = {class_names[i]: float(pred_probs[0][i]) for i in range(len(class_names))}
|
|
|
|
| 43 |
start_time = timer()
|
| 44 |
|
| 45 |
# Transform the target image and add a batch dimension
|
| 46 |
+
img1 = effnetb2_transforms(img).unsqueeze(0)
|
| 47 |
pix = normalize_2d(np.array(img))
|
| 48 |
|
| 49 |
# Put model into evaluation mode and turn on inference mode
|
| 50 |
effnetb2.eval()
|
| 51 |
with torch.inference_mode():
|
| 52 |
# Pass the transformed image through the model and turn the prediction logits into prediction probabilities
|
| 53 |
+
pred_probs = torch.softmax(effnetb2(img1), dim=1)
|
| 54 |
|
| 55 |
# Create a prediction label and prediction probability dictionary for each prediction class (this is the required format for Gradio's output parameter)
|
| 56 |
pred_labels_and_probs = {class_names[i]: float(pred_probs[0][i]) for i in range(len(class_names))}
|