Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,22 +1,43 @@
|
|
| 1 |
-
# app.py
|
| 2 |
import streamlit as st
|
| 3 |
from transformers import pipeline
|
| 4 |
|
| 5 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
|
| 7 |
-
#
|
| 8 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
|
| 10 |
-
|
| 11 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
if st.button("Check Job"):
|
| 13 |
-
if job_description.strip()
|
| 14 |
-
st.warning("Please enter a job description
|
| 15 |
else:
|
| 16 |
-
|
| 17 |
-
result = classifier(job_description, candidate_labels
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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.")
|