yassine123Z commited on
Commit
f9eaa32
·
verified ·
1 Parent(s): 34637e6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -5
app.py CHANGED
@@ -42,11 +42,10 @@ def classify_transaction(text):
42
  trans_emb = model.encode([text])[0]
43
  scores = util.pytorch_cos_sim(torch.tensor(trans_emb), torch.tensor(ref_embeddings)).flatten()
44
  best_idx = scores.argmax().item()
45
- return {
46
- "Predicted Category 1": ref_data.iloc[best_idx]["Cat1EN"],
47
- "Predicted Category 2": ref_data.iloc[best_idx]["Cat2EN"],
48
- "Similarity Score": float(scores[best_idx])
49
- }
50
 
51
  # ==================================================
52
  # 🖥️ Gradio Interface
 
42
  trans_emb = model.encode([text])[0]
43
  scores = util.pytorch_cos_sim(torch.tensor(trans_emb), torch.tensor(ref_embeddings)).flatten()
44
  best_idx = scores.argmax().item()
45
+ cat1 = ref_data.iloc[best_idx]["Cat1EN"]
46
+ cat2 = ref_data.iloc[best_idx]["Cat2EN"]
47
+ score = float(scores[best_idx])
48
+ return cat1, cat2, score
 
49
 
50
  # ==================================================
51
  # 🖥️ Gradio Interface