Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -30,12 +30,6 @@ def crop_images_from_boxes(image, boxes, scale_factor):
|
|
30 |
]
|
31 |
return cropped_images
|
32 |
|
33 |
-
# Warm-up function to perform a dummy inference
|
34 |
-
@spaces.GPU
|
35 |
-
def warm_up_model():
|
36 |
-
dummy_image = np.zeros((640, 512, 3), dtype=np.uint8)
|
37 |
-
infer_image_and_get_boxes(dummy_image)
|
38 |
-
|
39 |
@spaces.GPU
|
40 |
def process_pdf(pdf_file):
|
41 |
# Open the PDF file
|
@@ -51,7 +45,7 @@ def process_pdf(pdf_file):
|
|
51 |
|
52 |
# Pre-cache all page pixmaps at low DPI
|
53 |
low_res_pixmaps = [page.get_pixmap(dpi=low_dpi) for page in doc]
|
54 |
-
|
55 |
# Loop through each page
|
56 |
for page_num, low_res_pix in enumerate(low_res_pixmaps):
|
57 |
low_res_img = np.frombuffer(low_res_pix.samples, dtype=np.uint8).reshape(low_res_pix.height, low_res_pix.width, 3)
|
@@ -70,9 +64,6 @@ def process_pdf(pdf_file):
|
|
70 |
|
71 |
return all_cropped_images
|
72 |
|
73 |
-
# Warm-up the model before launching the app
|
74 |
-
warm_up_model()
|
75 |
-
|
76 |
# Create Gradio interface
|
77 |
iface = gr.Interface(
|
78 |
fn=process_pdf,
|
|
|
30 |
]
|
31 |
return cropped_images
|
32 |
|
|
|
|
|
|
|
|
|
|
|
|
|
33 |
@spaces.GPU
|
34 |
def process_pdf(pdf_file):
|
35 |
# Open the PDF file
|
|
|
45 |
|
46 |
# Pre-cache all page pixmaps at low DPI
|
47 |
low_res_pixmaps = [page.get_pixmap(dpi=low_dpi) for page in doc]
|
48 |
+
|
49 |
# Loop through each page
|
50 |
for page_num, low_res_pix in enumerate(low_res_pixmaps):
|
51 |
low_res_img = np.frombuffer(low_res_pix.samples, dtype=np.uint8).reshape(low_res_pix.height, low_res_pix.width, 3)
|
|
|
64 |
|
65 |
return all_cropped_images
|
66 |
|
|
|
|
|
|
|
67 |
# Create Gradio interface
|
68 |
iface = gr.Interface(
|
69 |
fn=process_pdf,
|