myavartanoo / 3DIAS_PyTorch

Official implementation of the paper "3DIAS: 3D Shape Reconstruction with Implicit Algebraic Surfaces" (ICCV 2021)
23 stars 1 forks source link

Unable to understand _gen_polycoeff_center function in model.py #1

Open achi9629 opened 2 years ago

achi9629 commented 2 years ago

Hi, @robot0321, @myavartanoo, @Reyhanehne I understand what the _pd_full function of the Shape3DModel class in model.py is doing, but I cannot understand what _gen_polycoeff_center is doing? Intuitively it is finding primitives with centres; calculation in the code is complicated to understand. Can you please help in understanding it?

myavartanoo commented 2 years ago

Thank you very much for your question. In _gen_polycoeff_center we translate the center of each primitive to the learned origins and simplify the algebraic surfaces to their standard forms to make the later operations easier. EX. f(x)=(x-a)^2 ---> f(x)=x^2-2ax+a^2. Therefore, in this example the coefficients change from [1,0,0] to [1,-2a,a^2].

achi9629 commented 2 years ago

@myavartanoo, @robot0321, @Reyhanehne Thank you for the reply, I understood the above example. But I am still unable to understand for which polynomials the 35 coefficients of polycoeff_center refer. For eg in pcoeff/net_params, all values refer to the 35 coefficients of [1, z, z^2, z^3, y, yz, yz^2, y^2, y^2z, y^3, x, xz, xz^2, xy, xyz, xy^2, x^2, x^2z, x^2y, x^3,z^4, yz^3, y^2z^2, y^3z, y^4, xz^3, xyz^2, xy^2z, xy^3, x^2z^2, x^2yz, x^2y^2, x^3z, x^3y, x^4]. Similarly what is the order of coefficients of the polycoeff_center? Like how the value of *polycoeff_center[:,19,:] is calculated as net_params[:, 19, :] - net_params[:, 32, :](origins[:,2,:]) - net_params[:, 33, :](origins[:,1,:]) - (4)net_params[:, 34, :](origins[:,0,:]), and value of polycoeff_center[:,0,:]** as the long calculation at the line no. 133 of model.py code etc

myavartanoo commented 2 years ago

Same as the above example each x, y, and z variable will be translated by o1, o2, and o3. Therefore, the new variables will be x-o1, y-o2, and z-o3. If you replace these new variables in the polynomial functions and try to simplify them as the above example, the coefficients of the terms with the degree of 4 such as x^4, x^3y, x^2zy, ... will be the same as before (like the coefficient of x^2 in the above example) which results: polycoeff_center[:, 20:, :] = net_params[:, 20:, :]. On the other hand the new coefficients for the other terms with the degree 3 or less than 3 can be computed by the equations in lines 133-172 of model.py. You can try to simplify the polynomial function ∑(x-o1)^i(y-o2)^j(z-o3)^k for 0≤i+j+k≤4 and obtain the equations by yourself.

achi9629 commented 2 years ago

Got it fully, thank you. one more doubt, why you have calculated logits at line 202 in model.py.

Also, you have used Houdini to extract the inside/outside/on points and the normal vectors of the shapenet dataset used in 3d-r2n2: A unified approach for single and multi-view 3d object reconstruction. Do you have the original shapenet dataset by any chance before extracting points as your naming convention is for each image (line for plane dataset 0000, 0001, 0002 etc) is different from 3D-R2N2 so it is difficult to map images to the labels before (in, out, on, norm) labels. Thank you

myavartanoo commented 2 years ago

Sorry for the ambiguity, we do not use the logits. The code is updated now.

We follow Occupancy Networks to generate watertight meshes. It generates three files train.lst, test.lst, and val.lst then you can use them to map the corresponding names.

achi9629 commented 2 years ago

Thank You, for the clarification, I have successfully run the model and used the Occupancy Networks to generate watertight meshes. For further work, I was thinking of using these results i.e vertices got from this 3DIAS model as the input for the pixel2mesh++ paper. For pixel2mesh++ we need a mesh with vertices and adjacency matrices, the output results of 3DIAS give vertices and faces, is there any way to get the adjacency matrices of these vertices also?