hnc-cad
hnc-cad copied to clipboard
pythonocc visualization error
Thank you for your amazing work. When visualizing sample results, the following error appears. Is it possible to identify the cause? Also, could you provide the version of pythonocc?
##### 3D rendering pipe initialisation #####
Display3d class initialization starting ...
0%| | 0/730 [00:00<?, ?it/s]
Traceback (most recent call last):
File "/media/data/hnc-cad/gen/cad_img.py", line 72, in <module>
main()
File "/media/data/hnc-cad/gen/cad_img.py", line 68, in main
render(shape, output_path.joinpath(fn.stem + ".png"), args.width, args.height)
File "/media/data/hnc-cad/gen/cad_img.py", line 15, in render
viewer = Viewer3d()
File "/home/.conda/envs/pyoccenv/lib/python3.9/site-packages/OCC/Display/OCCViewer.py", line 145, in __init__
Display3d.__init__(self)
File "/home/.conda/envs/pyoccenv/lib/python3.9/site-packages/OCC/Core/Visualization.py", line 180, in __init__
_Visualization.Display3d_swiginit(self, _Visualization.new_Display3d())
RuntimeError: Aspect_DisplayConnectionDefinitionErrorCan not connect to the server "" raised from method Display3d of class Display3d
File "/Users/Desktop/Code/gpus/hnc-cad/gen/cad_img.py", line 72, in <module>
main()
File "/Users/Desktop/Code/gpus/hnc-cad/gen/cad_img.py", line 68, in main
render(shape, output_path.joinpath(fn.stem + ".png"), args.width, args.height)
File "/Users/Desktop/Code/gpus/hnc-cad/gen/cad_img.py", line 16, in render
viewer.Create(phong_shading=True, create_default_lights=True)
File "/Users/miniconda3/envs/pyoccenv/lib/python3.9/site-packages/OCC/Display/OCCViewer.py", line 216, in Create
self.InitOffscreen(640, 480)
File "/Users/miniconda3/envs/pyoccenv/lib/python3.9/site-packages/OCC/Core/Visualization.py", line 215, in InitOffscreen
return _Visualization.Display3d_InitOffscreen(self, size_x, size_y)
RuntimeError: Aspect_WindowDefinitionErrorCocoa application should be instantiated before window raised from method InitOffscreen of class Display3d
Hello, I had the same issue and after trying a lot of things (including versions of pythonocc) I found a fix:
Install pythonocc-core version 7.4.0 as such: conda install -c conda-forge pythonocc-core=7.4.0
Viewer3d now excepts 1 argument
TypeError: init() missing 1 required positional argument: 'window_handle'
You can just pass None in gen/cad_img.py at line 15
viewer = Viewer3d(None)
Hope this helps
Thank you for your answer @Alex-experiments. However, I was unable to render because the following error occurred.
Traceback (most recent call last):
File "gen/cad_img.py", line 73, in <module>
main()
File "gen/cad_img.py", line 69, in main
render(shape, output_path.joinpath(fn.stem + ".png"), args.width, args.height)
File "gen/cad_img.py", line 16, in render
viewer.Create(phong_shading=True, create_default_lights=True)
File "/home/.conda/envs/pythonocc/lib/python3.7/site-packages/OCC/Display/OCCViewer.py", line
175, in Create
self.InitOffscreen(640, 480)
RuntimeError: Aspect_DisplayConnectionDefinitionError
Can not connect to the server ""
wrapper details:
* symname: Display3d_InitOffscreen
* wrapname: _wrap_Display3d_InitOffscreen
* fulldecl: bool Display3d::InitOffscreen(int,int)
Have you ever experienced an error like the one above?
I did not encounter this error so I'm not sure that I'll be able to help, though I noticed that you are using python 3.7 Maybe switching to python3.8 would do the trick?
@hxngiee apologies for my previous answer, as it turned out I encountered the same issue while trying to recreate my process. I have tried with python 3.8 and 3.9 and ends up with the same issue.
I could only make it work with windows, where I don't have that sort of issue.
However, when using the windows conda env, the gen/convert.py file does basically nothing.
This is because in convert, the signal library is used and signal on windows has no attribute 'SIGALARM'. A workaround I used is to simply comment the two lines with timeout(30):
in gen/convert.py (btw if you want to see the errors about SIGALARM, you can print the msg variable the authors created when catching exceptions on that same file).
I think at least for the sample_uncond pipeline, everything now works with windows. I was a huge hassle though and I have no idea on how this pipeline could work with linux.
Hello, I want to form a web demo of the whole process via gradio for adjustable parameter model generation and visualization in 2D as well as 3D. I had the same problem and tried the above, and found that visualization is only possible in windows and I can't fix it yet. Do you have a better solution to generate the whole process on Linux now? @Alex-experiments @hxngiee @samxuxiang
Hello, I did not made any further try to make it work on linux tbh I stood with the "easy" windows solution. Plus, I did a bit of restructuring and found this project to be overall really messy. I was interested in the conditional generation and after seeing the code, I wasn't even surprised to see that the author obtained his results on the training set after a LOOOT of overfitting.
For instance, he claims that conditional gen should be trained for 250 epochs. I implemented validation loss monitoring (really not a lot of work since the validation set was there, untouched, since the beginning) and found out that it minimized at the 14th epoch... (saving ~20 hours of training on my computer btw)
I also tried to reduce the insane number of steps needed to do some conditional inference on a custom 3D model from onshape.
I'm not sure if I'll be able to publish the updated code (I'll keep you posted) but there sure are a lot of things to redo in this repo
Thank you very much for your answer, I am equally interested in the conditional model generation part of its code and also struggling with its redundant data transformations.
I have temporarily solved the problem of occ visualization on linux, which is actually launched on Linux via a virtual graphics server. For the data, I'll consider trying more feature forms afterward, not just sketch and extrude.
Looking forward to your updated code, it should inspire me quite a bit! @Alex-experiments
Hello @Lydiagugugaga Unfortunately I won't be able to publish my updates because of my company policy. Sorry about that I would have loved to help you in your project... I hope you'll be able to finish it though!