Skip to content

Commit

Permalink
add cli arguments to retrieve annotaions
Browse files Browse the repository at this point in the history
  • Loading branch information
yCobanoglu committed Nov 30, 2023
1 parent dd60ad2 commit 732c078
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 16 deletions.
4 changes: 4 additions & 0 deletions Taskfile.dist.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ tasks:
- task: type
- task: test

python3:
cmds:
- poetry run python3 {{.CLI_ARGS}}

test:
cmds:
- poetry run pytest {{.CLI_ARGS}}
Expand Down
2 changes: 1 addition & 1 deletion ebl/fragmentarium/annotations.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"finished": ["YBC.4087", "HS.455", "BM.32486", "Rm-II.229", "YBC.3872", "YBC.4098", "HS.458", "HS.245", "YBC.4115", "YBC.4083", "BM.36943", "NBC.6176", "BM.34703", "BM.33741", "MLC.1737", "HS.277", "YBC.4106", "BM.33535", "BM.34695", "BM.34643", "HS.276", "BM.34780", "YBC.3838", "BM.35559", "YBC.3421", "GCBC.675", "BM.34679", "Sp-III.917", "HS.449", "BM.34731", "YBC.4114", "BM.41626", "BM.32376", "BM.33011", "BM.41577", "NBC.4617", "NBC.7439", "YBC.3763", "YBC.988", "YBC.3854", "BM.33012", "BM.34225", "K.22981", "BM.34201", "YBC.4023", "YBC.3409", "NBC.4628", "HS.156", "BM.33013", "BM.41893", "BM.33984", "HS.452", "HS.445", "BM.32217", "BM.42043", "BM.33382", "BM.33009", "1880,0719.160", "YBC.3855", "BM.33015", "GCBC.248", "K.2638", "BM.33017", "YBC.4110", "YBC.4109", "BM.41780", "BM.35519", "YBC.754", "BM.41665", "NBC.4615", "NBC.2749", "BM.38287", "1881,0727.205", "BM.42107", "BM.39235", "BM.33557", "BM.45156", "BM.35224", "YBC.4096", "YBC.4045", "HS.447", "BM.33010", "YBC.4085", "YBC.4068", "NBC.5345", "K.127", "BM.33016", "BM.34110", "BM.41483", "ND.4400", "HS.278", "BM.41556", "BM.40807", "BM.40068", "BM.41576", "BM.41176", "HS.450", "YBC.1", "HS.454", "K.3753", "YBC.3704", "BM.33262", "BM.41894", "YBC.4111", "HS.453", "BM.32656", "BM.37616", "YBC.3851", "YBC.3839", "BM.33667", "YBC.3836", "BM.36796", "NBC.5599", "YBC.3925", "NBC.461","1879,0708.86", "1880,0719.100", "1882,0323.102", "1882,0323.17", "1882,0522.552", "1891,0509.236", "BM.114741", "BM.121131.A", "BM.32254", "BM.33014", "BM.33337", "BM.33491", "BM.33541", "BM.33558", "BM.33983", "BM.34218", "BM.34314", "BM.35293", "BM.36041", "BM.36456", "BM.38076", "BM.38272", "BM.38422", "BM.38432", "BM.38537", "BM.38544", "BM.38770", "BM.39030", "BM.39119", "BM.39319", "BM.39562", "BM.39788", "BM.40012", "BM.40193", "BM.40196", "BM.40216", "BM.40295", "BM.40357", "BM.40403", "BM.40406", "BM.40416", "BM.40431", "BM.40518", "BM.40696", "BM.40818", "BM.41000", "BM.41291", "BM.41747", "BM.42273", "BM.42276", "BM.42283", "BM.42325", "BM.42333", "DT.42", "GCBC.284", "IM.67559", "IM.67571", "K.10084", "K.10208", "K.10211", "K.10545", "K.11309", "K.11373", "K.11403", "K.11700", "K.11947", "K.12000", "K.12000.Q", "K.12687", "K.128", "K.1283", "K.12984", "K.12999", "K.13355", "K.13731", "K.13887", "K.14481", "K.14854", "K.15827", "K.16002", "K.16446", "K.17666", "K.17674", "K.17677", "K.1808", "K.18767", "K.18874", "K.18875", "K.19000", "K.19001", "K.19006", "K.19010", "K.19105", "K.19118", "K.19210", "K.19403", "K.19604", "K.19888", "K.2", "K.20", "K.2025", "K.20256", "K.20493", "K.21803", "K.2189", "K.2210", "K.2712", "K.2826", "K.3118", "K.3285", "K.3499", "K.3810", "K.4003", "K.4030", "K.4063", "K.4426", "K.4782", "K.5807", "K.6201", "K.6393", "K.6400", "K.7114", "K.7853", "K.7917", "K.8678", "K.9048", "K.9499", "K.9654", "K.9905", "MGT.3", "MLC.1874", "MLC.1879", "MLC.1881", "NBC.1120", "ND.5437", "ND.6200", "ND.6201", "Rm", "Rm.618", "Sm.986", "YBC.1317", "YBC.4046"]
"finished": ["CBS.1519", "CBS.112", "YBC.6870", "GCBC.165", "CBS.26", "YBC.9120", "CBS.8646", "YBC.103", "BM.40757", "BM.45629", "YBC.7489", "CBS.13532", "CBS.1384", "BM.30980", "BM.33550", "CBS.121", "BM.41521", "CBS.1498", "NBC.5298", "CBS.1470", "YBC.102", "BM.31749", "CBS.1209", "CBS.14054", "GCBC.160", "CBS.1208", "BM.30119", "CBS.1422", "CBS.511", "YBC.4024", "YBC.10", "BM.41267", "BM.36276", "BM.39310", "YBC.4", "YBC.100", "YBC.2", "YBC.6861", "BM.38023", "YBC.6867", "CBS.1514", "GCBC.646", "YBC.101", "CBS.1516", "CBS.1505", "CBS.1515", "CBS.1499", "CBS.1490", "GCBC.562", "YBC.3", "F.76", "BM.30117", "GCBC.631", "BM.45641", "CBS.36", "CBS.156", "1880,0719.194", "CBS.142", "YBC.5","YBC.4087", "HS.455", "BM.32486", "Rm-II.229", "YBC.3872", "YBC.4098", "HS.458", "HS.245", "YBC.4115", "YBC.4083", "BM.36943", "NBC.6176", "BM.34703", "BM.33741", "MLC.1737", "HS.277", "YBC.4106", "BM.33535", "BM.34695", "BM.34643", "HS.276", "BM.34780", "YBC.3838", "BM.35559", "YBC.3421", "GCBC.675", "BM.34679", "Sp-III.917", "HS.449", "BM.34731", "YBC.4114", "BM.41626", "BM.32376", "BM.33011", "BM.41577", "NBC.4617", "NBC.7439", "YBC.3763", "YBC.988", "YBC.3854", "BM.33012", "BM.34225", "K.22981", "BM.34201", "YBC.4023", "YBC.3409", "NBC.4628", "HS.156", "BM.33013", "BM.41893", "BM.33984", "HS.452", "HS.445", "BM.32217", "BM.42043", "BM.33382", "BM.33009", "1880,0719.160", "YBC.3855", "BM.33015", "GCBC.248", "K.2638", "BM.33017", "YBC.4110", "YBC.4109", "BM.41780", "BM.35519", "YBC.754", "BM.41665", "NBC.4615", "NBC.2749", "BM.38287", "1881,0727.205", "BM.42107", "BM.39235", "BM.33557", "BM.45156", "BM.35224", "YBC.4096", "YBC.4045", "HS.447", "BM.33010", "YBC.4085", "YBC.4068", "NBC.5345", "K.127", "BM.33016", "BM.34110", "BM.41483", "ND.4400", "HS.278", "BM.41556", "BM.40807", "BM.40068", "BM.41576", "BM.41176", "HS.450", "YBC.1", "HS.454", "K.3753", "YBC.3704", "BM.33262", "BM.41894", "YBC.4111", "HS.453", "BM.32656", "BM.37616", "YBC.3851", "YBC.3839", "BM.33667", "YBC.3836", "BM.36796", "NBC.5599", "YBC.3925", "NBC.461","1879,0708.86", "1880,0719.100", "1882,0323.102", "1882,0323.17", "1882,0522.552", "1891,0509.236", "BM.114741", "BM.121131.A", "BM.32254", "BM.33014", "BM.33337", "BM.33491", "BM.33541", "BM.33558", "BM.33983", "BM.34218", "BM.34314", "BM.35293", "BM.36041", "BM.36456", "BM.38076", "BM.38272", "BM.38422", "BM.38432", "BM.38537", "BM.38544", "BM.38770", "BM.39030", "BM.39119", "BM.39319", "BM.39562", "BM.39788", "BM.40012", "BM.40193", "BM.40196", "BM.40216", "BM.40295", "BM.40357", "BM.40403", "BM.40406", "BM.40416", "BM.40431", "BM.40518", "BM.40696", "BM.40818", "BM.41000", "BM.41291", "BM.41747", "BM.42273", "BM.42276", "BM.42283", "BM.42325", "BM.42333", "DT.42", "GCBC.284", "IM.67559", "IM.67571", "K.10084", "K.10208", "K.10211", "K.10545", "K.11309", "K.11373", "K.11403", "K.11700", "K.11947", "K.12000", "K.12000.Q", "K.12687", "K.128", "K.1283", "K.12984", "K.12999", "K.13355", "K.13731", "K.13887", "K.14481", "K.14854", "K.15827", "K.16002", "K.16446", "K.17666", "K.17674", "K.17677", "K.1808", "K.18767", "K.18874", "K.18875", "K.19000", "K.19001", "K.19006", "K.19010", "K.19105", "K.19118", "K.19210", "K.19403", "K.19604", "K.19888", "K.2", "K.20", "K.2025", "K.20256", "K.20493", "K.21803", "K.2189", "K.2210", "K.2712", "K.2826", "K.3118", "K.3285", "K.3499", "K.3810", "K.4003", "K.4030", "K.4063", "K.4426", "K.4782", "K.5807", "K.6201", "K.6393", "K.6400", "K.7114", "K.7853", "K.7917", "K.8678", "K.9048", "K.9499", "K.9654", "K.9905", "MGT.3", "MLC.1874", "MLC.1879", "MLC.1881", "NBC.1120", "ND.5437", "ND.6200", "ND.6201", "Rm.618", "Sm.986", "YBC.1317", "YBC.4046"],
}
45 changes: 30 additions & 15 deletions ebl/fragmentarium/retrieve_annotations.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,11 +206,13 @@ def write_fragment_numbers(
parser.add_argument(
"-oi", "--output_imgs", type=str, default=None, help="Output Images Directory"
)
# add argument string

parser.add_argument(
"-f",
"--filter",
action="store_true",
help="filter finished Fragments from ./annotations.json",
type=str,
help="filter from ./annotations.json has to 'finished', 'unfinished' or 'selected'",
)
parser.add_argument(
"-c",
Expand All @@ -237,20 +239,33 @@ def write_fragment_numbers(
annotation_collection = context.annotations_repository.retrieve_all_non_empty()

if args.filter:
print(
"Already finished Fragments are filtered. Finished"
"fragments are defined in './annotations.json' file"
)
finished_fragments = json.load(open("ebl/fragmentarium/annotations.json"))[
"finished"
]

annotation_collection = list(
filter(
lambda elem: str(elem.fragment_number) in [*finished_fragments],
annotation_collection,
if args.filter not in ["finished", "unfinished", "selected"]:
raise argparse.ArgumentError(
None,
message="Filter has to be either 'finished', 'unfinished' or 'selected'",
)
)
print(f"'{args.filter}' Fragments are filtered.")
if args.filter == "selected" or args.filter == "finished":
filter_fragments = json.load(open("ebl/fragmentarium/annotations.json"))[
args.filter
]
annotation_collection = list(
filter(
lambda elem: str(elem.fragment_number) in filter_fragments,
annotation_collection,
)
)
else:
filter_fragments = json.load(open("ebl/fragmentarium/annotations.json"))[
"finished"
]
annotation_collection = list(
filter(
lambda elem: str(elem.fragment_number) not in filter_fragments,
annotation_collection,
)
)

if args.classification:
# For Sign Classification (Bounding Boxes have to be cropped for Image Classification)
TO_FILTER = [
Expand Down

0 comments on commit 732c078

Please sign in to comment.