Open jay-thakur opened 5 years ago
I think the shape[0] is to make sure batch sizes are equal to each other. So you need to add an extra '0' dimension as batch size, like line25 and line26 in example3.py.
vertices, faces = neural_renderer.load_obj(filename_obj)
self.vertices = vertices[None, :, :]
self.faces = faces[None, :, :]
Hopefully my understanding is helpful to your problem.
And if you have time, please also take a look at my question #21 , which is also related to save_obj.py.
I believe, if we add extra '0' as you suggested, then vertices & faces will be of 3 dimension. & in save_obj() we have assert statement for vertices & faces to 2. Please correct me if i am wrong.
I am expecting to save the .obj with its texture . Do you have working code for the same? Could you please share your example3.py ?
Thanks, Jay
Hi Jay. For your concern, please check out my code at question #21. I am sharing my piece of code there.
But anyway, I just slice out the first dimension and feed the rest into save_obj. And I am also a little confused about your question. The vertices_to_faces is not called either in load_obj.py or save_obj.py. So I don't encounter any problem related to dimension assertion. Maybe it's because you are using torch edition from another repo, not exactly the same code as this repo?
For simplicity, here are the codes added before #draw object module in example3.py
# save obj with textures
#TODO: textures are not reasonable
model.textures_1 = cf.concat((model.textures, model.textures.transpose((0, 1, 4, 3, 2, 5))), axis=1)
neural_renderer.save_obj('result.obj', model.vertices[0], model.faces[0], cf.tanh(model.textures_1[0]).array)
Sorry, I am using another repo.
@jay-thakur Which repo are you using?
I have the same problem when saved the rendered object. The error said
cupy.cuda.compiler.CompileException: /tmp/tmp72lc77x3/44a6062960e6de87983184b4a18c1a10_2.cubin.cu(20): error: a value of type "const float *" cannot be used to initialize an entity of type "float *"
/tmp/tmp72lc77x3/44a6062960e6de87983184b4a18c1a10_2.cubin.cu(21): error: a value of type "const float *" cannot be used to initialize an entity of type "float *"
/tmp/tmp72lc77x3/44a6062960e6de87983184b4a18c1a10_2.cubin.cu(75): error: expression must be a modifiable lvalue
I think it's chain, cupy or cuda versions problem. I run in python3.8 and cuda10.2 What chain and cupy version should I select? thanks
I have the same problem when saved the rendered object. The error said
cupy.cuda.compiler.CompileException: /tmp/tmp72lc77x3/44a6062960e6de87983184b4a18c1a10_2.cubin.cu(20): error: a value of type "const float *" cannot be used to initialize an entity of type "float *" /tmp/tmp72lc77x3/44a6062960e6de87983184b4a18c1a10_2.cubin.cu(21): error: a value of type "const float *" cannot be used to initialize an entity of type "float *" /tmp/tmp72lc77x3/44a6062960e6de87983184b4a18c1a10_2.cubin.cu(75): error: expression must be a modifiable lvalue
I think it's chain, cupy or cuda versions problem. I run in python3.8 and cuda10.2 What chain and cupy version should I select? thanks
Hello, I have encountered the same issue as you. How did you resolve this problem? Was it related to the version?
Hi,
I used this code to save as .obj-
import chainer import numpy as np import scipy.misc import neural_renderer
renderer = neural_renderer.Renderer()
vertices, faces, textures = neural_renderer.load_obj( '/home/user/jay/straight.obj', load_texture=True, texture_size=16)
neural_renderer.save_obj('/home/user/jay/chainer_save.obj', vertices, faces, textures)
But facing issue in renderer.py. So i changed below code like this. faces = torch.cat((faces, faces[:, list(reversed(range(faces.shape[-1])))]), dim=1).detach()
Then i was getting error in vertices_to_faces.py so i changed below vertices & faces assert to 2. assert (vertices.ndimension() == 2) assert (faces.ndimension() == 2)
But I am getting error at assert (vertices.shape[0] == faces.shape[0]) because vertices.shape[0] = 34817 faces.shape[0] = 69630.
Where am i doing wrong ? Could you please help me to fix this?