DreamStream-1 commited on
Commit
3eec01c
Β·
verified Β·
1 Parent(s): 5036f94

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +89 -55
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 buttons
72
  st.markdown("""
73
  <style>
74
  .title {
75
  text-align: center;
76
- font-size: 36px;
77
  font-weight: bold;
78
  color: #4CAF50;
 
79
  }
80
  .subtitle {
81
  text-align: center;
82
- font-size: 18px;
83
  color: #6c757d;
 
 
 
 
 
 
 
 
84
  }
85
  .button {
86
  background-color: #4CAF50;
87
  color: white;
88
- font-size: 16px;
89
- padding: 10px 20px;
90
- border-radius: 5px;
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
- # Sidebar with instructions and navigation
101
- st.sidebar.title("Navigation")
102
- page = st.sidebar.radio("Go to", ["Resume Analyzer"])
103
-
104
- if page == "Resume Analyzer":
105
- st.markdown('<div class="title">πŸ“„πŸ” ATS Resume Evaluation System</div>', unsafe_allow_html=True)
106
- st.markdown('<div class="subtitle">Upload your resume and job description to evaluate match with job requirements</div>', unsafe_allow_html=True)
107
-
108
- job_description = st.text_area("Job Description:", height=200)
109
- resumes = st.file_uploader("Upload your resumes (PDF or DOCX)", type=["pdf", "docx"], accept_multiple_files=True)
110
-
111
- if resumes:
112
- st.write("Uploaded Resumes:")
113
- for index, resume in enumerate(resumes):
114
- st.write(f"πŸ“„ {resume.name}")
115
- display_resume(resume, index) # Passing the index to ensure unique keys
116
-
117
- # Analyze resumes button with a custom style
118
- if st.button("Analyze Resumes", key="analyze_button"):
119
- if job_description and resumes:
120
- if len(resumes) <= 10: # Limit to a maximum of 10 resumes
121
- with st.spinner("Analyzing..."):
122
- for index, resume in enumerate(resumes):
123
- resume.seek(0) # Reset the file pointer
124
- file_type = resume.name.split('.')[-1].lower()
125
-
126
- # Extract resume text based on file type
127
- if file_type == 'pdf':
128
- resume_text = extract_text_from_pdf(resume)
129
- elif file_type == 'docx':
130
- resume_text = extract_text_from_docx(resume)
131
-
132
- # Analyze the resume text
133
- analysis = analyze_documents(resume_text, job_description)
134
-
135
- if "candidates" in analysis:
136
- for candidate in analysis["candidates"]:
137
- if "content" in candidate and "parts" in candidate["content"]:
138
- for part in candidate["content"]["parts"]:
139
- response_text = part["text"]
140
-
141
- # Display the analysis results
142
- st.markdown(response_text)
143
-
144
- st.success("Analysis Complete!")
145
- else:
146
- st.error("You can upload a maximum of 10 resumes.")
 
 
147
  else:
148
- st.error("Please enter the job description and upload at least one resume.")
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.")