Răsfoiți Sursa

Check --labels and --validatelabel

Kentaro Wada 7 ani în urmă
părinte
comite
f1155252dd
1 a modificat fișierele cu 12 adăugiri și 2 ștergeri
  1. 12 2
      labelme/app.py

+ 12 - 2
labelme/app.py

@@ -1,5 +1,6 @@
 import argparse
 import functools
+import logging
 import os.path
 import re
 import sys
@@ -36,6 +37,10 @@ from labelme.zoomWidget import ZoomWidget
 __appname__ = 'labelme'
 
 
+logging.basicConfig(level=logging.INFO)
+logger = logging.getLogger(__appname__)
+
+
 # FIXME
 # - [medium] Set max zoom value to something big enough for FitWidth/Window
 
@@ -474,7 +479,8 @@ class MainWindow(QtWidgets.QMainWindow, WindowMixin):
         def update_dict(target_dict, new_dict):
             for key, value in new_dict.items():
                 if key not in target_dict:
-                    print('Skipping unexpected key in config: {}'.format(key))
+                    logger.warn('Skipping unexpected key in config: {}'
+                                .format(key))
                     continue
                 if isinstance(target_dict[key], dict) and \
                         isinstance(value, dict):
@@ -1222,7 +1228,11 @@ def main():
                         help='label validation types')
     args = parser.parse_args()
 
-    if args.labels is not None:
+    if args.labels is None:
+        if args.validatelabel is not None:
+            logger.error('--labels must be specified with --validatelabel')
+            sys.exit(1)
+    else:
         if os.path.isfile(args.labels):
             args.labels = [l.strip() for l in open(args.labels, 'r')
                            if l.strip()]