Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -108,24 +108,15 @@ def generate_ocr(method, image):
|
|
108 |
outputs = model(**inputs)
|
109 |
logits = outputs.logits # Get raw logits
|
110 |
|
111 |
-
# Print raw logits
|
112 |
print(f"Raw logits: {logits}")
|
113 |
|
114 |
-
#
|
115 |
-
|
116 |
|
117 |
-
# Extract probability values
|
118 |
-
not_spam_prob = probs[0, 0].item()
|
119 |
-
spam_prob = probs[0, 1].item()
|
120 |
-
|
121 |
-
# Print probability values for debugging
|
122 |
-
print(f"Not Spam Probability: {not_spam_prob}, Spam Probability: {spam_prob}")
|
123 |
-
|
124 |
-
# Ensure correct label mapping
|
125 |
-
predicted_class = torch.argmax(probs, dim=1).item() # Get predicted class index
|
126 |
print(f"Predicted Class Index: {predicted_class}") # Debugging output
|
127 |
|
128 |
-
#
|
129 |
if predicted_class == 1:
|
130 |
label = "Spam"
|
131 |
else:
|
|
|
108 |
outputs = model(**inputs)
|
109 |
logits = outputs.logits # Get raw logits
|
110 |
|
111 |
+
# Print raw logits for debugging
|
112 |
print(f"Raw logits: {logits}")
|
113 |
|
114 |
+
# Compare raw logits instead of using softmax
|
115 |
+
predicted_class = torch.argmax(logits, dim=1).item()
|
116 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
117 |
print(f"Predicted Class Index: {predicted_class}") # Debugging output
|
118 |
|
119 |
+
# Ensure correct label mapping
|
120 |
if predicted_class == 1:
|
121 |
label = "Spam"
|
122 |
else:
|