-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathui_resume_multiple.py
More file actions
34 lines (30 loc) · 1.11 KB
/
ui_resume_multiple.py
File metadata and controls
34 lines (30 loc) · 1.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import io
import gradio as gr
import fitz # PyMuPDF for PDF handling
from PIL import Image
from resume_util import *
def convert_image(pdf_file):
# check if pdf file is provided
if not pdf_file:
raise ValueError("No pdf file provided , please upload the same")
# Open the PDF from the uploaded file
doc = fitz.open(pdf_file)
images = []
# Iterate through all the pages and convert them to images
for page_num in range(len(doc)):
page = doc.load_page(page_num)
pix = page.get_pixmap()
img = Image.open(io.BytesIO(pix.tobytes("png")))
# Append the image to the list
images.append(img)
return images
with gr.Blocks() as demo:
with gr.Row():
gallery = []
resume_list = ['Rahul_Sharma.pdf','Rahul_Mehta.pdf','Rajesh_Kumar.pdf']
for resume in resume_list:
label = resume.strip('.pdf')
img_arr = convert_image(resume)
output_gallery1 = gr.Gallery(value=img_arr,type="pil", label=label,elem_id="resume-gallery",height=50,scale=0,preview=True)
gallery.append(output_gallery1)
demo.launch()