Infinity-1995 commited on
Commit
311306e
·
verified ·
1 Parent(s): 1d230e4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -32
app.py CHANGED
@@ -1,43 +1,27 @@
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.")
 
1
  import streamlit as st
2
  from transformers import pipeline
3
 
4
+ st.title("Fake Job / Lie Detector")
5
+
 
6
  st.write(
7
+ "This app classifies a job description as potentially fake or real. "
8
+ "Runs entirely locally on CPU, no API key needed."
9
  )
10
 
11
+ # Use a small, CPU-friendly model
12
+ classifier = pipeline("zero-shot-classification", model="facebook/bart-large-mnli", device=-1)
 
 
 
 
 
 
 
13
 
14
+ job_description = st.text_area("Enter the job description:")
 
15
 
 
16
  if st.button("Check Job"):
17
  if not job_description.strip():
18
+ st.warning("Please enter a job description.")
19
  else:
20
+ # Define the candidate labels
21
+ labels = ["real", "fake"]
22
+ result = classifier(job_description, candidate_labels=labels)
23
+ top_label = result["labels"][0]
24
+ score = result["scores"][0]
25
+
26
+ st.write(f"Prediction: **{top_label.upper()}**")
27
+ st.write(f"Confidence: **{score*100:.2f}%**")