Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,27 +1,34 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
from transformers import pipeline
|
| 3 |
|
|
|
|
|
|
|
| 4 |
st.title("Fake Job / Lie Detector")
|
|
|
|
| 5 |
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
)
|
| 10 |
|
| 11 |
-
|
| 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 |
-
#
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
st.
|
| 27 |
-
st.write(
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
from transformers import pipeline
|
| 3 |
|
| 4 |
+
# App title
|
| 5 |
+
st.set_page_config(page_title="Fake Job Detector", page_icon="🕵️♂️")
|
| 6 |
st.title("Fake Job / Lie Detector")
|
| 7 |
+
st.markdown("Enter a job description and check if it seems suspicious!")
|
| 8 |
|
| 9 |
+
# Load small NLI model for zero-shot classification (CPU-friendly)
|
| 10 |
+
@st.cache_resource
|
| 11 |
+
def load_model():
|
| 12 |
+
return pipeline("zero-shot-classification", model="facebook/bart-large-mnli")
|
| 13 |
|
| 14 |
+
classifier = load_model()
|
|
|
|
| 15 |
|
| 16 |
+
# Input from user
|
| 17 |
job_description = st.text_area("Enter the job description:")
|
| 18 |
|
| 19 |
+
# Label options
|
| 20 |
+
labels = ["Legitimate", "Suspicious", "Fake", "Scam"]
|
| 21 |
+
|
| 22 |
+
# Button to check
|
| 23 |
if st.button("Check Job"):
|
| 24 |
if not job_description.strip():
|
| 25 |
+
st.warning("Please enter a job description!")
|
| 26 |
else:
|
| 27 |
+
# Run zero-shot classification
|
| 28 |
+
results = classifier(job_description, candidate_labels=labels)
|
| 29 |
+
st.subheader("Prediction:")
|
| 30 |
+
# Show top label and scores
|
| 31 |
+
top_label = results["labels"][0]
|
| 32 |
+
score = results["scores"][0]
|
| 33 |
+
st.success(f"Most likely: **{top_label}** ({score*100:.2f}%)")
|
| 34 |
+
st.write("Full results:", results)
|