honeyangelhp commited on
Commit
5b7a17e
Β·
verified Β·
1 Parent(s): 7e03b89

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +71 -58
app.py CHANGED
@@ -13,7 +13,7 @@ st.title("Resume Screening Assistance")
13
  required_skills = ["Python", "Machine Learning", "Cloud (AWS/Azure)", "Data Analysis", "React", "Docker"]
14
 
15
  # Job Description Input
16
- job_description = st.text_area("Paste the job description below:")
17
 
18
  # Upload Resumes
19
  uploaded_files = st.file_uploader("Upload your resumes (PDF only):", type="pdf", accept_multiple_files=True)
@@ -31,67 +31,80 @@ if st.button("Submit"):
31
  current_file_placeholder = st.empty()
32
 
33
  for idx, file in enumerate(uploaded_files, start=1):
34
- # Update the current file being processed in the placeholder
35
- current_file_placeholder.text(f"Currently processing: {file.name}")
36
-
37
- # Process the file
38
- text = ExtractPDFText(file)
39
- ats_score = calculateATSscore(text, job_description)
40
- skill_analysis = skill_gap_analysis(text, required_skills)
41
- feedback = modelFeedback(ats_score, text)
42
- resumes_data.append({
43
- "name": file.name,
44
- "ATS Score": ats_score,
45
- "Skills Present": skill_analysis['present'],
46
- "Missing Skills": skill_analysis['missing'],
47
- "Feedback": feedback
48
- })
49
-
50
- # Update progress bar
51
- progress_bar.progress(idx / total_resumes)
 
 
 
 
 
 
 
 
 
 
52
 
53
  # Clear the current file placeholder after processing all files
54
  current_file_placeholder.empty()
55
 
56
- # Sort resumes by ATS score
57
- sorted_resumes = sorted(resumes_data, key=lambda x: x["ATS Score"], reverse=True)
58
-
59
- # Add rankings
60
- for rank, resume in enumerate(sorted_resumes, start=1):
61
- resume["Rank"] = rank
62
-
63
- # Display results
64
- st.subheader("Top Matches:")
65
- for resume in sorted_resumes:
66
- st.write(f"#### Rank {resume['Rank']}: {resume['name']}")
67
- st.write(f"**ATS Score:** {resume['ATS Score']*100:.0f}%")
68
- st.write("**Missing Skills:**", ", ".join(resume["Missing Skills"]) if resume["Missing Skills"] else "None")
69
- st.write("**Feedback:**")
70
- st.markdown(f"> {resume['Feedback']}")
71
- st.write("---")
72
-
73
- # Skill Gap Analysis Table
74
- st.subheader("Skill Gap Analysis")
75
- for resume in sorted_resumes:
76
- st.write(f"**{resume['name']} (Rank {resume['Rank']})**")
77
- skill_data = {
78
- "Required Skills": required_skills,
79
- "Present in Resume": ["βœ…" if skill in resume["Skills Present"] else "❌" for skill in required_skills],
80
- "Missing": [skill if skill in resume["Missing Skills"] else "β€”" for skill in required_skills]
81
- }
82
- df = pd.DataFrame(skill_data)
83
- st.table(df)
84
-
85
- # Visualize ATS Scores with Rankings
86
- st.subheader("ATS Score Distribution")
87
- names_with_ranks = [f"Rank {r['Rank']}: {r['name']}" for r in sorted_resumes]
88
- scores = [r["ATS Score"]*100 for r in sorted_resumes]
89
- plt.figure(figsize=(8, 5))
90
- plt.bar(names_with_ranks, scores)
91
- plt.title("ATS Scores by Resume (Ranked)")
92
- plt.ylabel("ATS Score (%)")
93
- plt.xticks(rotation=45, ha="right")
94
- st.pyplot(plt)
 
 
 
95
 
96
  else:
97
  st.warning("Please upload resumes and provide a job description before submitting.")
 
13
  required_skills = ["Python", "Machine Learning", "Cloud (AWS/Azure)", "Data Analysis", "React", "Docker"]
