credent007 commited on
Commit
175f30a
·
verified ·
1 Parent(s): 0a81395

Update processor_utils.py

Browse files
Files changed (1) hide show
  1. processor_utils.py +12 -0
processor_utils.py CHANGED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from PIL import Image
2
+ import fitz
3
+
4
+ def load_input(file_path):
5
+ if file_path.lower().endswith(".pdf"):
6
+ doc = fitz.open(file_path)
7
+ page = doc[0]
8
+ pix = page.get_pixmap()
9
+ img = Image.frombytes("RGB", [pix.width, pix.height], pix.samples)
10
+ return img
11
+ else:
12
+ return Image.open(file_path).convert("RGB")