update
This commit is contained in:
+19
-19
@@ -13,10 +13,10 @@ parser.add_argument('-g', '--gpu', type=str)
|
||||
args = vars(parser.parse_args())
|
||||
|
||||
if args['debug']:
|
||||
from configs.iccvw.pyr_64_128_cape_f_2 import config
|
||||
from configs.iccvw.pyr_64_128_cape_f_2 import config_1
|
||||
else:
|
||||
config_module = importlib.import_module(args['config'])
|
||||
config = config_module.config
|
||||
config_1 = config_module.config
|
||||
|
||||
os.environ["CUDA_DEVICE_ORDER"]="PCI_BUS_ID"
|
||||
os.environ["CUDA_VISIBLE_DEVICES"] = args['gpu']
|
||||
@@ -53,26 +53,26 @@ from models.pyramid_model import Pyramid
|
||||
from models.cvae_model import CVAE
|
||||
|
||||
|
||||
uv2mesh = UV2Mesh(res=256, is_skirt=config['is_skirt'], is_smpl_orig=config['is_cape'])
|
||||
uv2mesh = UV2Mesh(res=256, is_skirt=config_1['is_skirt'], is_smpl_orig=config_1['is_cape'])
|
||||
|
||||
|
||||
def step_pyramid(batch):
|
||||
model.eval()
|
||||
with torch.inference_mode():
|
||||
levels_input, conds = group_inputs_for_levels(batch, config)
|
||||
levels_input, conds = group_inputs_for_levels(batch, config_1)
|
||||
|
||||
out_levels = model([levels_input, conds])
|
||||
pred, _, _ = out_levels[-1]
|
||||
|
||||
mesh_pred = uv2mesh(pred)
|
||||
|
||||
if config['use_skinning']:
|
||||
if config_1['use_skinning']:
|
||||
shape = batch['pose_shape'][:, 72:]
|
||||
gender = torch.greater_equal(shape[:, 10] , 0.5).to(dtype=torch.int64)
|
||||
shape_offsets = torch.stack([torch.tensordot(shape[i,:10][None, :], smpl.shapedirs[gender[i]], dims=[[1], [2]])[0,smpl.to_keep,:] for i in range(shape.shape[0])])
|
||||
|
||||
mesh_pred_shaped = mesh_pred + shape_offsets * batch['mesh_mask'][:,:,None]
|
||||
if not config['is_cape']:
|
||||
if not config_1['is_cape']:
|
||||
mesh_pred_posed = smpl(batch['pose_shape'][:, :72], batch['pose_shape'][:, 72:], mesh_pred_shaped)[0]
|
||||
else:
|
||||
mesh_pred_posed = mesh_pred_shaped
|
||||
@@ -83,7 +83,7 @@ def step_pyramid(batch):
|
||||
|
||||
|
||||
def step(batch):
|
||||
if config['use_skinning']:
|
||||
if config_1['use_skinning']:
|
||||
uv_orig = batch['uv_unposed']
|
||||
else:
|
||||
uv_orig = batch['uv_posed']
|
||||
@@ -92,7 +92,7 @@ def step(batch):
|
||||
pred, _, _ = model([uv_orig, batch['uv_static'], batch['uv_body_posed'], batch['uv_normals'], batch['uv_mask']])
|
||||
mesh_pred = uv2mesh(pred)
|
||||
|
||||
if config['use_skinning']:
|
||||
if config_1['use_skinning']:
|
||||
shape = batch['pose_shape'][:, 72:]
|
||||
gender = torch.greater_equal(shape[:, 10] , 0.5).to(torch.long)
|
||||
shape_offsets = torch.stack([torch.tensordot(shape[i,:10][None, :], smpl.shapedirs[gender[i]], dims=[[1], [2]])[0,smpl.to_keep,:] for i in range(shape.shape[0])])
|
||||
@@ -141,33 +141,33 @@ def generate():
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
smpl = SMPL(orig_smpl=config['is_cape'], path='smpl', device=config['device'])
|
||||
skirt_modifier = '_skirt' if config['is_skirt'] else ''
|
||||
smpl = SMPL(orig_smpl=config_1['is_cape'], path='smpl', device=config_1['device'])
|
||||
skirt_modifier = '_skirt' if config_1['is_skirt'] else ''
|
||||
dataset_resolutions = []
|
||||
if 'pyramid' in config:
|
||||
dataset_resolutions = config['pyramid']['resolutions'].copy()
|
||||
if 'pyramid' in config_1:
|
||||
dataset_resolutions = config_1['pyramid']['resolutions'].copy()
|
||||
if 512 not in dataset_resolutions:
|
||||
dataset_resolutions.append(512)
|
||||
|
||||
# remove all values from config['signature] that start with mesh_
|
||||
config['signature'] = set([x for x in config['signature'] if not x.startswith('mesh_')])
|
||||
config_1['signature'] = set([x for x in config_1['signature'] if not x.startswith('mesh_')])
|
||||
|
||||
dataset_test = Dataset(config['test_dir'], config['signature'], device=config['device'], frames_file=config['test_frames'], use_cache=config['dataset_in_memory'], resolutions=dataset_resolutions, is_cape=config['is_cape'])
|
||||
dataset_test = Dataset(config_1['test_dir'], config_1['signature'], device=config_1['device'], frames_file=config_1['test_frames'], use_cache=config_1['dataset_in_memory'], resolutions=dataset_resolutions, is_cape=config_1['is_cape'])
|
||||
# dataset_test = Dataset(config['test_dir'], config['signature'], device=config['device'], frames_file='frames_temp.txt', use_cache=config['dataset_in_memory'], resolutions=dataset_resolutions, is_cape=config['is_cape'])
|
||||
test_dataloader = DataLoader(dataset_test, batch_size=4, drop_last=True, shuffle=True, )
|
||||
|
||||
is_pyramid = config['name'].startswith('pyr')
|
||||
is_pyramid = config_1['name'].startswith('pyr')
|
||||
|
||||
if is_pyramid:
|
||||
model: Pyramid = Pyramid(config)
|
||||
model: Pyramid = Pyramid(config_1)
|
||||
else:
|
||||
model: CVAE = CVAE(config)
|
||||
model: CVAE = CVAE(config_1)
|
||||
|
||||
it = load_model(model, 'checkpoints/iccvw/' + config['name'], iteration=args['iteration'])
|
||||
it = load_model(model, 'checkpoints/iccvw/' + config_1['name'], iteration=args['iteration'])
|
||||
model.eval()
|
||||
# it = load_model(model, 'checkpoints/iccvw/' + config['name'])
|
||||
|
||||
name = config['name'] + '_' + str(it)
|
||||
name = config_1['name'] + '_' + str(it)
|
||||
|
||||
folder = '/data-local/127_2/results'
|
||||
out_folder = f'{folder}/{name}'
|
||||
|
||||
Reference in New Issue
Block a user