Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -145,6 +145,24 @@ def display_score(similarity, colors):
|
|
145 |
ax.axis('equal')
|
146 |
st.pyplot(fig)
|
147 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
148 |
|
149 |
# Process if files are uploaded
|
150 |
if uploaded_resume and uploaded_job_description:
|
@@ -186,6 +204,16 @@ if uploaded_resume and uploaded_job_description:
|
|
186 |
</script>
|
187 |
""", unsafe_allow_html=True)
|
188 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
189 |
with st.spinner("Computing Match"):
|
190 |
similarity_score, pie_colors = get_score(resume_path, job_description_path)
|
191 |
display_score(similarity_score, pie_colors)
|
@@ -207,8 +235,7 @@ if uploaded_resume and uploaded_job_description:
|
|
207 |
file_name="tailored_resume.docx",
|
208 |
mime="application/vnd.openxmlformats-officedocument.wordprocessingml.document"
|
209 |
)
|
210 |
-
|
211 |
-
|
212 |
else:
|
213 |
st.warning("Please upload both the resume and job description files.")
|
214 |
|
|
|
145 |
ax.axis('equal')
|
146 |
st.pyplot(fig)
|
147 |
|
148 |
+
def save_docx_as_pdf(doc_content, output_path='output.pdf'):
|
149 |
+
# Save document content as a .docx file
|
150 |
+
temp_doc_path = 'temp.docx'
|
151 |
+
doc = Document()
|
152 |
+
doc.add_paragraph(doc_content)
|
153 |
+
doc.save(temp_doc_path)
|
154 |
+
|
155 |
+
# Convert .docx to PDF
|
156 |
+
from docx2pdf import convert
|
157 |
+
convert(temp_doc_path, output_path)
|
158 |
+
os.remove(temp_doc_path)
|
159 |
+
|
160 |
+
def display_doc_as_image(pdf_path):
|
161 |
+
images = convert_from_path(pdf_path)
|
162 |
+
for img in images:
|
163 |
+
buf = BytesIO()
|
164 |
+
img.save(buf, format="PNG")
|
165 |
+
st.image(buf)
|
166 |
|
167 |
# Process if files are uploaded
|
168 |
if uploaded_resume and uploaded_job_description:
|
|
|
204 |
</script>
|
205 |
""", unsafe_allow_html=True)
|
206 |
|
207 |
+
col1, col2 = st.columns(2)
|
208 |
+
with col1:
|
209 |
+
st.markdown("### Uploaded Resume:")
|
210 |
+
save_docx_as_pdf(uploaded_resume.getvalue().decode('utf-8'), 'uploaded_resume.pdf')
|
211 |
+
display_doc_as_image('uploaded_resume.pdf')
|
212 |
+
with col2:
|
213 |
+
st.markdown("### Tailored Resume:")
|
214 |
+
save_docx_as_pdf(generated_resume, 'tailored_resume.pdf')
|
215 |
+
display_doc_as_image('tailored_resume.pdf')
|
216 |
+
|
217 |
with st.spinner("Computing Match"):
|
218 |
similarity_score, pie_colors = get_score(resume_path, job_description_path)
|
219 |
display_score(similarity_score, pie_colors)
|
|
|
235 |
file_name="tailored_resume.docx",
|
236 |
mime="application/vnd.openxmlformats-officedocument.wordprocessingml.document"
|
237 |
)
|
238 |
+
|
|
|
239 |
else:
|
240 |
st.warning("Please upload both the resume and job description files.")
|
241 |
|