tensorboy0101 commited on
Commit
aef0bed
·
verified ·
1 Parent(s): 8cd7e1e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -8
app.py CHANGED
@@ -18,26 +18,26 @@ def get_gemini_response(input,pdf_cotent,prompt):
18
 
19
  def input_pdf_setup(uploaded_file):
20
  if uploaded_file is not None:
21
- ## Convert the PDF to image
22
- images=fitz.open(stream=pdf_bytes, filetype="pdf")
 
 
 
23
 
24
- first_page=images[0]
25
-
26
- # Convert to bytes
27
  img_byte_arr = io.BytesIO()
28
- first_page.save(img_byte_arr, format='JPEG')
29
  img_byte_arr = img_byte_arr.getvalue()
30
 
31
  pdf_parts = [
32
  {
33
  "mime_type": "image/jpeg",
34
- "data": base64.b64encode(img_byte_arr).decode() # encode to base64
35
  }
36
  ]
37
  return pdf_parts
38
  else:
39
  raise FileNotFoundError("No file uploaded")
40
-
41
  ## Streamlit App
42
 
43
  st.set_page_config(page_title="ATS Resume EXpert")
 
18
 
19
  def input_pdf_setup(uploaded_file):
20
  if uploaded_file is not None:
21
+ # Read PDF as bytes
22
+ pdf_bytes = uploaded_file.read()
23
+ pdf_doc = fitz.open(stream=pdf_bytes, filetype="pdf")
24
+ first_page = pdf_doc[0] # Get first page of the PDF
25
+ pix = first_page.get_pixmap()
26
 
27
+ # Convert page to image bytes
 
 
28
  img_byte_arr = io.BytesIO()
29
+ img_byte_arr.write(pix.tobytes("jpeg"))
30
  img_byte_arr = img_byte_arr.getvalue()
31
 
32
  pdf_parts = [
33
  {
34
  "mime_type": "image/jpeg",
35
+ "data": base64.b64encode(img_byte_arr).decode()
36
  }
37
  ]
38
  return pdf_parts
39
  else:
40
  raise FileNotFoundError("No file uploaded")
 
41
  ## Streamlit App
42
 
43
  st.set_page_config(page_title="ATS Resume EXpert")