Spaces:
Sleeping
Sleeping
Commit
·
e8681e8
1
Parent(s):
0d3554e
Fixed bug where pages suggested for whole redaction are one lower than requested
Browse files- app.py +1 -1
- tools/file_redaction.py +5 -8
- tools/redaction_review.py +1 -1
app.py
CHANGED
@@ -117,7 +117,7 @@ with app:
|
|
117 |
|
118 |
|
119 |
## Annotator zoom value
|
120 |
-
annotator_zoom_number = gr.Number(label = "Current annotator zoom level", value=
|
121 |
zoom_true_bool = gr.State(True)
|
122 |
zoom_false_bool = gr.State(False)
|
123 |
|
|
|
117 |
|
118 |
|
119 |
## Annotator zoom value
|
120 |
+
annotator_zoom_number = gr.Number(label = "Current annotator zoom level", value=100, precision=0, visible=False)
|
121 |
zoom_true_bool = gr.State(True)
|
122 |
zoom_false_bool = gr.State(False)
|
123 |
|
tools/file_redaction.py
CHANGED
@@ -708,8 +708,6 @@ def redact_page_with_pymupdf(page:Page, page_annotations:dict, image=None, custo
|
|
708 |
if image:
|
709 |
img_width, img_height = image.size
|
710 |
|
711 |
-
print("annot:", annot)
|
712 |
-
|
713 |
x1, image_y1, x2, image_y2 = convert_pymupdf_to_image_coords(page, x1, pymupdf_y1, x2, pymupdf_y2, image)
|
714 |
|
715 |
img_annotation_box["xmin"] = x1 #* (img_width / rect_width) # Use adjusted x1
|
@@ -745,9 +743,6 @@ def redact_page_with_pymupdf(page:Page, page_annotations:dict, image=None, custo
|
|
745 |
"boxes": all_image_annotation_boxes
|
746 |
}
|
747 |
|
748 |
-
|
749 |
-
|
750 |
-
|
751 |
page.apply_redactions(images=0, graphics=0)
|
752 |
page.clean_contents()
|
753 |
|
@@ -1160,7 +1155,8 @@ def redact_image_pdf(file_path:str,
|
|
1160 |
else:
|
1161 |
#print("redact_whole_page_list:", redact_whole_page_list)
|
1162 |
if redact_whole_page_list:
|
1163 |
-
|
|
|
1164 |
else: redact_whole_page = False
|
1165 |
else: redact_whole_page = False
|
1166 |
|
@@ -1846,8 +1842,9 @@ def redact_text_pdf(
|
|
1846 |
|
1847 |
# Make pymupdf page redactions
|
1848 |
#print("redact_whole_page_list:", redact_whole_page_list)
|
1849 |
-
if redact_whole_page_list:
|
1850 |
-
|
|
|
1851 |
else: redact_whole_page = False
|
1852 |
else: redact_whole_page = False
|
1853 |
|
|
|
708 |
if image:
|
709 |
img_width, img_height = image.size
|
710 |
|
|
|
|
|
711 |
x1, image_y1, x2, image_y2 = convert_pymupdf_to_image_coords(page, x1, pymupdf_y1, x2, pymupdf_y2, image)
|
712 |
|
713 |
img_annotation_box["xmin"] = x1 #* (img_width / rect_width) # Use adjusted x1
|
|
|
743 |
"boxes": all_image_annotation_boxes
|
744 |
}
|
745 |
|
|
|
|
|
|
|
746 |
page.apply_redactions(images=0, graphics=0)
|
747 |
page.clean_contents()
|
748 |
|
|
|
1155 |
else:
|
1156 |
#print("redact_whole_page_list:", redact_whole_page_list)
|
1157 |
if redact_whole_page_list:
|
1158 |
+
int_reported_page_number = int(reported_page_number)
|
1159 |
+
if int_reported_page_number in redact_whole_page_list: redact_whole_page = True
|
1160 |
else: redact_whole_page = False
|
1161 |
else: redact_whole_page = False
|
1162 |
|
|
|
1842 |
|
1843 |
# Make pymupdf page redactions
|
1844 |
#print("redact_whole_page_list:", redact_whole_page_list)
|
1845 |
+
if redact_whole_page_list:
|
1846 |
+
int_reported_page_number = int(reported_page_number)
|
1847 |
+
if int_reported_page_number in redact_whole_page_list: redact_whole_page = True
|
1848 |
else: redact_whole_page = False
|
1849 |
else: redact_whole_page = False
|
1850 |
|
tools/redaction_review.py
CHANGED
@@ -49,7 +49,7 @@ def update_zoom(current_zoom_level:int, annotate_current_page:int, decrease:bool
|
|
49 |
|
50 |
return current_zoom_level, annotate_current_page
|
51 |
|
52 |
-
def update_annotator(image_annotator_object:AnnotatedImageData, page_num:int, recogniser_entities_drop=gr.Dropdown(value="ALL", allow_custom_value=True), recogniser_dataframe_gr=gr.Dataframe(pd.DataFrame(data={"page":[], "label":[]})), zoom:int=
|
53 |
'''
|
54 |
Update a gradio_image_annotation object with new annotation data
|
55 |
'''
|
|
|
49 |
|
50 |
return current_zoom_level, annotate_current_page
|
51 |
|
52 |
+
def update_annotator(image_annotator_object:AnnotatedImageData, page_num:int, recogniser_entities_drop=gr.Dropdown(value="ALL", allow_custom_value=True), recogniser_dataframe_gr=gr.Dataframe(pd.DataFrame(data={"page":[], "label":[]})), zoom:int=100):
|
53 |
'''
|
54 |
Update a gradio_image_annotation object with new annotation data
|
55 |
'''
|