14
 
15
  # Job Description Input
16
+ job_description = st.text_area("Paste the job description below:", placeholder="Enter the job description here...")
17
 
18
  # Upload Resumes
19
  uploaded_files = st.file_uploader("Upload your resumes (PDF only):", type="pdf", accept_multiple_files=True)
 
31
  current_file_placeholder = st.empty()
32
 
33
  for idx, file in enumerate(uploaded_files, start=1):
34
+ try:
35
+ # Update the current file being processed in the placeholder
36
+ current_file_placeholder.text(f"Currently processing: {file.name}")
37
+
38
+ # Extract resume text
39
+ text = ExtractPDFText(file)
40
+
41
+ # Calculate ATS score and skill gap analysis
42
+ ats_score = calculateATSscore(text, job_description)
43
+ skill_analysis = skill_gap_analysis(text, required_skills)
44
+
45
+ # Generate AI feedback
46
+ feedback = modelFeedback(ats_score, text, job_description)
47
+
48
+ # Append results for each resume
49
+ resumes_data.append({
50
+ "name": file.name,
51
+ "ATS Score": ats_score,
52
+ "Skills Present": skill_analysis["present"],
53
+ "Missing Skills": skill_analysis["missing"],
54
+ "Feedback": feedback
55
+ })
56
+
57
+ # Update progress bar
58
+ progress_bar.progress(idx / total_resumes)
59
+
60
+ except Exception as e:
61
+ st.error(f"Error processing {file.name}: {e}")
62
 
63
  # Clear the current file placeholder after processing all files
64
  current_file_placeholder.empty()
65
 
66
+ if resumes_data:
67
+ # Sort resumes by ATS score
68
+ sorted_resumes = sorted(resumes_data, key=lambda x: x["ATS Score"], reverse=True)
69
+
70
+ # Add rankings
71
+ for rank, resume in enumerate(sorted_resumes, start=1):
72
+ resume["Rank"] = rank
73
+
74
+ # Display results
75
+ st.subheader("Top Matches:")
76
+ for resume in sorted_resumes:
77
+ st.write(f"#### Rank {resume['Rank']}: {resume['name']}")
78
+ st.write(f"**ATS Score:** {resume['ATS Score']*100:.0f}%")
79
+ st.write("**Missing Skills:**", ", ".join(resume["Missing Skills"]) if resume["Missing Skills"] else "None")
80
+ st.write("**Feedback:**")
81
+ st.markdown(f"> {resume['Feedback']}")
82
+ st.write("---")
83
+
84
+ # Skill Gap Analysis Table
85
+ st.subheader("Skill Gap Analysis")
86
+ for resume in sorted_resumes:
87
+ st.write(f"**{resume['name']} (Rank {resume['Rank']})**")
88
+ skill_data = {
89
+ "Required Skills": required_skills,
90
+ "Present in Resume": ["βœ…" if skill in resume["Skills Present"] else "❌" for skill in required_skills],
91
+ "Missing": [skill if skill in resume["Missing Skills"] else "β€”" for skill in required_skills]
92
+ }
93
+ df = pd.DataFrame(skill_data)
94
+ st.table(df)
95
+
96
+ # Visualize ATS Scores with Rankings
97
+ st.subheader("ATS Score Distribution")
98
+ names_with_ranks = [f"Rank {r['Rank']}: {r['name']}" for r in sorted_resumes]
99
+ scores = [r["ATS Score"]*100 for r in sorted_resumes]
100
+ plt.figure(figsize=(8, 5))
101
+ plt.bar(names_with_ranks, scores, color='skyblue')
102
+ plt.title("ATS Scores by Resume (Ranked)")
103
+ plt.ylabel("ATS Score (%)")
104
+ plt.xticks(rotation=45, ha="right")
105
+ st.pyplot(plt)
106
+ else:
107
+ st.error("No resumes could be processed. Please check the uploaded files.")
108
 
109
  else:
110
  st.warning("Please upload resumes and provide a job description before submitting.")