# default_exp capture_annotator
Capture annotator¶
The current notebook develop a annotator (Capture Annotator
) that displays multiple items options, allowing users to select multiple of them and save their answers.
State¶
The data shared across the annotator are:
The
annotations
attribute represents all annotations that could be selected and the user’s answers;The
disp_number
attribute represents the number of options to be displayed;The
question_value
attribute represents the label to be shown above the selectable options;The
all_none
attribute represents that no option was selected;The
n_rows
andn_cols
displays the number of options to be shows per rows and cols respectively.
View¶
The CaptureAnnotatorGUI
joins the internal component (GridMenu
) with the navi component and its interaction.
Storage¶
The CaptureAnnotationStorage
saves the user annotations on the disk
Controller¶
The controller communicates with the state and the storage layer, updating the states and saving the data on disk using the storage module.
# remove if the results folder exists this allows
# the next command to construct the annotation path
! rm -rf ../data/projects/capture1/results
from ipyannotator.storage import construct_annotation_path
anno_file_path = construct_annotation_path(project_path)
storage = CaptureAnnotationStorage(
input_item_path=project_path / imz.dir,
annotation_file_path=anno_file_path
)
app_state = AppWidgetState()
capture_state = CaptureState(grid=grid)
caController = CaptureAnnotatorController(
app_state=app_state,
capture_state=capture_state,
storage=storage,
input_item=imz,
output_item=grid_bx,
annotation_file_path=anno_file_path,
question='hello'
)
caController._capture_state.disp_number = 9 # should be synced from gui
We have 16 images in capture1
project on disk, so first screen should load 9 images;
7 images (16-9) left for second screen.
caController.images
[Path('../data/projects/capture1/pics/pink25x25.png'),
Path('../data/projects/capture1/pics/pink50x125.png'),
Path('../data/projects/capture1/pics/pink50x50.png'),
Path('../data/projects/capture1/pics/pink50x50_0.png'),
Path('../data/projects/capture1/pics/pink50x50_1.png'),
Path('../data/projects/capture1/pics/pink50x50_3.png'),
Path('../data/projects/capture1/pics/teal125x50.png'),
Path('../data/projects/capture1/pics/teal50x50.png'),
Path('../data/projects/capture1/pics/teal50x50_0.png'),
Path('../data/projects/capture1/pics/teal50x50_1.png'),
Path('../data/projects/capture1/pics/teal50x50_2.png'),
Path('../data/projects/capture1/pics/teal50x50_3.png'),
Path('../data/projects/capture1/pics/teal50x50_4.png'),
Path('../data/projects/capture1/pics/teal50x50_5.png'),
Path('../data/projects/capture1/pics/teal50x50_6.png'),
Path('../data/projects/capture1/pics/teal75x75.png')]
This will output the path of all the 16 images
[Path('../data/projects/capture1/pics/pink25x25.png'),
Path('../data/projects/capture1/pics/pink50x125.png'),
Path('../data/projects/capture1/pics/pink50x50.png'),
Path('../data/projects/capture1/pics/pink50x50_0.png'),
Path('../data/projects/capture1/pics/pink50x50_1.png'),
Path('../data/projects/capture1/pics/pink50x50_3.png'),
Path('../data/projects/capture1/pics/teal125x50.png'),
Path('../data/projects/capture1/pics/teal50x50.png'),
Path('../data/projects/capture1/pics/teal50x50_0.png'),
Path('../data/projects/capture1/pics/teal50x50_1.png'),
Path('../data/projects/capture1/pics/teal50x50_2.png'),
Path('../data/projects/capture1/pics/teal50x50_3.png'),
Path('../data/projects/capture1/pics/teal50x50_4.png'),
Path('../data/projects/capture1/pics/teal50x50_5.png'),
Path('../data/projects/capture1/pics/teal50x50_6.png'),
Path('../data/projects/capture1/pics/teal75x75.png')]
List of image names for the 1st screen:
caController._capture_state.annotations
LabelStore({'../data/projects/capture1/pics/pink25x25.png': {}, '../data/projects/capture1/pics/pink50x125.png': {}, '../data/projects/capture1/pics/pink50x50.png': {}, '../data/projects/capture1/pics/pink50x50_0.png': {}, '../data/projects/capture1/pics/pink50x50_1.png': {}, '../data/projects/capture1/pics/pink50x50_3.png': {}, '../data/projects/capture1/pics/teal125x50.png': {}, '../data/projects/capture1/pics/teal50x50.png': {}, '../data/projects/capture1/pics/teal50x50_0.png': {}})
{'../data/projects/capture1/pics/pink25x25.png': {},
'../data/projects/capture1/pics/pink50x125.png': {},
'../data/projects/capture1/pics/pink50x50.png': {},
'../data/projects/capture1/pics/pink50x50_0.png': {},
'../data/projects/capture1/pics/pink50x50_1.png': {},
'../data/projects/capture1/pics/pink50x50_3.png': {},
'../data/projects/capture1/pics/teal125x50.png': {},
'../data/projects/capture1/pics/teal50x50.png': {},
'../data/projects/capture1/pics/teal50x50_0.png': {}}
Suppose state change from gui:
caController._capture_state.annotations[
'../data/projects/capture1/pics/pink25x25.png'] = {'answer': False}