seanpedrickcase commited on
Commit
face41c
·
1 Parent(s): ec98119

Should now retain modified redactions on first use of zoom

Browse files
Files changed (2) hide show
  1. app.py +5 -4
  2. tools/redaction_review.py +8 -6
app.py CHANGED
@@ -308,11 +308,12 @@ with app:
308
 
309
  # Zoom in and out on annotator
310
  annotate_zoom_in.click(modify_existing_page_redactions, inputs = [annotator, annotate_current_page, annotate_previous_page, all_image_annotations_state], outputs = [all_image_annotations_state, annotate_previous_page, annotate_current_page_bottom]).\
311
- then(update_zoom, inputs=[annotator_zoom_number, zoom_true_bool], outputs=[annotator_zoom_number]).\
312
- then(update_annotator, inputs=[all_image_annotations_state, annotate_current_page, annotator_zoom_number], outputs = [annotator, annotate_current_page, annotate_current_page_bottom])
313
  annotate_zoom_out.click(modify_existing_page_redactions, inputs = [annotator, annotate_current_page, annotate_previous_page, all_image_annotations_state], outputs = [all_image_annotations_state, annotate_previous_page, annotate_current_page_bottom]).\
314
- then(update_zoom, inputs=[annotator_zoom_number, zoom_false_bool], outputs=[annotator_zoom_number]).\
315
- then(update_annotator, inputs=[all_image_annotations_state, annotate_current_page, annotator_zoom_number], outputs = [annotator, annotate_current_page, annotate_current_page_bottom])
 
316
 
317
  #annotation_button_get.click(get_boxes_json, annotator, json_boxes)
318
  annotation_button_apply.click(apply_redactions, inputs=[annotator, in_doc_files, pdf_doc_state, all_image_annotations_state, annotate_current_page], outputs=[pdf_doc_state, all_image_annotations_state, output_review_files], scroll_to_output=True)
 
308
 
309
  # Zoom in and out on annotator
310
  annotate_zoom_in.click(modify_existing_page_redactions, inputs = [annotator, annotate_current_page, annotate_previous_page, all_image_annotations_state], outputs = [all_image_annotations_state, annotate_previous_page, annotate_current_page_bottom]).\
311
+ then(update_zoom, inputs=[annotator_zoom_number, annotate_current_page, zoom_true_bool], outputs=[annotator_zoom_number, annotate_current_page])
312
+
313
  annotate_zoom_out.click(modify_existing_page_redactions, inputs = [annotator, annotate_current_page, annotate_previous_page, all_image_annotations_state], outputs = [all_image_annotations_state, annotate_previous_page, annotate_current_page_bottom]).\
314
+ then(update_zoom, inputs=[annotator_zoom_number, annotate_current_page, zoom_false_bool], outputs=[annotator_zoom_number, annotate_current_page])
315
+
316
+ annotator_zoom_number.change(update_annotator, inputs=[all_image_annotations_state, annotate_current_page, annotator_zoom_number], outputs = [annotator, annotate_current_page, annotate_current_page_bottom])
317
 
318
  #annotation_button_get.click(get_boxes_json, annotator, json_boxes)
319
  annotation_button_apply.click(apply_redactions, inputs=[annotator, in_doc_files, pdf_doc_state, all_image_annotations_state, annotate_current_page], outputs=[pdf_doc_state, all_image_annotations_state, output_review_files], scroll_to_output=True)
tools/redaction_review.py CHANGED
@@ -37,7 +37,7 @@ def increase_page(number:int, image_annotator_object:AnnotatedImageData):
37
  else:
38
  return max_pages, max_pages
39
 
40
- def update_zoom(current_zoom_level:int, decrease:bool=True):
41
  if decrease == False:
42
  if current_zoom_level >= 50:
43
  current_zoom_level -= 10
@@ -45,7 +45,7 @@ def update_zoom(current_zoom_level:int, decrease:bool=True):
45
  if current_zoom_level < 100:
46
  current_zoom_level += 10
47
 
48
- return current_zoom_level
49
 
50
 
51
  def update_annotator(image_annotator_object:AnnotatedImageData, page_num:int, zoom:int=100):
@@ -110,13 +110,15 @@ def modify_existing_page_redactions(image_annotated:AnnotatedImageData, current_
110
  '''
111
  Overwrite current image annotations with modifications
112
  '''
113
- #If no previous page or is 0, i.e. first time run, then make no changes
114
- if not previous_page:
115
- return all_image_annotations, current_page, current_page
116
-
117
  if not current_page:
118
  current_page = 1
119
 
 
 
 
 
 
120
  #print("all_image_annotations before:",all_image_annotations)
121
 
122
  image_annotated['image'] = all_image_annotations[previous_page - 1]["image"]
 
37
  else:
38
  return max_pages, max_pages
39
 
40
+ def update_zoom(current_zoom_level:int, annotate_current_page:int, decrease:bool=True):
41
  if decrease == False:
42
  if current_zoom_level >= 50:
43
  current_zoom_level -= 10
 
45
  if current_zoom_level < 100:
46
  current_zoom_level += 10
47
 
48
+ return current_zoom_level, annotate_current_page
49
 
50
 
51
  def update_annotator(image_annotator_object:AnnotatedImageData, page_num:int, zoom:int=100):
 
110
  '''
111
  Overwrite current image annotations with modifications
112
  '''
113
+
 
 
 
114
  if not current_page:
115
  current_page = 1
116
 
117
+ #If no previous page or is 0, i.e. first time run, then rewrite current page
118
+ if not previous_page:
119
+ previous_page = current_page
120
+ #return all_image_annotations, current_page, current_page
121
+
122
  #print("all_image_annotations before:",all_image_annotations)
123
 
124
  image_annotated['image'] = all_image_annotations[previous_page - 1]["image"]