Beispiel #1
0
    def __init__(self):
        # Parse config
        settings.parse()

        # Init database
        self.session_factory = model.create_session_factory()

        # Init
        import routes
        tornado.web.Application.__init__(self, routes.load(), **settings.get_app_settings())
Beispiel #2
0
def segment(settings_file):

    version = '2016-7-12'

    print "Loading settings from %s..." % settings_file
    runs = settings.parse(settings_file)

    for i, run in enumerate(runs):

        print('Segment - running configuration %d of %d from %s' %
              (i + 1, len(runs), settings_file))

        # Get list of images in directory
        image_list = images.list_files(run['directory'], run['input_ext'])

        # Set up additonal run parameters
        run['image_file_label'] = 'th=%05.4f_size=%04.0fu-%04.0fu' % (
            run['threshold'], run['minimum_size'], run['maximum_size'])

        run['image_label'] = contruct_image_label(run, version)

        if not os.path.exists(run['full_output']):
            os.makedirs(run['full_output'])

        top_image_filename = image_list[-1]
        objects, _ = setup_object_boxes(top_image_filename, run)

        if run['mode'] == 'final':

            # sanity check to avoid creating unnecessary file
            if len(objects) > 10000:
                sys.exit(
                    'Over 10,000 objects are identified in the image, are you sure you want to continue?'
                )

            print('Saving Settings into %s' % run['full_output'])
            settings.save(run.copy())

            # last plane in some image samples is not a true focus plane
            if run['skip_last_plane']:
                final_list = image_list[:-1]
            else:
                final_list = image_list

            # Loop over the planes we're interested in, load an image, then process it
            for plane_num, plane_image_filename in enumerate(final_list):

                final(plane_image_filename, objects, run, plane_num)
Beispiel #3
0
def segment(settings_file):

    version = '2016-7-12'

    print "Loading settings from %s..." % settings_file
    runs = settings.parse(settings_file)

    for i, run in enumerate(runs):

        print('Segment - running configuration %d of %d from %s'
              % (i+1, len(runs), settings_file))

        # Get list of images in directory
        image_list = images.list_files(run['directory'], run['input_ext'])

        # Set up additonal run parameters
        run['image_file_label'] = 'th=%05.4f_size=%04.0fu-%04.0fu' % (run['threshold'],
                                                                      run['minimum_size'],
                                                                      run['maximum_size'])

        run['image_label'] = contruct_image_label(run, version)

        if not os.path.exists(run['full_output']):
            os.makedirs(run['full_output'])

        top_image_filename = image_list[-1]
        objects, _ = setup_object_boxes(top_image_filename, run)

        if run['mode'] == 'final':

            # sanity check to avoid creating unnecessary file
            if len(objects) > 10000:
                sys.exit('Over 10,000 objects are identified in the image, are you sure you want to continue?')

            print('Saving Settings into %s' % run['full_output'])
            settings.save(run.copy())

            # last plane in some image samples is not a true focus plane
            if run['skip_last_plane']:
                final_list = image_list[:-1]
            else:
                final_list = image_list

            # Loop over the planes we're interested in, load an image, then process it
            for plane_num, plane_image_filename in enumerate(final_list):

                final(plane_image_filename, objects, run, plane_num)
Beispiel #4
0
    def setUp(self):
        self.conf1 = SomeSettings()
        self.conf2 = MoreSettings()
        self.conf2 = parse(MoreSettings(), StringIO('''
[settings]
item1=foo
integer=-23423
floatz=423.2
lines=23.3
    32.3
    42
keypair_of_lists=k:x,y,z
some_dict_thing={'foo': 1, 2: [1, 2, 3]}
a_long=12345678901234567890

[extra]
What Up=dog

[undeclared]
what=huh?
'''))
Beispiel #5
0
logger.setup()

with open(settings_filename, "r") as f:
  lines = f.readlines()
  # remove comments in json
  lines = map(lambda line: re.sub("/\*.*\*/", "", line), lines)
  settings_file_contents = "".join(lines)
settings_raw = json.loads(settings_file_contents)
#settings_log_text = None
# for line in log:
#   if line['Activity'] in ['Create', 'Update']:
#     settings_log_text = line['Data']
# settings_log_raw = json.loads(settings_log_text) if settings_log_text else settings_raw
# settings_in_log = settings.parse(settings_log_raw)
settings_in_file = settings.parse(settings_raw)
# settings_modified = (action is not "show status" and settings_in_log is not settings_in_file)
# TODO: bail if settings modified
settings = settings_in_file

## load hit metadata if it exists
hit_modes = dict()
hit = None
if os.path.isfile("hit_modes.json"):
  hit_modes = json.load(open("hit_modes.json", "r"))
  if mode in hit_modes:
    hit = hit_modes[mode]

## connect to amazon
mtc = connection.MTurkConnection(aws_access_key_id=ACCESS_ID,
                                 aws_secret_access_key=SECRET_KEY,
Beispiel #6
0
logger.setup()

with open(settings_filename, "r") as f:
  lines = f.readlines()
  # remove comments in json
  lines = map(lambda line: re.sub("/\*.*\*/", "", line), lines)
  settings_file_contents = "".join(lines)
settings_raw = json.loads(settings_file_contents)
#settings_log_text = None
# for line in log:
#   if line['Activity'] in ['Create', 'Update']:
#     settings_log_text = line['Data']
# settings_log_raw = json.loads(settings_log_text) if settings_log_text else settings_raw
# settings_in_log = settings.parse(settings_log_raw)
settings_in_file = settings.parse(settings_raw)
# settings_modified = (action is not "show status" and settings_in_log is not settings_in_file)
# TODO: bail if settings modified
settings = settings_in_file

## load hit metadata if it exists
hit_modes = dict()
hit = None
if os.path.isfile("hit_modes.json"):
  hit_modes = json.load(open("hit_modes.json", "r"))
  if mode in hit_modes:
    hit = hit_modes[mode]

## connect to amazon
mtc = connection.MTurkConnection(aws_access_key_id=ACCESS_ID,
                                 aws_secret_access_key=SECRET_KEY,