def GetRegionDescriptionsOfImage(id=61512): """ Get the region descriptions of an image. """ image = GetImageData(id=id) data = utils.RetrieveData('/api/v0/images/' + str(id) + '/regions') if 'detail' in data and data['detail'] == 'Not found.': return None return utils.ParseRegionDescriptions(data, image)
def GetAllRegionDescriptions(dataDir=None): if dataDir is None: dataDir = utils.GetDataDir() dataFile = os.path.join(dataDir, 'region_descriptions.json') imageData = GetAllImageData(dataDir) imageMap = {} for d in imageData: imageMap[d.id] = d images = json.load(open(dataFile)) output = [] for image in images: output.append(utils.ParseRegionDescriptions(image['regions'], imageMap[image['id']])) return output