Ejemplo n.º 1
0
    def __init__(self, augmented_pascal=True, ignore_label=255):
        self.root = settings.get_config_dir('pascal_voc')
        self.augmented_pascal = augmented_pascal
        self.ignore_label = ignore_label
        if augmented_pascal:
            self._train_files = self.file_list(os.path.join(self.root, 'ImageSets', 'SegmentationAug', 'train_aug.txt'))
            self._val_files = self.file_list(os.path.join(self.root, 'ImageSets', 'SegmentationAug', 'val.txt'))
        else:
            self._train_files = self.file_list(os.path.join(self.root, 'ImageSets', 'Segmentation', 'train.txt'))
            self._val_files = self.file_list(os.path.join(self.root, 'ImageSets', 'Segmentation', 'val.txt'))

        self.num_classes = 21

        self.class_names = ['background',  # always index 0
                            'aeroplane', 'bicycle', 'bird', 'boat',
                            'bottle', 'bus', 'car', 'cat', 'chair',
                            'cow', 'diningtable', 'dog', 'horse',
                            'motorbike', 'person', 'pottedplant',
                            'sheep', 'sofa', 'train', 'tvmonitor']
Ejemplo n.º 2
0
def main():
  """Run the program."""
  # Check for --loglevel, --debug, we deal with them by ourselves because
  # option parser also use logging.
  loglevel = None
  for idx, arg in enumerate(sys.argv):
    if '--loglevel' in arg:
      if '=' in arg:
        loglevel = arg.split('=')[1]
      else:
        loglevel = sys.argv[idx + 1]
      level = getattr(logging, loglevel.upper(), None)
      if level is None:
          raise ValueError('Invalid log level: %s' % loglevel)
      loglevel = level
  else:
    if '--debug' in sys.argv or '-d' in sys.argv:
      loglevel = logging.DEBUG
  logging.basicConfig(
      level=loglevel,
      format='%(filename)s [%(lineno)d]: %(levelname)s %(message)s')
  if loglevel is None:
    # Disabling warning, info, debug messages
    logging.disable(logging.WARNING)

  opts = create_options()
  opts.read_ini_file(os.path.join(settings.get_config_dir(), 'config'))
  desc = _('Usage: %prog [Options...]')
  opts.parse_args(desc, sys.argv)

  if opts.version:
    show_version()
    sys.exit(0)
  if opts.smaller:
    opts.scale = 0.75
  elif opts.larger:
    opts.scale = 1.25

  opts.themes = settings.get_themes()
  if opts.list_themes:
    print _('Available themes:')
    print
    theme_names = sorted(opts.themes)
    name_len = max(len(name) for name in theme_names)
    for theme in theme_names:
      print (' - %%-%ds: %%s' % name_len) % (theme, opts.themes[theme][0])
    raise SystemExit()
  elif opts.theme and opts.theme not in opts.themes:
    print _('Theme %r does not exist') % opts.theme
    print
    print _('Please make sure %r can be found in '
            'one of the following directories:') % opts.theme
    print
    for theme_dir in settings.get_config_dirs('themes'):
      print ' - %s' % theme_dir
    sys.exit(-1)
  if opts.reset:
    print _('Resetting to defaults.')
    opts.reset_to_defaults()
    opts.save()
  keymon = KeyMon(opts)
  try:
    gtk.main()
  except KeyboardInterrupt:
    keymon.quit_program()
Ejemplo n.º 3
0
def main():
  """Run the program."""
  # Check for --loglevel, --debug, we deal with them by ourselves because
  # option parser also use logging.
  loglevel = None
  for idx, arg in enumerate(sys.argv):
    if '--loglevel' in arg:
      if '=' in arg:
        loglevel = arg.split('=')[1]
      else:
        loglevel = sys.argv[idx + 1]
      level = getattr(logging, loglevel.upper(), None)
      if level is None:
          raise ValueError('Invalid log level: %s' % loglevel)
      loglevel = level
  else:
    if '--debug' in sys.argv or '-d' in sys.argv:
      loglevel = logging.DEBUG
  logging.basicConfig(
      level=loglevel,
      format='%(filename)s [%(lineno)d]: %(levelname)s %(message)s')
  if loglevel is None:
    # Disabling warning, info, debug messages
    logging.disable(logging.WARNING)

  opts = create_options()
  opts.read_ini_file(os.path.join(settings.get_config_dir(), 'config'))
  desc = _('Usage: %prog [Options...]')
  opts.parse_args(desc, sys.argv)

  if opts.version:
    show_version()
    sys.exit(0)
  if opts.smaller:
    opts.scale = 0.75
  elif opts.larger:
    opts.scale = 1.25

  opts.themes = settings.get_themes()
  if opts.list_themes:
    print _('Available themes:')
    print
    theme_names = sorted(opts.themes)
    name_len = max(len(name) for name in theme_names)
    for theme in theme_names:
      print (' - %%-%ds: %%s' % name_len) % (theme, opts.themes[theme][0])
    raise SystemExit()
  elif opts.theme and opts.theme not in opts.themes:
    print _('Theme %r does not exist') % opts.theme
    print
    print _('Please make sure %r can be found in '
            'one of the following directories:') % opts.theme
    print
    for theme_dir in settings.get_config_dirs('themes'):
      print ' - %s' % theme_dir
    sys.exit(-1)
  if opts.reset:
    print _('Resetting to defaults.')
    opts.reset_to_defaults()
    opts.save()
  keymon = KeyMon(opts)
  try:
    gtk.main()
  except KeyboardInterrupt:
    keymon.quit_program()