Aashi commited on
Commit
da6df47
·
verified ·
1 Parent(s): d81e328

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +84 -0
app.py ADDED
@@ -0,0 +1,84 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import os
3
+ import io
4
+ import base64
5
+ from PIL import Image
6
+ import pdf2image
7
+ import google.generativeai as genai
8
+
9
+ genai.configure(api_key = os.getenv('GEN_AI_API_KEY'))
10
+
11
+ def get_gemini_response(input, pdf_content, prompt):
12
+ model.genai.GenerativeModel('gemini-pro-vision')
13
+ response = model.generate_content([input, pdf_content[0], prompt])
14
+ return response.text
15
+
16
+ def input_pdf_setup(uploaded_file):
17
+ if uploaded_file is not None:
18
+ ## convert pdf to image
19
+ images = pdf2image.convert_from_bytes(uploaded_file.read())
20
+ first_page = images[0]
21
+ # take image and convert into bytes
22
+ img_byte_arr = io.BytesIO()
23
+ first_page.save(img_byte_arr, format = 'JPEG')
24
+ img_byte_arr = img_byte_arr.getvalue()
25
+
26
+ pdf_parts = [
27
+ {
28
+ "mime-type": "image/jpeg",
29
+ "data": base64.b64encode(img_byte_arr).decode()
30
+ }
31
+ ]
32
+ return pdf_parts
33
+ else:
34
+ raise FileNotFoundError("No File uploaded")
35
+
36
+
37
+ # Streamlit app
38
+ st.set_page_config(page_title = "ATS Resume Analyser")
39
+ st.header("ATS Tracker")
40
+ input_text = st.text_area("Job Description: ", key = "input")
41
+ uploaded_file = st.file_uploader("Upload your resume in pdf format...", type = ["pdf"])
42
+
43
+ if uploaded_fileis not None:
44
+ st.write("PDF uploaded successfully ")
45
+
46
+ submit1 = st.button("Tell me about the resume")
47
+ # submit2 = st.button("How can I improve my skills")
48
+ # submit3 = st.button("What are the missing keywords in my resume")
49
+ submit3 = st.button("Percentage match to Job description")
50
+
51
+ input_prompt1 = """
52
+ You are an experienced Technical Human Resource Manager with tech experience with experience in data science, LLMs,
53
+ machine learning, deep learning, devops and data analyst,
54
+ your task is to review the provided resume and share your professional evaluation on
55
+ whether the candidate's profile aligns with the Job description. Highlight the strengths and weakness of the applicant
56
+ in relation to the specified job description
57
+
58
+ """
59
+ input_prompt3 = """
60
+ You are skilled ATS (Application Tracking System) scanner with a deep understanding of any one job role data science, LLMs,
61
+ machine learning, deep learning, devops, data analyst and deep ATS functionality. Your task is to evaluate the given resume against provided job description
62
+ Give me a percentage match if the resume matches the job description and should come as a percentage followed by keywords missing in the resume.
63
+
64
+ """
65
+ if submit1:
66
+ if uploaded_file is not None:
67
+ pdf_content = input_pdf_setup(uploaded_file)
68
+ response = get_gemini_response(input_text, pdf_content, input_prompt1)
69
+ st.subheader("The response is: ")
70
+ st.write(response)
71
+ else:
72
+ st.write("Please upload the resume")
73
+
74
+ elif submit3:
75
+ if uploaded_file is not None:
76
+ pdf_content = input_pdf_setup(uploaded_file)
77
+ response = get_gemini_response(input_text, pdf_content,input_prompt3)
78
+ st.subheader("The response is: ")
79
+ st.write(response)
80
+ else:
81
+ st.write("Please upload the resume")
82
+
83
+
84
+