udayr commited on
Commit
bb4762b
·
verified ·
1 Parent(s): a856ffb

Upload 2 files

Browse files
Files changed (2) hide show
  1. app.py +102 -0
  2. requirements.txt +5 -0
app.py ADDED
@@ -0,0 +1,102 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # importing libraries
2
+ import streamlit as st
3
+ import google.generativeai as genai
4
+ from dotenv import load_dotenv
5
+ import pdf2image
6
+ from PIL import Image
7
+ import os
8
+ import io
9
+ import base64
10
+
11
+
12
+ # loading environment variables
13
+ load_dotenv()
14
+
15
+ # Google API KEY configuration
16
+ genai.configure(api_key=os.getenv('GOOGLE_API_KEY'))
17
+
18
+ # generating response from Gemini API
19
+ def get_gemini_response(input, pdf_content, prompt):
20
+ model = genai.GenerativeModel('gemini-pro-vision')
21
+ response = model.generate_content([input, pdf_content[0],prompt])
22
+ return response.text
23
+
24
+ # taking PDF and converting into image format
25
+ def input_pdf_setup(uploaded_file):
26
+ if uploaded_file is not None:
27
+
28
+ # convert PDF to image format
29
+ images = pdf2image.convert_from_bytes(uploaded_file.read())
30
+ # content from 1st page
31
+ first_page = images[0]
32
+
33
+ # convert to bytes
34
+ img_bytes_arr = io.BytesIO()
35
+ first_page.save(img_bytes_arr, format='JPEG')
36
+ img_bytes_arr = img_bytes_arr.getvalue()
37
+
38
+ pdf_parts = [{
39
+ "mime_type": "image/jpeg",
40
+ "data" : base64.b64encode(img_bytes_arr).decode() # encode to base64
41
+ }]
42
+ return pdf_parts
43
+ else:
44
+ raise FileNotFoundError("No file uploaded")
45
+
46
+ # streamlit application
47
+
48
+ st.set_page_config(page_title="ATS Resume Expert")
49
+ st.header("ATS Tracking System")
50
+ input_text = st.text_area("Job Description: ", key="input")
51
+ uploaded_file = st.file_uploader("Upload your resume(PDF)...", type=['pdf'])
52
+
53
+ if uploaded_file is not None:
54
+ st.write("PDF Uploaded Successfully")
55
+
56
+
57
+ # creating buttons
58
+ submit1 = st.button("Tell Me About the Resume")
59
+ # submit2 = st.button("How Can I Improvise my skills?")
60
+ submit3 = st.button("Percentage match")
61
+
62
+
63
+ input_prompt1 = """
64
+ You are an experienced Technical Human Resource Manager,your task is to review the provided resume against the job description.
65
+ Please share your professional evaluation on whether the candidate's profile aligns with the role.
66
+ Highlight the strengths and weaknesses of the applicant in relation to the specified job requirements.
67
+ """
68
+ input_prompt3 = """
69
+ You are an skilled ATS (Applicant Tracking System) scanner with a deep understanding of data science and ATS functionality,
70
+ your task is to evaluate the resume against the provided job description. give me the percentage of match if the resume matches
71
+ the job description. First the output should come as percentage and then keywords missing and last final thoughts.
72
+ """
73
+
74
+ # for submit1
75
+ if submit1:
76
+ if uploaded_file is not None:
77
+ pdf_content = input_pdf_setup(uploaded_file)
78
+ response = get_gemini_response(input_prompt1, pdf_content, input_text)
79
+ st.subheader("The Response is")
80
+ st.write(response)
81
+ else:
82
+ st.write("Please upload the resume")
83
+
84
+ # for submit3
85
+ elif submit3:
86
+ if uploaded_file is not None:
87
+ pdf_content = input_pdf_setup(uploaded_file)
88
+ response = get_gemini_response(input_prompt3, pdf_content, input_text)
89
+ st.subheader("The Response is")
90
+ st.write(response)
91
+ else:
92
+ st.write("Please upload the resume")
93
+
94
+
95
+
96
+
97
+
98
+
99
+
100
+
101
+
102
+
requirements.txt ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ google-generativeai
2
+ streamlit
3
+ python-dotenv
4
+ pdf2image
5
+