ritampatra commited on
Commit
aaddfff
·
verified ·
1 Parent(s): f61526f

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +25 -0
app.py ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from transformers import pipeline
3
+
4
+ # Load pretrained fraud detection model from Hugging Face
5
+ @st.cache_resource
6
+ def load_model():
7
+ return pipeline("text-classification", model="juliensimon/xlm-roberta-base-finetuned-fraud-detection")
8
+
9
+ model = load_model()
10
+
11
+ # Streamlit UI
12
+ st.title("💳 Fraud Detection System (Hugging Face Model)")
13
+
14
+ # User input text
15
+ user_input = st.text_area("Enter transaction description:", "Payment of $500 for electronics purchase")
16
+
17
+ if st.button("Check for Fraud"):
18
+ prediction = model(user_input)
19
+ label = prediction[0]["label"]
20
+ score = prediction[0]["score"]
21
+
22
+ if label == "LABEL_1": # Assuming LABEL_1 means fraud
23
+ st.error(f"🚨 Fraudulent Transaction Detected! (Confidence: {score:.2f})")
24
+ else:
25
+ st.success(f"✅ Legitimate Transaction (Confidence: {score:.2f})")