Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -68,82 +68,116 @@ def display_resume(file, index):
|
|
| 68 |
# Streamlit page configuration for better layout
|
| 69 |
st.set_page_config(page_title="ATS Resume Evaluation System", layout="wide")
|
| 70 |
|
| 71 |
-
# Custom styles for headers and
|
| 72 |
st.markdown("""
|
| 73 |
<style>
|
| 74 |
.title {
|
| 75 |
text-align: center;
|
| 76 |
-
font-size:
|
| 77 |
font-weight: bold;
|
| 78 |
color: #4CAF50;
|
|
|
|
| 79 |
}
|
| 80 |
.subtitle {
|
| 81 |
text-align: center;
|
| 82 |
-
font-size:
|
| 83 |
color: #6c757d;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 84 |
}
|
| 85 |
.button {
|
| 86 |
background-color: #4CAF50;
|
| 87 |
color: white;
|
| 88 |
-
font-size:
|
| 89 |
-
padding:
|
| 90 |
-
border-radius:
|
| 91 |
width: 100%;
|
| 92 |
margin: 20px 0;
|
|
|
|
| 93 |
}
|
| 94 |
.button:hover {
|
| 95 |
background-color: #45a049;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 96 |
}
|
| 97 |
</style>
|
| 98 |
""", unsafe_allow_html=True)
|
| 99 |
|
| 100 |
-
#
|
| 101 |
-
st.
|
| 102 |
-
|
| 103 |
-
|
| 104 |
-
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
|
| 111 |
-
|
| 112 |
-
|
| 113 |
-
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
|
| 125 |
-
|
| 126 |
-
|
| 127 |
-
|
| 128 |
-
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
|
| 135 |
-
|
| 136 |
-
|
| 137 |
-
|
| 138 |
-
|
| 139 |
-
|
| 140 |
-
|
| 141 |
-
|
| 142 |
-
|
| 143 |
-
|
| 144 |
-
|
| 145 |
-
|
| 146 |
-
|
|
|
|
|
|
|
| 147 |
else:
|
| 148 |
-
st.error("
|
| 149 |
-
|
|
|
|
|
|
| 68 |
# Streamlit page configuration for better layout
|
| 69 |
st.set_page_config(page_title="ATS Resume Evaluation System", layout="wide")
|
| 70 |
|
| 71 |
+
# Custom styles for headers, buttons, and sections
|
| 72 |
st.markdown("""
|
| 73 |
<style>
|
| 74 |
.title {
|
| 75 |
text-align: center;
|
| 76 |
+
font-size: 40px;
|
| 77 |
font-weight: bold;
|
| 78 |
color: #4CAF50;
|
| 79 |
+
font-family: 'Arial', sans-serif;
|
| 80 |
}
|
| 81 |
.subtitle {
|
| 82 |
text-align: center;
|
| 83 |
+
font-size: 22px;
|
| 84 |
color: #6c757d;
|
| 85 |
+
font-family: 'Arial', sans-serif;
|
| 86 |
+
}
|
| 87 |
+
.section-header {
|
| 88 |
+
font-size: 24px;
|
| 89 |
+
color: #333333;
|
| 90 |
+
margin-top: 20px;
|
| 91 |
+
margin-bottom: 10px;
|
| 92 |
+
font-family: 'Arial', sans-serif;
|
| 93 |
}
|
| 94 |
.button {
|
| 95 |
background-color: #4CAF50;
|
| 96 |
color: white;
|
| 97 |
+
font-size: 18px;
|
| 98 |
+
padding: 12px 24px;
|
| 99 |
+
border-radius: 8px;
|
| 100 |
width: 100%;
|
| 101 |
margin: 20px 0;
|
| 102 |
+
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
|
| 103 |
}
|
| 104 |
.button:hover {
|
| 105 |
background-color: #45a049;
|
| 106 |
+
cursor: pointer;
|
| 107 |
+
}
|
| 108 |
+
.file-upload {
|
| 109 |
+
background-color: #f8f8f8;
|
| 110 |
+
padding: 20px;
|
| 111 |
+
border-radius: 10px;
|
| 112 |
+
border: 1px solid #e0e0e0;
|
| 113 |
+
}
|
| 114 |
+
.resume-content {
|
| 115 |
+
background-color: #f1f1f1;
|
| 116 |
+
border-radius: 8px;
|
| 117 |
+
padding: 15px;
|
| 118 |
+
margin-top: 10px;
|
| 119 |
+
}
|
| 120 |
+
.highlight {
|
| 121 |
+
font-weight: bold;
|
| 122 |
+
color: #4CAF50;
|
| 123 |
+
font-size: 16px;
|
| 124 |
+
}
|
| 125 |
+
.spinner {
|
| 126 |
+
margin-top: 20px;
|
| 127 |
}
|
| 128 |
</style>
|
| 129 |
""", unsafe_allow_html=True)
|
| 130 |
|
| 131 |
+
# Remove navigation and use centered layout
|
| 132 |
+
st.markdown('<div class="title">ππ Resume Evaluation System π</div>', unsafe_allow_html=True) # Updated title with both emojis
|
| 133 |
+
st.markdown('<div class="subtitle">Upload your resume and job description to evaluate match with job requirements</div>', unsafe_allow_html=True)
|
| 134 |
+
|
| 135 |
+
# Section for Job Description
|
| 136 |
+
job_description = st.text_area("Job Description:", height=200, placeholder="Paste the job description here...", label_visibility="collapsed")
|
| 137 |
+
|
| 138 |
+
# Section for uploading resumes
|
| 139 |
+
st.markdown('<div class="section-header">Upload Resumes (PDF or DOCX)</div>', unsafe_allow_html=True)
|
| 140 |
+
resumes = st.file_uploader("Upload your resumes", type=["pdf", "docx"], accept_multiple_files=True)
|
| 141 |
+
|
| 142 |
+
if resumes:
|
| 143 |
+
st.write("Uploaded Resumes:")
|
| 144 |
+
for index, resume in enumerate(resumes):
|
| 145 |
+
st.write(f"π {resume.name}")
|
| 146 |
+
display_resume(resume, index) # Passing the index to ensure unique keys
|
| 147 |
+
|
| 148 |
+
# Section for analysis button
|
| 149 |
+
st.markdown('<div class="section-header">Analyze Resumes</div>', unsafe_allow_html=True)
|
| 150 |
+
if st.button("Analyze Resumes", key="analyze_button", help="Click to analyze the uploaded resumes against the job description"):
|
| 151 |
+
if job_description and resumes:
|
| 152 |
+
if len(resumes) <= 10: # Limit to a maximum of 10 resumes
|
| 153 |
+
with st.spinner("Analyzing..."):
|
| 154 |
+
for index, resume in enumerate(resumes):
|
| 155 |
+
resume.seek(0) # Reset the file pointer
|
| 156 |
+
file_type = resume.name.split('.')[-1].lower()
|
| 157 |
+
|
| 158 |
+
# Extract resume text based on file type
|
| 159 |
+
if file_type == 'pdf':
|
| 160 |
+
resume_text = extract_text_from_pdf(resume)
|
| 161 |
+
elif file_type == 'docx':
|
| 162 |
+
resume_text = extract_text_from_docx(resume)
|
| 163 |
+
|
| 164 |
+
# Analyze the resume text
|
| 165 |
+
analysis = analyze_documents(resume_text, job_description)
|
| 166 |
+
|
| 167 |
+
if "candidates" in analysis:
|
| 168 |
+
for candidate in analysis["candidates"]:
|
| 169 |
+
if "content" in candidate and "parts" in candidate["content"]:
|
| 170 |
+
for part in candidate["content"]["parts"]:
|
| 171 |
+
response_text = part["text"]
|
| 172 |
+
|
| 173 |
+
# Highlight match percentage by looking for the keyword "match percentage"
|
| 174 |
+
response_text = response_text.replace("Match Percentage:", '<span class="highlight">Match Percentage:</span>')
|
| 175 |
+
|
| 176 |
+
# Display the analysis results
|
| 177 |
+
st.markdown(response_text, unsafe_allow_html=True)
|
| 178 |
+
|
| 179 |
+
st.success("Analysis Complete!")
|
| 180 |
else:
|
| 181 |
+
st.error("You can upload a maximum of 10 resumes.")
|
| 182 |
+
else:
|
| 183 |
+
st.error("Please enter the job description and upload at least one resume.")
|