teowu commited on
Commit
d2522ba
·
verified ·
1 Parent(s): 7f513c9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -0
app.py CHANGED
@@ -133,6 +133,25 @@ def load_frames(video_file, max_num_frames=64, long_edge=448):
133
  imgs.append(img)
134
 
135
  return imgs, frame_timestamps
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
136
 
137
  @wrap_gen_fn
138
  @spaces.GPU(duration=30)
 
133
  imgs.append(img)
134
 
135
  return imgs, frame_timestamps
136
+
137
+ def pdf_to_multi_image(local_pdf):
138
+ import fitz, io
139
+ doc_ = fitz.open(local_pdf)
140
+
141
+ all_input_images = []
142
+
143
+ for page_num in range(len(doc_)):
144
+ page = doc.load_page(page_num)
145
+
146
+ pixmap = page.get_pixmap(dpi=96)
147
+
148
+ image = Image.open(io.BytesIO(pixmap.tobytes("png")))
149
+
150
+ all_input_images.append(image)
151
+
152
+
153
+ doc_.close()
154
+ return all_input_images
155
 
156
  @wrap_gen_fn
157
  @spaces.GPU(duration=30)