Spaces:
Sleeping
Sleeping
fix: revert fix what
Browse files
app.py
CHANGED
|
@@ -34,7 +34,7 @@ class WasteClassifier:
|
|
| 34 |
img_tensor = self.transform(image).unsqueeze(0).to(self.device)
|
| 35 |
|
| 36 |
with torch.no_grad():
|
| 37 |
-
outputs,
|
| 38 |
probabilities = torch.nn.functional.softmax(outputs, dim=1)
|
| 39 |
|
| 40 |
probs = probabilities[0].cpu().numpy()
|
|
@@ -42,9 +42,8 @@ class WasteClassifier:
|
|
| 42 |
confidence = np.max(probs)
|
| 43 |
|
| 44 |
# Process segmentation mask
|
| 45 |
-
seg_mask_probs = torch.sigmoid(seg_mask_logits)
|
| 46 |
seg_mask = (
|
| 47 |
-
|
| 48 |
)
|
| 49 |
# Get first image, first channel
|
| 50 |
# seg_mask = (seg_mask >= 0.2).astype(np.float32) # Threshold at 0.2
|
|
|
|
| 34 |
img_tensor = self.transform(image).unsqueeze(0).to(self.device)
|
| 35 |
|
| 36 |
with torch.no_grad():
|
| 37 |
+
outputs, seg_mask = self.model(img_tensor) # Handle both outputs
|
| 38 |
probabilities = torch.nn.functional.softmax(outputs, dim=1)
|
| 39 |
|
| 40 |
probs = probabilities[0].cpu().numpy()
|
|
|
|
| 42 |
confidence = np.max(probs)
|
| 43 |
|
| 44 |
# Process segmentation mask
|
|
|
|
| 45 |
seg_mask = (
|
| 46 |
+
seg_mask[0, 0].cpu().numpy().astype(np.float32)
|
| 47 |
)
|
| 48 |
# Get first image, first channel
|
| 49 |
# seg_mask = (seg_mask >= 0.2).astype(np.float32) # Threshold at 0.2
|