Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,2 +1,45 @@
|
|
1 |
import streamlit as st
|
2 |
-
from transformers import pipeline
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import streamlit as st
|
2 |
+
from transformers import pipeline
|
3 |
+
from sentence_transformers import SentenceTransformer, util
|
4 |
+
import docx2txt
|
5 |
+
import PyPDF2
|
6 |
+
|
7 |
+
@st.cache_resource
|
8 |
+
def load_model():
|
9 |
+
return SentenceTransformer('all-mpnet-base-v2')
|
10 |
+
|
11 |
+
model = load_model()
|
12 |
+
|
13 |
+
def extract_text_from_file(file):
|
14 |
+
if file.type == "application/pdf":
|
15 |
+
with open(file, "rb") as f:
|
16 |
+
pdf_reader = PyPDF2.PdfReader(f)
|
17 |
+
text = "".join([page.extract_text() for page in pdf_reader.pages])
|
18 |
+
elif file.type == "application/vnd.openxmlformats-officedocument.wordprocessingml.document":
|
19 |
+
text = docx2txt.process(file)
|
20 |
+
else:
|
21 |
+
return None
|
22 |
+
return text
|
23 |
+
|
24 |
+
st.title("Resume/Job Description Similarity Checker")
|
25 |
+
|
26 |
+
job_description = st.text_area("Paste the job description here:")
|
27 |
+
resume_file = st.file_uploader("Upload your resume (PDF or DOCX)", type=["pdf", "docx"])
|
28 |
+
|
29 |
+
if job_description and resume_file:
|
30 |
+
resume_text = extract_text_from_file(resume_file)
|
31 |
+
if resume_text:
|
32 |
+
job_description_embedding = model.encode(job_description)
|
33 |
+
resume_embedding = model.encode(resume_text)
|
34 |
+
|
35 |
+
similarity_score = util.cos_sim(job_description_embedding, resume_embedding).item() * 100
|
36 |
+
st.write(f"**Similarity Score:** {similarity_score:.2f}%")
|
37 |
+
|
38 |
+
if similarity_score > 80:
|
39 |
+
st.success("Your resume seems to be a strong match for the job description!")
|
40 |
+
elif similarity_score > 50:
|
41 |
+
st.warning("Your resume shows some alignment, but consider enhancing it further to better reflect the job requirements.")
|
42 |
+
else:
|
43 |
+
st.error("Your resume might not align well with the job description. Consider revising it based on the listed requirements.")
|
44 |
+
else:
|
45 |
+
st.error("Unsupported file type. Please upload a PDF or DOCX file.")
|