Spaces:
Sleeping
Sleeping
Upload 2 files
Browse files- app.py +84 -0
- requirements.txt +4 -0
app.py
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import base64
|
| 2 |
+
import streamlit as st
|
| 3 |
+
import os
|
| 4 |
+
import io
|
| 5 |
+
from PIL import Image
|
| 6 |
+
import pdf2image
|
| 7 |
+
import google.generativeai as genai
|
| 8 |
+
|
| 9 |
+
|
| 10 |
+
|
| 11 |
+
def get_gemini_response(input,pdf_cotent,prompt):
|
| 12 |
+
model=genai.GenerativeModel('gemini-pro-vision')
|
| 13 |
+
response=model.generate_content([input,pdf_content[0],prompt])
|
| 14 |
+
return response.text
|
| 15 |
+
|
| 16 |
+
def input_pdf_setup(uploaded_file):
|
| 17 |
+
if uploaded_file is not None:
|
| 18 |
+
## Convert the PDF to image
|
| 19 |
+
images=pdf2image.convert_from_bytes(uploaded_file.read())
|
| 20 |
+
|
| 21 |
+
first_page=images[0]
|
| 22 |
+
|
| 23 |
+
# Convert to bytes
|
| 24 |
+
img_byte_arr = io.BytesIO()
|
| 25 |
+
first_page.save(img_byte_arr, format='JPEG')
|
| 26 |
+
img_byte_arr = img_byte_arr.getvalue()
|
| 27 |
+
|
| 28 |
+
pdf_parts = [
|
| 29 |
+
{
|
| 30 |
+
"mime_type": "image/jpeg",
|
| 31 |
+
"data": base64.b64encode(img_byte_arr).decode() # encode to base64
|
| 32 |
+
}
|
| 33 |
+
]
|
| 34 |
+
return pdf_parts
|
| 35 |
+
else:
|
| 36 |
+
raise FileNotFoundError("No file uploaded")
|
| 37 |
+
|
| 38 |
+
## Streamlit App
|
| 39 |
+
|
| 40 |
+
st.set_page_config(page_title="Resume Expert")
|
| 41 |
+
st.header("Resume Tracking System")
|
| 42 |
+
input_text=st.text_area("Job Description: ",key="input")
|
| 43 |
+
uploaded_file=st.file_uploader("Upload your resume(PDF)...",type=["pdf"])
|
| 44 |
+
|
| 45 |
+
|
| 46 |
+
if uploaded_file is not None:
|
| 47 |
+
st.write("PDF Uploaded Successfully")
|
| 48 |
+
|
| 49 |
+
|
| 50 |
+
submit1 = st.button("Tell Me About the Resume")
|
| 51 |
+
|
| 52 |
+
#submit2 = st.button("How Can I Improvise my Skills")
|
| 53 |
+
|
| 54 |
+
submit3 = st.button("Percentage match")
|
| 55 |
+
|
| 56 |
+
input_prompt1 = """
|
| 57 |
+
You are an experienced Technical Human Resource Manager,your task is to review the provided resume against the job description.
|
| 58 |
+
Please share your professional evaluation on whether the candidate's profile aligns with the role.
|
| 59 |
+
Highlight the strengths and weaknesses of the applicant in relation to the specified job requirements.
|
| 60 |
+
"""
|
| 61 |
+
|
| 62 |
+
input_prompt3 = """
|
| 63 |
+
You are an skilled ATS (Applicant Tracking System) scanner with a deep understanding of data science and ATS functionality,
|
| 64 |
+
your task is to evaluate the resume against the provided job description. give me the percentage of match if the resume matches
|
| 65 |
+
the job description. First the output should come as percentage and then keywords missing and last final thoughts.
|
| 66 |
+
"""
|
| 67 |
+
|
| 68 |
+
if submit1:
|
| 69 |
+
if uploaded_file is not None:
|
| 70 |
+
pdf_content=input_pdf_setup(uploaded_file)
|
| 71 |
+
response=get_gemini_response(input_prompt1,pdf_content,input_text)
|
| 72 |
+
st.subheader("The Repsonse is")
|
| 73 |
+
st.write(response)
|
| 74 |
+
else:
|
| 75 |
+
st.write("Please uplaod the resume")
|
| 76 |
+
|
| 77 |
+
elif submit3:
|
| 78 |
+
if uploaded_file is not None:
|
| 79 |
+
pdf_content=input_pdf_setup(uploaded_file)
|
| 80 |
+
response=get_gemini_response(input_prompt3,pdf_content,input_text)
|
| 81 |
+
st.subheader("The Repsonse is")
|
| 82 |
+
st.write(response)
|
| 83 |
+
else:
|
| 84 |
+
st.write("Please uplaod the resume")
|
requirements.txt
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
streamlit
|
| 2 |
+
google-generativeai
|
| 3 |
+
python-dotenv
|
| 4 |
+
pdf2image
|