Spaces:
Sleeping
Sleeping
Upload 3 files
Browse files- .env +1 -0
- app.py +61 -0
- requirements.txt +4 -0
.env
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
GOOGLE_API_KEY = "AIzaSyCbeXGU_7qWtmY6pXZoff-T_-aNli25x3Y"
|
app.py
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from dotenv import load_dotenv
|
| 2 |
+
import streamlit as st
|
| 3 |
+
from pdf2image import convert_from_bytes
|
| 4 |
+
import os
|
| 5 |
+
import google.generativeai as genai
|
| 6 |
+
from PIL import Image
|
| 7 |
+
|
| 8 |
+
load_dotenv()
|
| 9 |
+
|
| 10 |
+
genai.configure(api_key=os.getenv("GOOGLE_API_KEY"))
|
| 11 |
+
|
| 12 |
+
def get_gemini_response(input,image,query=None):
|
| 13 |
+
model = genai.GenerativeModel("gemini-pro-vision")
|
| 14 |
+
if query is not None:
|
| 15 |
+
response = model.generate_content([input,image,query])
|
| 16 |
+
else:
|
| 17 |
+
response = model.generate_content([input,image])
|
| 18 |
+
|
| 19 |
+
return response.text
|
| 20 |
+
|
| 21 |
+
def input_resumedata(uploaded_file):
|
| 22 |
+
if uploaded_file is not None:
|
| 23 |
+
pdf_bytes = uploaded_file.read()
|
| 24 |
+
images = convert_from_bytes(pdf_bytes, first_page=1, last_page=1)
|
| 25 |
+
return images[0]
|
| 26 |
+
else:
|
| 27 |
+
raise FileNotFoundError("No file uploaded")
|
| 28 |
+
|
| 29 |
+
st.set_page_config(page_title="Resume Data Extractor")
|
| 30 |
+
|
| 31 |
+
st.header("Resume Data")
|
| 32 |
+
|
| 33 |
+
uploaded_file = st.file_uploader("Choose a file...", type=["pdf"])
|
| 34 |
+
|
| 35 |
+
image_data = None
|
| 36 |
+
|
| 37 |
+
if uploaded_file is not None:
|
| 38 |
+
image_data = input_resumedata(uploaded_file)
|
| 39 |
+
st.image(image_data, caption='Resume', use_column_width=True)
|
| 40 |
+
query = st.text_input(label="What details you want from the resume?")
|
| 41 |
+
query_button = st.button("Get Answer")
|
| 42 |
+
|
| 43 |
+
submit = st.button("Extract all data")
|
| 44 |
+
|
| 45 |
+
|
| 46 |
+
input_prompt = """
|
| 47 |
+
You are a resume analyzer. You have to extract the data from the resume image.
|
| 48 |
+
You will have to answer the questions based on the input resume image.
|
| 49 |
+
"""
|
| 50 |
+
|
| 51 |
+
|
| 52 |
+
if submit and image_data is not None:
|
| 53 |
+
response = get_gemini_response(input_prompt,image_data)
|
| 54 |
+
st.subheader("The response is:")
|
| 55 |
+
st.write(response)
|
| 56 |
+
|
| 57 |
+
if query_button and image_data is not None:
|
| 58 |
+
response = get_gemini_response(input_prompt,image_data, query)
|
| 59 |
+
st.subheader("The response is:")
|
| 60 |
+
st.write(response)
|
| 61 |
+
|
requirements.txt
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
streamlit
|
| 2 |
+
google-generativeai
|
| 3 |
+
python-dotenv
|
| 4 |
+
pdf2image
|