fizyr / tf-retinanet

Apache License 2.0
115 stars 32 forks source link

Development #19

Closed vcarpani closed 5 years ago

vcarpani commented 5 years ago

This PR adds the parsing of additional options, here's an example: python ./train.py --o "{'backbone': {'name': 'resnet'}, 'generator': {'name': 'coco', 'details': {'data_dir': '/srv/datasets/COCO'}}}"

Also adds first draft of documentation.

Fix #20

hgaiser commented 5 years ago

Ah I see, not exactly what I had in mind. In git you can override your username and email like:

git -c user.name="Vivek Sury" -c user.email="v.sury@fizyr.com" commit

Likewise, as in your example, you could do:

python ./train.py -o backbone.name=resnet -o generator.name=coco -o generator.details.data_dir=/srv/datasets/COCO

It's a bit more work to parse these options (basically you would need to convert them to a dictionary), but it's more in line with other Linux tools.

hgaiser commented 5 years ago

This may also be very helpful with modules and multiple argument parsers, have a look to see if you think it's something we can use.

vcarpani commented 5 years ago

[This] may also be very helpful with modules and multiple argument parsers, have a look to see if you think it's something we can use.

I dont see any link

hgaiser commented 5 years ago

Awkward.. was supposed to link to this.

vcarpani commented 5 years ago

Unfortunately that library supports yaml list only in this format:

fruit: [apple, orange, lemon]

Not:

fruit:
 - apple
 - orange
 - lemon
vcarpani commented 5 years ago

Should be done now, the parsing is: python ./train.py --gpu 1 -o backbone.name=resnet -o generator.name=coco -o generator.details.data_dir=/srv/datasets/COCO

hgaiser commented 5 years ago

Unfortunately that library supports yaml list only in this format:

Hmm that is unfortunate. Still, it's maybe worth considering replacing argparse with something else (maybe still configargparse eventhough it doesn't support full yaml).

hgaiser commented 5 years ago

Checked that YAML parsing a bit for configargparse, the default parser doesn't allow for yaml in the form of:

fruits:
- apples
- pears

but if you construct the configargparse object like so:

p = configargparse.ArgParser(config_file_parser_class=configargparse.YAMLConfigFileParser)

Then it forces to use a YAML parser, which allows a more complete (full?) YAML syntax, including the multiline list syntax. The default parser is a flexible parser, allowing YAML / ini syntax, but then it is a bit limited in the exact syntax.

vcarpani commented 5 years ago

@enricoliscio can you have a look at this?