From 301cd41718ca0eb621848a2d538d931f96718672 Mon Sep 17 00:00:00 2001 From: cwang Date: Mon, 30 Jul 2018 17:16:29 -0500 Subject: [PATCH 1/2] minor save --- neural_renderer/load_obj.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/neural_renderer/load_obj.py b/neural_renderer/load_obj.py index 11be14b..bcc6c53 100644 --- a/neural_renderer/load_obj.py +++ b/neural_renderer/load_obj.py @@ -85,6 +85,14 @@ def load_textures(filename_obj, filename_mtl, texture_size): for material_name, filename_texture in texture_filenames.items(): filename_texture = os.path.join(os.path.dirname(filename_obj), filename_texture) image = imread(filename_texture).astype(np.float32) / 255. + + # texture image may have one channel (grey color) + if len(image.shape) == 2: + image = np.stack((image,)*3,-1) + # or has extral alpha channel shoule ignore for now + if image.shape[2] == 4: + image = image[:,:,:3] + # pytorch does not support negative slicing for the moment image = image[::-1, :, :] image = torch.from_numpy(image.copy()).cuda() From 06ea5cf496870db5fc785982bf71afcae74df5c1 Mon Sep 17 00:00:00 2001 From: cwang Date: Mon, 30 Jul 2018 17:21:40 -0500 Subject: [PATCH 2/2] minor save --- neural_renderer/load_obj.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/neural_renderer/load_obj.py b/neural_renderer/load_obj.py index bcc6c53..7043495 100644 --- a/neural_renderer/load_obj.py +++ b/neural_renderer/load_obj.py @@ -48,16 +48,16 @@ def load_textures(filename_obj, filename_mtl, texture_size): if line.split()[0] == 'f': vs = line.split()[1:] nv = len(vs) - if '/' in vs[0]: + if '/' in vs[0] and '//' not in vs[0]: v0 = int(vs[0].split('/')[1]) else: v0 = 0 for i in range(nv - 2): - if '/' in vs[i + 1]: + if '/' in vs[i + 1] and '//' not in vs[i + 1]: v1 = int(vs[i + 1].split('/')[1]) else: v1 = 0 - if '/' in vs[i + 2]: + if '/' in vs[i + 2] and '//' not in vs[i + 2]: v2 = int(vs[i + 2].split('/')[1]) else: v2 = 0