-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathannotation_project_administration.py
45 lines (36 loc) · 1.99 KB
/
annotation_project_administration.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
from webknossos import AnnotationState, Project, Task
def main() -> None:
# Assume running annotation project with previously created tasks.
# Compare WEBKNOSSOS documentation at https://docs.webknossos.org/webknossos/tasks.html
# Fetch statistics about how many annotation tasks have been completed yet.
sample_project = Project.get_by_name("sampleProject")
tasks = sample_project.get_tasks()
total_active_instances = sum([task.status.active_instance_count for task in tasks])
total_pending_instances = sum(
[task.status.pending_instance_count for task in tasks]
)
print(
f"There are {total_active_instances} active and {total_pending_instances} pending task instances."
)
# Find and download all of the project’s annotations that are already finished by annotators
finished_annotations = []
for task in tasks:
for annotation_info in task.get_annotation_infos():
if annotation_info.state == AnnotationState.FINISHED:
finished_annotation = annotation_info.download_annotation()
finished_annotations.append(finished_annotation)
assert len(finished_annotations) > 0, "No annotations are finished yet!"
# Assume a second task type is in place that instructs annotators to take the previously created
# annotations and perform a secondary annotation step on them
# (e.g. first task is to seed positions, second is to fully label around those)
task_type_id = "61f90e4efe0100b102553009" # from WEBKNOSSOS web interface
tasks = Task.create_from_annotations(
task_type_id=task_type_id, # New task type instructs annotators what to do in the task
project_name="sampleProject2",
base_annotations=finished_annotations,
needed_experience_domain="sampleExp", # Only annotators with the experience "sampleExp" of at least value 2 will get this task
needed_experience_value=2,
)
print(f"New tasks: {tasks}")
if __name__ == "__main__":
main()