Infinity-1995 commited on
Commit
0593b67
·
verified ·
1 Parent(s): 8850ba6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +35 -14
app.py CHANGED
@@ -1,22 +1,43 @@
1
- # app.py
2
  import streamlit as st
3
  from transformers import pipeline
4
 
5
- st.title("Fake Job Posting Detector")
 
 
 
 
 
6
 
7
- # Use a small model that fits in Hugging Face Space memory
8
- classifier = pipeline("zero-shot-classification", model="Groq/compound-mini")
 
 
 
 
 
9
 
10
- job_description = st.text_area("Enter the job description:")
11
 
 
 
 
 
12
  if st.button("Check Job"):
13
- if job_description.strip() == "":
14
- st.warning("Please enter a job description.")
15
  else:
16
- labels = ["Legit", "Fake"]
17
- result = classifier(job_description, candidate_labels=labels)
18
- predicted_label = result['labels'][0]
19
- confidence = result['scores'][0]
20
-
21
- st.write(f"Prediction: **{predicted_label}**")
22
- st.write(f"Confidence: {confidence:.2f}")
 
 
 
 
 
 
 
 
 
 
1
  import streamlit as st
2
  from transformers import pipeline
3
 
4
+ # --- App title and description ---
5
+ st.set_page_config(page_title="Fake Job / Lie Detector", layout="centered")
6
+ st.title("🔍 Fake Job / Lie Detector")
7
+ st.write(
8
+ "Enter a job description below and the AI will predict if it's likely genuine or fake."
9
+ )
10
 
11
+ # --- Load zero-shot classification model ---
12
+ @st.cache_resource
13
+ def load_model():
14
+ return pipeline(
15
+ "zero-shot-classification",
16
+ model="typeform/distilbert-base-uncased-mnli"
17
+ )
18
 
19
+ classifier = load_model()
20
 
21
+ # --- Text input ---
22
+ job_description = st.text_area("Enter the job description here:")
23
+
24
+ # --- Button action ---
25
  if st.button("Check Job"):
26
+ if not job_description.strip():
27
+ st.warning("⚠️ Please enter a job description first!")
28
  else:
29
+ candidate_labels = ["genuine", "fake"]
30
+ result = classifier(job_description, candidate_labels)
31
+
32
+ label = result['labels'][0]
33
+ confidence = round(result['scores'][0]*100, 2)
34
+
35
+ # --- Display results with color ---
36
+ if label == "genuine":
37
+ st.success(f"✅ Prediction: {label.upper()} ({confidence}%)")
38
+ else:
39
+ st.error(f"❌ Prediction: {label.upper()} ({confidence}%)")
40
+
41
+ # --- Footer ---
42
+ st.markdown("---")
43
+ st.markdown("Built with ❤️ using Hugging Face Transformers and Streamlit.")