winamnd commited on
Commit
44a4a1e
·
verified ·
1 Parent(s): ffe536a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -13
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 to debug
112
  print(f"Raw logits: {logits}")
113
 
114
- # Convert logits to probabilities using softmax
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 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
- # Check if the labels are flipped
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: