Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,43 +1,27 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
from transformers import pipeline
|
| 3 |
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
st.title("🔍 Fake Job / Lie Detector")
|
| 7 |
st.write(
|
| 8 |
-
"
|
|
|
|
| 9 |
)
|
| 10 |
|
| 11 |
-
#
|
| 12 |
-
|
| 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 |
-
|
| 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("
|
| 28 |
else:
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 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}%**")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|