|
@@ -1,9 +1,6 @@
|
|
-import argparse
|
|
|
|
-import codecs
|
|
|
|
import functools
|
|
import functools
|
|
import os.path
|
|
import os.path
|
|
import re
|
|
import re
|
|
-import sys
|
|
|
|
import warnings
|
|
import warnings
|
|
import webbrowser
|
|
import webbrowser
|
|
|
|
|
|
@@ -13,8 +10,6 @@ from qtpy import QtGui
|
|
from qtpy import QtWidgets
|
|
from qtpy import QtWidgets
|
|
|
|
|
|
from labelme import __appname__
|
|
from labelme import __appname__
|
|
-from labelme import __version__
|
|
|
|
-from labelme import logger
|
|
|
|
from labelme import QT5
|
|
from labelme import QT5
|
|
|
|
|
|
from labelme.config import get_config
|
|
from labelme.config import get_config
|
|
@@ -48,9 +43,6 @@ from labelme.widgets import ZoomWidget
|
|
# - Zoom is too "steppy".
|
|
# - Zoom is too "steppy".
|
|
|
|
|
|
|
|
|
|
-# Utility functions and classes.
|
|
|
|
-
|
|
|
|
-
|
|
|
|
class WindowMixin(object):
|
|
class WindowMixin(object):
|
|
def menu(self, title, actions=None):
|
|
def menu(self, title, actions=None):
|
|
menu = self.menuBar().addMenu(title)
|
|
menu = self.menuBar().addMenu(title)
|
|
@@ -1295,113 +1287,3 @@ def read(filename, default=None):
|
|
return f.read()
|
|
return f.read()
|
|
except Exception:
|
|
except Exception:
|
|
return default
|
|
return default
|
|
-
|
|
|
|
-
|
|
|
|
-def main():
|
|
|
|
- parser = argparse.ArgumentParser()
|
|
|
|
- parser.add_argument('--version', '-V', action='store_true',
|
|
|
|
- help='show version')
|
|
|
|
- parser.add_argument('filename', nargs='?', help='image or label filename')
|
|
|
|
- parser.add_argument('--output', '-O', '-o', help='output label name')
|
|
|
|
- default_config_file = os.path.join(os.path.expanduser('~'), '.labelmerc')
|
|
|
|
- parser.add_argument(
|
|
|
|
- '--config',
|
|
|
|
- dest='config_file',
|
|
|
|
- help='config file (default: %s)' % default_config_file,
|
|
|
|
- default=default_config_file,
|
|
|
|
- )
|
|
|
|
- # config for the gui
|
|
|
|
- parser.add_argument(
|
|
|
|
- '--nodata',
|
|
|
|
- dest='store_data',
|
|
|
|
- action='store_false',
|
|
|
|
- help='stop storing image data to JSON file',
|
|
|
|
- default=argparse.SUPPRESS,
|
|
|
|
- )
|
|
|
|
- parser.add_argument(
|
|
|
|
- '--autosave',
|
|
|
|
- dest='auto_save',
|
|
|
|
- action='store_true',
|
|
|
|
- help='auto save',
|
|
|
|
- default=argparse.SUPPRESS,
|
|
|
|
- )
|
|
|
|
- parser.add_argument(
|
|
|
|
- '--nosortlabels',
|
|
|
|
- dest='sort_labels',
|
|
|
|
- action='store_false',
|
|
|
|
- help='stop sorting labels',
|
|
|
|
- default=argparse.SUPPRESS,
|
|
|
|
- )
|
|
|
|
- parser.add_argument(
|
|
|
|
- '--flags',
|
|
|
|
- help='comma separated list of flags OR file containing flags',
|
|
|
|
- default=argparse.SUPPRESS,
|
|
|
|
- )
|
|
|
|
- parser.add_argument(
|
|
|
|
- '--labels',
|
|
|
|
- help='comma separated list of labels OR file containing labels',
|
|
|
|
- default=argparse.SUPPRESS,
|
|
|
|
- )
|
|
|
|
- parser.add_argument(
|
|
|
|
- '--validatelabel',
|
|
|
|
- dest='validate_label',
|
|
|
|
- choices=['exact', 'instance'],
|
|
|
|
- help='label validation types',
|
|
|
|
- default=argparse.SUPPRESS,
|
|
|
|
- )
|
|
|
|
- parser.add_argument(
|
|
|
|
- '--keep-prev',
|
|
|
|
- action='store_true',
|
|
|
|
- help='keep annotation of previous frame',
|
|
|
|
- default=argparse.SUPPRESS,
|
|
|
|
- )
|
|
|
|
- parser.add_argument(
|
|
|
|
- '--epsilon',
|
|
|
|
- type=float,
|
|
|
|
- help='epsilon to find nearest vertex on canvas',
|
|
|
|
- default=argparse.SUPPRESS,
|
|
|
|
- )
|
|
|
|
- args = parser.parse_args()
|
|
|
|
-
|
|
|
|
- if args.version:
|
|
|
|
- print('{0} {1}'.format(__appname__, __version__))
|
|
|
|
- sys.exit(0)
|
|
|
|
-
|
|
|
|
- if hasattr(args, 'flags'):
|
|
|
|
- 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 hasattr(args, 'labels'):
|
|
|
|
- if os.path.isfile(args.labels):
|
|
|
|
- with codecs.open(args.labels, 'r', encoding='utf-8') as f:
|
|
|
|
- args.labels = [l.strip() for l in f if l.strip()]
|
|
|
|
- else:
|
|
|
|
- args.labels = [l for l in args.labels.split(',') if l]
|
|
|
|
-
|
|
|
|
- config_from_args = args.__dict__
|
|
|
|
- config_from_args.pop('version')
|
|
|
|
- filename = config_from_args.pop('filename')
|
|
|
|
- output = config_from_args.pop('output')
|
|
|
|
- config_file = config_from_args.pop('config_file')
|
|
|
|
- config = get_config(config_from_args, config_file)
|
|
|
|
-
|
|
|
|
- if not config['labels'] and config['validate_label']:
|
|
|
|
- logger.error('--labels must be specified with --validatelabel or '
|
|
|
|
- 'validate_label: true in the config file '
|
|
|
|
- '(ex. ~/.labelmerc).')
|
|
|
|
- sys.exit(1)
|
|
|
|
-
|
|
|
|
- app = QtWidgets.QApplication(sys.argv)
|
|
|
|
- app.setApplicationName(__appname__)
|
|
|
|
- app.setWindowIcon(newIcon('icon'))
|
|
|
|
- win = MainWindow(config=config, filename=filename, output=output)
|
|
|
|
- win.show()
|
|
|
|
- win.raise_()
|
|
|
|
- sys.exit(app.exec_())
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-if __name__ == '__main__':
|
|
|
|
- main()
|
|
|