RasmusRPaulsen/Deep-MVLM

AttributeError: 'NoneType' object has no attribute 'GetMapper'

cuixin1992 opened this issue · 9 comments

Hi, thank you for your wonderful work, I have learned a lot from your code. But could you have me with this question?
I want to prepare rendered data using my raw data (.wrl, .bmp, and the landmark .txt files). But when run the preparedata.py file, I got the following problems. Unfortunately, I can not solve it. Do you know anything about it? I guess there is some format difference between your data and mine. If it is possible, could you share a set of example data for training? Maybe the data from DTU dataset because the BU_3DFE dataset is not available to download freely.

Preparing BU-3DFE data
Read 10 file ids
Processing 7 file ids for training
Processing F0001\F0001_AN02WH
F0001\F0001_AN02WH is locked - skipping
Processing F0001\F0001_AN03WH
F0001\F0001_AN03WH is locked - skipping
Processing F0001\F0001_AN04WH
F0001\F0001_AN04WH is locked - skipping
Processing F0001\F0001_DI01WH
Rendering F0001\F0001_DI01WH
Error near line 2: parse error
Traceback (most recent call last):
File "D:/07_AutomaticLandmarking/Paulsen_DeepMVLM/preparedata.py", line 349, in
main(cfg_global)
File "D:/07_AutomaticLandmarking/Paulsen_DeepMVLM/preparedata.py", line 334, in main
prepare_bu_3dfe_data(config)
File "D:/07_AutomaticLandmarking/Paulsen_DeepMVLM/preparedata.py", line 327, in prepare_bu_3dfe_data
process_file_bu_3dfe(config, base_name, output_dir)
File "D:/07_AutomaticLandmarking/Paulsen_DeepMVLM/preparedata.py", line 97, in process_file_bu_3dfe
pd = vrmlin.GetRenderer().GetActors().GetLastActor().GetMapper().GetInput()
AttributeError: 'NoneType' object has no attribute 'GetMapper'

hi @cuixin1992, it seems your error comes from VTK module in preparedata.py file :
` vrmlin = vtk.vtkVRMLImporter()
vrmlin.SetFileName(name_pd)
vrmlin.Update()

pd = vrmlin.GetRenderer().GetActors().GetLastActor().GetMapper().GetInput()`

try to see if you installed the right version of vtk

Hi, @bilelmnasser, thank you for your answer.
I install the same version of packages with the author, except the libnetcdf 4.7.1. Mine is libnetcdf 4.6.1 I really cannot find the same version.

After several tries, I got the 'GetMapper' problem using some data. For several data, I can run the preparedata.py without error. But I got the blank images. I prepared .bmp and .wrl scanned by Artec hand scanner. I am not sure what's wrong with my data.
image

Hi,
The problem is that the code is using vtk.vtkVRMLImporter() that only supports VRML 2.0.

The file from @cuixin1992 is in VRML 1.0 and therefore the file parser fails.

There are no easy ways to fix this from my side.

If you in any way can convert your files from VRML 1.0 to VRML 2.0 it should work.

Also do remember, that you should apply a pre-transformation if your scans are not roughly aligned to the default coordinate system. Let me know if this is an issue.

Best,
Rasmus

@cuixin1992 I now managed to make the code running with your data. What I did was:

  • used http://www.interocitors.com/polyhedra/vr1tovr2/index.html to convert the scan to VRML 2.0
  • used the geometry only pre-trained network for BU-3DFE (configs/BU_3DFE-geometry.json)
  • Used a pre-rotation (-90 degrees around y axis) in the JSON file:
    "pre-align": {
    "align_center_of_mass" : false,
    "rot_x": 0,
    "rot_y": -90,
    "rot_z": 0,
    "scale": 1,
    "write_pre_aligned": false
    }

This way the landmarks are successfully found on one of the test scans.

Please let me know if this approach does not work.

Thank you very much for your instructions.
After changing the data to VRML 2.0, I can use the preparedata.py without error. But I still got one problem that the output rendering files were empty. I wonder if you can get the rendered images using my data.
I think it is not the rotation problem because I tried your method by your code and I also tried to roughly align them manually. There is no change to the result.
image

I agree that preparedata.py is not very user friendly. Unless your data is exactly in the format of BU_3DFE it needs quite some code tweaking. Some things can be done by modifying the JSON file that you use. I managed to make renderings of your data by setting:

    "type": "MVLMModel",
    "args": {
        "n_landmarks": 15,
        "n_features": 256,
        "dropout_rate": 0.2,
        "image_channels": "RGB"
    }

"process_3d": {
"filter_view_lines": "quantile",
"heatmap_max_quantile": 0.5,
"heatmap_abs_threshold": 0.5,
"write_renderings": false,
"off_screen_rendering": true,
"min_x_angle": -20,
"max_x_angle": 20,
"min_y_angle": -130,
"max_y_angle": -50,
"min_z_angle": -20,
"max_z_angle": 20
},

"pre-align": {
	"align_center_of_mass" : false,
	"rot_x": 0,
	"rot_y": 0,
	"rot_z": 0,
	"scale": 1,
	"write_pre_aligned": false
}

If you have further issues, please show me the console output.

No, I think you did a great job! It is not the problem of your code, it is my problem. I am still a beginner at coding, so I can't solve problems very smoothly. But thanks to your help, I further understood your code and learned a lot. And I am sorry I took up a lot of your time.
I tried your rotation and tried many combinations that may work in my opinion. And I also manually aligned data. But I still got the blank rendered images, which let me guess, I have other problems. I think I still didn't read the .wrl properly.

Here are the console output and variable output.
image
image
image

@RasmusRPaulsen Hi, Prof. Rasmus R. Paulsen, how are you doing? Are you still very busy? Actually, I had not found where the problem is. I did not solve the rendering problem yet. I check the scale and the direction of the face, but it seems that the problem not happened here. I wonder did you successfully rendered the data I sent you? If so, I will further check the alignment problem. Thank you very much.