示例#1
0
def savePickle(relfn, obj):
    #create parent path if not exist
    fn = os.path.abspath(relfn)
    parentPath = Dir.getPathFilename(fn)
    Dir.createIfNExist(parentPath)
    with open(fn, 'wb') as fd:
        pickle.dump(obj, fd)
示例#2
0
    def __init__(self, path, ltype, projectName, expName):
        self.path = os.path.join(path, expName)
        if (ltype == 'tb' or ltype == 'filesystem'):
            Dir.createIfNExist(self.path)
        self.ltype = ltype
        self.step = 0
        if (self.ltype == 'wandb'):
            wandb.init(project=projectName, name=expName)
        elif (self.ltype == 'tb'):
            self.writer = SummaryWriter(self.path)

        self.profiler_time = {}
        self.profiler_memory = {}
示例#3
0
    def __init__(self, opts, info=None):
        load_params, store_params = opts.load_params, opts.store_params
        if (load_params):
            expName = opts.expname
            path = opts.logdir
            params_fn = os.path.join(path, expName, './app_params.pickle')
            opts = cvgutil.loadPickle(params_fn)
            print('loaded ', params_fn)

        self.opts = opts
        path = opts.logdir
        ltype = opts.logger
        projectName = opts.projectname
        expName = opts.expname

        self.path_train = os.path.join(path, expName, 'train')
        self.path_val = os.path.join(path, expName, 'val')
        self.path_test = os.path.join(path, expName, 'test')
        print('log path: ', os.path.join(path, expName))
        if (ltype == 'tb' or ltype == 'filesystem'):
            Dir.createIfNExist(self.path_train)
            Dir.createIfNExist(self.path_val)
            Dir.createIfNExist(self.path_test)
        self.ltype = ltype
        self.step = 0
        if (self.ltype == 'wandb'):
            wandb.init(project=projectName, name=expName)
        elif (self.ltype == 'tb'):
            self.writer_train = SummaryWriter(self.path_train)
            self.writer_val = SummaryWriter(self.path_val)
            self.writer_test = SummaryWriter(self.path_test)

        self.profiler_time = {}
        self.profiler_memory = {}

        if (store_params):
            params_fn = os.path.join(path, expName, './app_params.pickle')
            cvgutil.savePickle(params_fn, opts)
            print('stored ', params_fn)
            exit(0)

        self.info = self.opts.__dict__
        if (self.info is not None):
            #additional info
            cmd = 'git rev-parse HEAD'
            head_id = subprocess.check_output(cmd, shell=True)
            readabletime = datetime.datetime.fromtimestamp(
                time.time()).strftime("%m/%d/%Y, %H:%M:%S")
            self.info.update({'head_id': head_id, 'datetime': readabletime})
            self.addDict(self.info, 'info')
示例#4
0
import cvgutils.Mitsuba2XML as mts
import cvgutils.Linalg as lin
import cvgutils.Dir as dr
import numpy as np
import torch
if __name__ == "__main__":
    outdir = '/home/mohammad/Projects/NRV/dataset/simple/trainData'
    outdirTest ='/home/mohammad/Projects/NRV/dataset/simple/testData'
    outfmt = '%04d-%04d.png'
    outfmtmask = 'mask-%04d-%04d.png'
    
    texturefn = 'cvgutils/tests/testimages/5x5pattern.png'
    objfn = 'cvgutils/tests/testobjs/z.obj'
    dr.createIfNExist(outdir)
    dr.createIfNExist(outdirTest)
    center = [0,0,0]
    intensity = [1.0,1.0,1.0]
    nsamples = 15
    radius = 0.8
    diffuseReflectanceMask = [1.0,1.0,1.0]
    specularReflectance = [1.0,1.0,1.0]
    diffuseReflectance = texturefn
    dxs = torch.Tensor([0.0,1.0,0.0]) * 0.2
    camOrig = torch.Tensor([0.0,0.0,-1.0])
    # camLookAt = torch.Tensor([0.0,0.0,0.0])
    camLookAt = torch.Tensor([0,0,0])
    camUp = torch.Tensor([0.000,1.0,0.000])

    ntheta = 10
    nphi = 10
    nthetal = 15