Sfoglia il codice sorgente

Specify flags by command line arguments

Kentaro Wada 7 anni fa
parent
commit
4abe716273
1 ha cambiato i file con 10 aggiunte e 0 eliminazioni
  1. 10 0
      labelme/app.py

+ 10 - 0
labelme/app.py

@@ -1249,6 +1249,9 @@ def main():
                         help='stop storing image data to JSON file')
     parser.add_argument('--autosave', dest='auto_save', action='store_true',
                         help='auto save')
+    parser.add_argument('--flags',
+                        help='comma separated list of flags OR file '
+                        'containing one flag per line')
     parser.add_argument('--labels',
                         help='comma separated list of labels OR file '
                         'containing one label per line')
@@ -1263,6 +1266,13 @@ def main():
         print('{0} {1}'.format(__appname__, __version__))
         sys.exit(0)
 
+    if args.flags is not None:
+        if os.path.isfile(args.flags):
+            with codecs.open(args.flags, 'r', encoding='utf-8') as f:
+                args.flags = [l.strip() for l in f if l.strip()]
+        else:
+            args.flags = [l for l in args.flags.split(',') if l]
+
     if args.labels is not None:
         if os.path.isfile(args.labels):
             with codecs.open(args.labels, 'r', encoding='utf-8') as f: