winamnd commited on
Commit
db8a1e5
·
verified ·
1 Parent(s): 8d4918f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -5
app.py CHANGED
@@ -107,17 +107,23 @@ def generate_ocr(method, image):
107
  with torch.no_grad():
108
  outputs = model(**inputs)
109
  logits = outputs.logits # Get raw logits
110
- probs = F.softmax(logits, dim=1) # Convert logits to probabilities
111
 
112
- # Print probabilities for debugging
113
- print(f"Probabilities: {probs}")
114
 
 
 
 
115
  # Extract probability values
116
  not_spam_prob = probs[0, 0].item()
117
  spam_prob = probs[0, 1].item()
118
 
119
- # Ensure classification is based on correct threshold
120
- if spam_prob > not_spam_prob:
 
 
 
 
121
  label = "Spam"
122
  else:
123
  label = "Not Spam"
 
107
  with torch.no_grad():
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
+ # Convert logits to probabilities
115
+ probs = F.softmax(logits, dim=1)
116
+
117
  # Extract probability values
118
  not_spam_prob = probs[0, 0].item()
119
  spam_prob = probs[0, 1].item()
120
 
121
+ # Print probabilities for debugging
122
+ print(f"Not Spam Probability: {not_spam_prob}, Spam Probability: {spam_prob}")
123
+
124
+ # Use a classification threshold to avoid bias
125
+ threshold = 0.55 # Adjust based on observations
126
+ if spam_prob >= threshold:
127
  label = "Spam"
128
  else:
129
  label = "Not Spam"