def get_region_descriptions_of_image(id=61512): """ Get the region descriptions of an image. """ image = get_image_data(id=id) data = utils.retrieve_data("/api/v0/images/" + str(id) + "/regions") if "detail" in data and data["detail"] == "Not found.": return None return utils.parse_region_descriptions(data, image)
def get_region_descriptions_of_image(id=61512): """ Get the region descriptions of an image. """ image = get_image_data(id=id) data = utils.retrieve_data('/api/v0/images/' + str(id) + '/regions') if 'detail' in data and data['detail'] == 'Not found.': return None return utils.parse_region_descriptions(data, image)
def get_region_descriptions_of_image(id=61512): """ Get the region descriptions of an image. """ image = get_image_data(id=id) data = utils.retrieve_data('/api/v0/images/' + str(id) + '/regions') if 'detail' in data and data['detail'] == 'Not found.': return None return utils.parse_region_descriptions(data, image)
def get_region_descriptions(image_ids, data_dir=None): """ Get all region descriptions. """ if data_dir is None: data_dir = utils.get_data_dir() data_file = os.path.join(data_dir, 'region_descriptions.json') image_data = get_all_image_data(data_dir, True) images = json.load(open(data_file)) output = [] for image in images: if image["id"] in image_ids and len(image["regions"]) > 0: output.append(utils.parse_region_descriptions( image['regions'], image_data[image['id']])) return output
def get_all_region_descriptions(data_dir=None): """ Get all region descriptions. """ if data_dir is None: data_dir = utils.get_data_dir() data_file = os.path.join(data_dir, 'region_descriptions.json') image_data = get_all_image_data(data_dir) image_map = {} for d in image_data: image_map[d.id] = d images = json.load(open(data_file)) output = [] for image in images: output.append(utils.parse_region_descriptions( image['regions'], image_map[image['id']])) return output
def get_all_region_descriptions(data_dir=None): """ Get all region descriptions. """ if data_dir is None: data_dir = utils.get_data_dir() data_file = os.path.join(data_dir, 'region_descriptions.json') image_data = get_all_image_data(data_dir) image_map = {} for d in image_data: image_map[d.id] = d images = json.load(open(data_file)) output = [] for image in images: output.append(utils.parse_region_descriptions( image['regions'], image_map[image['id']])) return output
def get_all_objects(data_dir=None): """ Get all region descriptions. """ if data_dir is None: data_dir = utils.get_data_dir() # In case when exact filename is passed if os.path.isdir(data_dir): data_file = os.path.join(data_dir, 'objects.json') else: dataFile = data_dir image_data = get_all_image_data(data_dir) image_map = {} for d in image_data: image_map[d.id] = d images = json.load(open(data_file)) output = [] for image in images: output.append( utils.parse_region_descriptions(image['regions'], image_map[image['id']])) return output