olgaliak / active-learning-detect

Active learning + object detection

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

add labels that project was not initialized with

abfleishman opened this issue · comments

Sometimes when tagging new labels that were not thought of when the project was initialized are needed. Essentially, it would be nice to be able to add classes to the config.ini and have the pascal_label_map update automatically with the new labels.

@yashpande provided this code
The code to make a new label map file:

with open(config_file["label_map_path"], "w") as map_file:
       for index, name in enumerate(config_file["classes"].split(","), 1):
           map_file.write("item {{\n  id: {}\n  name: '{}'\n}}".format(index, name))

The easiest way is probably just to manually fill in the variables config_file["label_map_path"] and config_file["classes"] then run it as an independent script.
You might want to add an issue about just having that code run each time training kicks off.

@olgaliak The best place for this would likely be in convert_tf_record.py in line 73. Since config_file["classes"] is already a parameter (tag_names) you would simply also have to send the config_file["label_map_path"] parameter as label_map_path and then you could use the code:

with open(label_map_path, "w") as map_file:
    for index, name in enumerate(tag_names, 1):
        map_file.write("item {{\n  id: {}\n  name: '{}'\n}}".format(index, name))

I added this in the yash/features branch. Please let me know if it works / throws errors 😃