Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -52,7 +52,7 @@ model.to(device);
|
|
52 |
def app_outputs(uploaded_pdf):
|
53 |
filename, msg, images = pdf_to_images(uploaded_pdf)
|
54 |
num_images = len(images)
|
55 |
-
|
56 |
if not msg.startswith("Error with the PDF"):
|
57 |
|
58 |
# Extraction of image data (text and bounding boxes)
|
@@ -67,10 +67,12 @@ def app_outputs(uploaded_pdf):
|
|
67 |
# Get labeled images with lines bounding boxes
|
68 |
images = get_labeled_images(dataset, images_ids_list, bboxes_list_dict, probs_dict_dict)
|
69 |
|
|
|
|
|
70 |
img_files = list()
|
71 |
# get image of PDF without bounding boxes
|
72 |
for i in range(num_images):
|
73 |
-
if filename != "
|
74 |
else: img_file = filename.replace(".pdf", ".png")
|
75 |
images[i].save(img_file)
|
76 |
img_files.append(img_file)
|
|
|
52 |
def app_outputs(uploaded_pdf):
|
53 |
filename, msg, images = pdf_to_images(uploaded_pdf)
|
54 |
num_images = len(images)
|
55 |
+
path = os.path.dirname(__file__)
|
56 |
if not msg.startswith("Error with the PDF"):
|
57 |
|
58 |
# Extraction of image data (text and bounding boxes)
|
|
|
67 |
# Get labeled images with lines bounding boxes
|
68 |
images = get_labeled_images(dataset, images_ids_list, bboxes_list_dict, probs_dict_dict)
|
69 |
|
70 |
+
|
71 |
+
|
72 |
img_files = list()
|
73 |
# get image of PDF without bounding boxes
|
74 |
for i in range(num_images):
|
75 |
+
if filename != path+"/blank.png": img_file = f"img_{i}_" + filename.replace(".pdf", ".png")
|
76 |
else: img_file = filename.replace(".pdf", ".png")
|
77 |
images[i].save(img_file)
|
78 |
img_files.append(img_file)
|