CoolFace
Apppublic

blanchon/Metric3D

sourceHugging Facegpl-3.0updated 2y agoView on Hugging Face
0likes
custom_data.py34 linesDownload Raw Back to utils
1import glob2import os3import json4import cv25 6def load_from_annos(anno_path):7    with open(anno_path, 'r') as f:8        annos = json.load(f)['files']9 10    datas = []11    for i, anno in enumerate(annos):12        rgb = anno['rgb']13        depth = anno['depth'] if 'depth' in anno else None14        depth_scale = anno['depth_scale'] if 'depth_scale' in anno else 1.015        intrinsic = anno['cam_in'] if 'cam_in' in anno else None16        normal = anno['normal'] if 'normal' in anno else None17 18        data_i = {19            'rgb': rgb,20            'depth': depth,21            'depth_scale': depth_scale,22            'intrinsic': intrinsic,23            'filename': os.path.basename(rgb),24            'folder': rgb.split('/')[-3],25            'normal': normal26        }27        datas.append(data_i)28    return datas29 30def load_data(path: str):31    rgbs = glob.glob(path + '/*.jpg') + glob.glob(path + '/*.png')32    #intrinsic =  [835.8179931640625, 835.8179931640625, 961.5419921875, 566.8090209960938] #[721.53769, 721.53769, 609.5593, 172.854]33    data = [{'rgb': i, 'depth': None, 'intrinsic': None, 'filename': os.path.basename(i), 'folder': i.split('/')[-3]} for i in rgbs]34    return data