Spaces:
Sleeping
Sleeping
Anushkabhat9
commited on
Upload app.py
Browse files
app.py
CHANGED
@@ -1,62 +1,80 @@
|
|
1 |
# -*- coding: utf-8 -*-
|
2 |
-
"""Untitled27.ipynb
|
3 |
-
|
4 |
-
Automatically generated by Colab.
|
5 |
-
|
6 |
-
Original file is located at
|
7 |
-
https://colab.research.google.com/drive/16VnJw-SMttFaPZi8gMJTp4k7YDqL-rP0
|
8 |
-
"""
|
9 |
-
|
10 |
import streamlit as st
|
11 |
import os
|
12 |
-
|
|
|
13 |
from similarity_score_refined import similarity_main
|
14 |
|
15 |
# Helper function to save uploaded files temporarily and return their paths
|
16 |
def save_uploaded_file(uploaded_file):
|
17 |
-
# Define the temporary file path
|
18 |
file_path = os.path.join("/tmp", uploaded_file.name)
|
19 |
-
|
20 |
-
# Write the uploaded file content to the path
|
21 |
with open(file_path, "wb") as f:
|
22 |
f.write(uploaded_file.getbuffer())
|
23 |
-
|
24 |
return file_path
|
25 |
|
26 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
27 |
st.title("Resume Tailoring with Google Generative AI")
|
28 |
-
st.
|
29 |
|
30 |
-
#
|
31 |
-
|
32 |
-
|
|
|
|
|
|
|
33 |
|
34 |
-
|
35 |
-
|
|
|
36 |
resume_path = save_uploaded_file(uploaded_resume)
|
37 |
job_description_path = save_uploaded_file(uploaded_job_description)
|
38 |
-
st.write(f"Files saved at: {resume_path} and {job_description_path}")
|
39 |
|
40 |
-
#
|
|
|
|
|
|
|
41 |
if st.button("Check Similarity Score"):
|
42 |
-
# Calculate the similarity score between resume and job description using similarity_main
|
43 |
similarity_score = similarity_main(resume_path, job_description_path)
|
44 |
-
|
45 |
if isinstance(similarity_score, str) and '%' in similarity_score:
|
46 |
-
|
47 |
|
48 |
-
# Display
|
49 |
-
st.
|
50 |
-
|
|
|
51 |
|
52 |
-
# Generate
|
53 |
-
|
54 |
-
|
55 |
-
# Call the model function with both file paths
|
56 |
-
generated_resume = Gemini_pro_main(resume_path, job_description_path) # Assuming this function returns the resume text
|
57 |
|
58 |
-
|
|
|
|
|
59 |
st.subheader("Generated Tailored Resume:")
|
60 |
st.write(generated_resume)
|
|
|
61 |
else:
|
62 |
-
st.warning("Please upload both the
|
|
|
1 |
# -*- coding: utf-8 -*-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
import streamlit as st
|
3 |
import os
|
4 |
+
import pandas as pd
|
5 |
+
from resume_generation_gemini_pro import Gemini_pro_main
|
6 |
from similarity_score_refined import similarity_main
|
7 |
|
8 |
# Helper function to save uploaded files temporarily and return their paths
|
9 |
def save_uploaded_file(uploaded_file):
|
|
|
10 |
file_path = os.path.join("/tmp", uploaded_file.name)
|
|
|
|
|
11 |
with open(file_path, "wb") as f:
|
12 |
f.write(uploaded_file.getbuffer())
|
|
|
13 |
return file_path
|
14 |
|
15 |
+
# Custom CSS for styling
|
16 |
+
st.markdown("""
|
17 |
+
<style>
|
18 |
+
.main {
|
19 |
+
background-color: #f5f5f5;
|
20 |
+
font-family: Arial, sans-serif;
|
21 |
+
}
|
22 |
+
h1, h2 {
|
23 |
+
color: #4B7BE5;
|
24 |
+
text-align: center;
|
25 |
+
}
|
26 |
+
.stButton>button {
|
27 |
+
background-color: #4B7BE5;
|
28 |
+
color: white;
|
29 |
+
font-size: 18px;
|
30 |
+
}
|
31 |
+
.stButton>button:hover {
|
32 |
+
background-color: #3A6FD8;
|
33 |
+
color: white;
|
34 |
+
}
|
35 |
+
</style>
|
36 |
+
""", unsafe_allow_html=True)
|
37 |
+
|
38 |
+
# Title and Description
|
39 |
st.title("Resume Tailoring with Google Generative AI")
|
40 |
+
st.markdown("### Upload your resume and job description to check similarity and generate a tailored resume.")
|
41 |
|
42 |
+
# Two columns for file uploaders
|
43 |
+
col1, col2 = st.columns(2)
|
44 |
+
with col1:
|
45 |
+
uploaded_resume = st.file_uploader("Upload Current Resume (.docx or .pdf)", type=["docx", "pdf"], key="resume")
|
46 |
+
with col2:
|
47 |
+
uploaded_job_description = st.file_uploader("Upload Job Description (.docx or .pdf)", type=["docx", "pdf"], key="job_description")
|
48 |
|
49 |
+
# Process if files are uploaded
|
50 |
+
if uploaded_resume and uploaded_job_description:
|
51 |
+
# Save files
|
52 |
resume_path = save_uploaded_file(uploaded_resume)
|
53 |
job_description_path = save_uploaded_file(uploaded_job_description)
|
|
|
54 |
|
55 |
+
# Similarity Score Section
|
56 |
+
st.markdown("---")
|
57 |
+
st.subheader("Check Resume Similarity")
|
58 |
+
|
59 |
if st.button("Check Similarity Score"):
|
|
|
60 |
similarity_score = similarity_main(resume_path, job_description_path)
|
|
|
61 |
if isinstance(similarity_score, str) and '%' in similarity_score:
|
62 |
+
similarity_score = float(similarity_score.replace('%', ''))
|
63 |
|
64 |
+
# Display Score and Bar Chart
|
65 |
+
st.markdown(f"### Similarity Score: {int(similarity_score)}%")
|
66 |
+
similarity_data = pd.DataFrame({'Score': [similarity_score]})
|
67 |
+
st.bar_chart(similarity_data)
|
68 |
|
69 |
+
# Generate Tailored Resume Section
|
70 |
+
st.markdown("---")
|
71 |
+
st.subheader("Generate Tailored Resume")
|
|
|
|
|
72 |
|
73 |
+
if st.button("Generate Tailored Resume"):
|
74 |
+
with st.spinner("Generating resume..."):
|
75 |
+
generated_resume = Gemini_pro_main(resume_path, job_description_path)
|
76 |
st.subheader("Generated Tailored Resume:")
|
77 |
st.write(generated_resume)
|
78 |
+
|
79 |
else:
|
80 |
+
st.warning("Please upload both the resume and job description files.")
|