Spaces:
Runtime error
Runtime error
Delete app.py
Browse files
app.py
DELETED
|
@@ -1,118 +0,0 @@
|
|
| 1 |
-
from dotenv import load_dotenv
|
| 2 |
-
|
| 3 |
-
load_dotenv()
|
| 4 |
-
import base64
|
| 5 |
-
import streamlit as st
|
| 6 |
-
import os
|
| 7 |
-
import io
|
| 8 |
-
from PIL import Image
|
| 9 |
-
import pdf2image
|
| 10 |
-
import google.generativeai as genai
|
| 11 |
-
|
| 12 |
-
genai.configure(api_key=os.getenv("GOOGLE_API_KEY"))
|
| 13 |
-
|
| 14 |
-
def get_gemini_response(input,pdf_cotent,prompt):
|
| 15 |
-
model=genai.GenerativeModel('gemini-pro-vision')
|
| 16 |
-
response=model.generate_content([input,pdf_content[0],prompt])
|
| 17 |
-
return response.text
|
| 18 |
-
|
| 19 |
-
def input_pdf_setup(uploaded_file):
|
| 20 |
-
if uploaded_file is not None:
|
| 21 |
-
## Convert the PDF to image
|
| 22 |
-
images=pdf2image.convert_from_bytes(uploaded_file.read())
|
| 23 |
-
|
| 24 |
-
first_page=images[0]
|
| 25 |
-
|
| 26 |
-
# Convert to bytes
|
| 27 |
-
img_byte_arr = io.BytesIO()
|
| 28 |
-
first_page.save(img_byte_arr, format='JPEG')
|
| 29 |
-
img_byte_arr = img_byte_arr.getvalue()
|
| 30 |
-
|
| 31 |
-
pdf_parts = [
|
| 32 |
-
{
|
| 33 |
-
"mime_type": "image/jpeg",
|
| 34 |
-
"data": base64.b64encode(img_byte_arr).decode() # encode to base64
|
| 35 |
-
}
|
| 36 |
-
]
|
| 37 |
-
return pdf_parts
|
| 38 |
-
else:
|
| 39 |
-
raise FileNotFoundError("No file uploaded")
|
| 40 |
-
|
| 41 |
-
## Streamlit App
|
| 42 |
-
|
| 43 |
-
st.set_page_config(page_title="ATS Resume EXpert")
|
| 44 |
-
st.header("ATS Tracking System")
|
| 45 |
-
input_text=st.text_area("Job Description: ",key="input")
|
| 46 |
-
with st.sidebar:
|
| 47 |
-
st.title("Menu:")
|
| 48 |
-
uploaded_file=st.file_uploader("Upload your resume(PDF)...",type=["pdf"])
|
| 49 |
-
if uploaded_file is not None:
|
| 50 |
-
st.success("Done")
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
submit1 = st.button("Tell Me About the Resume")
|
| 54 |
-
|
| 55 |
-
#submit2 = st.button("How Can I Improvise my Skills")
|
| 56 |
-
|
| 57 |
-
submit3 = st.button("Percentage match")
|
| 58 |
-
|
| 59 |
-
input_prompt1 = """
|
| 60 |
-
You are an experienced Technical Human Resource Manager,your task is to review the provided resume against the job description.
|
| 61 |
-
Please share your professional evaluation on whether the candidate's profile aligns with the role.
|
| 62 |
-
Highlight the strengths and weaknesses of the applicant in relation to the specified job requirements.
|
| 63 |
-
"""
|
| 64 |
-
|
| 65 |
-
input_prompt3 = """
|
| 66 |
-
You are an skilled ATS (Applicant Tracking System) scanner with a deep understanding of data science and ATS functionality,
|
| 67 |
-
your task is to evaluate the resume against the provided job description. give me the percentage of match if the resume matches
|
| 68 |
-
the job description. First the output should come as percentage and then keywords missing and last final thoughts.
|
| 69 |
-
"""
|
| 70 |
-
|
| 71 |
-
if submit1 and uploaded_file is not None and input_text:
|
| 72 |
-
pdf_content=input_pdf_setup(uploaded_file)
|
| 73 |
-
|
| 74 |
-
response=get_gemini_response(input_text,pdf_content,input_prompt1)
|
| 75 |
-
|
| 76 |
-
st.subheader("Evaluation of the Resume")
|
| 77 |
-
|
| 78 |
-
selected_option = "Clear Uploaded Files"
|
| 79 |
-
|
| 80 |
-
uploaded_file = None
|
| 81 |
-
|
| 82 |
-
st.write(response)
|
| 83 |
-
st.write("Uploaded files cleared. Because While Rendersing Response It will Automatically Clear")
|
| 84 |
-
|
| 85 |
-
elif submit3 and uploaded_file is not None and input_text:
|
| 86 |
-
pdf_content=input_pdf_setup(uploaded_file)
|
| 87 |
-
|
| 88 |
-
response=get_gemini_response(input_text,pdf_content,input_prompt3)
|
| 89 |
-
|
| 90 |
-
st.subheader("Matching Percentage and Analysis")
|
| 91 |
-
|
| 92 |
-
selected_option = "Clear Uploaded Files"
|
| 93 |
-
|
| 94 |
-
|
| 95 |
-
uploaded_file = None
|
| 96 |
-
|
| 97 |
-
st.write(response)
|
| 98 |
-
st.write("Uploaded files cleared. Because While Rendersing Response It will Automatically Clear")
|
| 99 |
-
else:
|
| 100 |
-
st.write("Please upload the resume and provide the job description.")
|
| 101 |
-
|
| 102 |
-
st.sidebar.markdown("### Additional Options:")
|
| 103 |
-
selected_option = st.sidebar.selectbox("Select an option", ["View Uploaded Resume", "Clear Uploaded Files"])
|
| 104 |
-
|
| 105 |
-
|
| 106 |
-
if selected_option == "View Uploaded Resume" and uploaded_file is not None:
|
| 107 |
-
st.markdown("### Uploaded Resume")
|
| 108 |
-
# Store the PDF content
|
| 109 |
-
pdf_content = uploaded_file.read()
|
| 110 |
-
# Convert the PDF to images
|
| 111 |
-
images = pdf2image.convert_from_bytes(pdf_content)
|
| 112 |
-
# Display each page as an image
|
| 113 |
-
for i, page in enumerate(images):
|
| 114 |
-
st.image(page, caption=f"Page {i+1}", use_column_width=True)
|
| 115 |
-
|
| 116 |
-
elif selected_option == "Clear Uploaded Files":
|
| 117 |
-
st.write("Uploaded files cleared.")
|
| 118 |
-
uploaded_file = None
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|