Spaces:
Sleeping
Sleeping
Update app.py
Browse files12345678910111213141516171819202122232425262728293031323334import streamlit as stfrom transformers import pipeline# App titlest.set_page_config(page_title="Fake Job Detector", page_icon="🕵️♂️")st.title("Fake Job / Lie Detector")st.markdown("Enter a job description and check if it seems suspicious!")# Load small NLI model for zero-shot classification (CPU-friendly)@st.cache_resourcedef load_model():return pipeline("zero-shot-classification", model="facebook/bart-large-mnli")classifier = load_model()# Input from userjob_description = st.text_area("Enter the job description:")# Label optionslabels = ["Legitimate", "Suspicious", "Fake", "Scam"]# Button to checkif st.button("Check Job"):if not job_description.strip():st.warning("Please enter a job description!")else:# Run zero-shot classificationresults = classifier(job_description, candidate_labels=labels)st.subheader("Prediction:")# Show top label and scorestop_label = results["labels"][0]score = results["scores"][0]st.success(f"Most likely: **{top_label}** ({score*100:.2f}%)")st.write("Full results:", results)1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162import streamlit as stfrom transformers import pipelinefrom PIL import Imageimport pytesseractfrom pdf2image import convert_from_bytes# -------------------# Load Hugging Face text classifier# -------------------@st.cache_resourcedef load_classifier():classifier = pipeline("text-classification", model="distilbert-base-uncased-finetuned-sst-2-english")return classifierclassifier = load_classifier()# -------------------# App UI# -------------------st.title("Fake Job Detector")st.write("Paste job text or upload a screenshot/PDF to check if the job posting is Legitimate or Fake.")# Job text inputjob_text = st.text_area("Paste job description here:")# File upload (image or PDF)uploaded_file = st.file_uploader("Or upload a screenshot / PDF", type=["png","jpg","jpeg","pdf"])extracted_text = ""# Extract text from file if uploadedif uploaded_file:if uploaded_file.type == "application/pdf":images = convert_from_bytes(uploaded_file.read())for img in images:extracted_text += pytesseract.image_to_string(img) + "\n"else:img = Image.open(uploaded_file)extracted_text = pytesseract.image_to_string(img)# Combine pasted text + extracted textfull_text = job_text + "\n" + extracted_textif st.button("Detect"):if full_text.strip() == "":st.warning("Please paste job text or upload a file!")else:result = classifier(full_text)label = result[0]['label']score = result[0]['score']# Map labels to Fake/Suspicious/Legit (simple demo)# Here using SST-2 labels for demo; in real app, fine-tune modelif label == "NEGATIVE":final_label = "Suspicious / Fake"else:final_label = "Legitimate"st.success(f"Prediction: **{final_label}**")st.info(f"Confidence: {score:.2f}")st.subheader("Extracted Job Text:")st.text_area("Text Extracted", full_text, height=200)
app.py+53-25