gsgen3d / gsgen

[CVPR 2024] Text-to-3D using Gaussian Splatting
https://arxiv.org/abs/2309.16585
MIT License
761 stars 42 forks source link

utils/export.py in wrong folder and cannot access libraries #13

Open coolkite opened 11 months ago

coolkite commented 11 months ago

Hi,

While trying to convert the .pt to .ply file using the script in utils/export.py, I encountered a few import related errors.

Traceback (most recent call last):
  File "/home/jovyan/gsgen/utils/export.py", line 2, in <module>
    import numpy as np
  File "/opt/conda/envs/gsgen/lib/python3.10/site-packages/numpy/__init__.py", line 144, in <module>
    from . import lib
  File "/opt/conda/envs/gsgen/lib/python3.10/site-packages/numpy/lib/__init__.py", line 25, in <module>
    from . import index_tricks
  File "/opt/conda/envs/gsgen/lib/python3.10/site-packages/numpy/lib/index_tricks.py", line 12, in <module>
    import numpy.matrixlib as matrixlib
  File "/opt/conda/envs/gsgen/lib/python3.10/site-packages/numpy/matrixlib/__init__.py", line 4, in <module>
    from . import defmatrix
  File "/opt/conda/envs/gsgen/lib/python3.10/site-packages/numpy/matrixlib/defmatrix.py", line 12, in <module>
    from numpy.linalg import matrix_power
  File "/opt/conda/envs/gsgen/lib/python3.10/site-packages/numpy/linalg/__init__.py", line 73, in <module>
    from . import linalg
  File "/opt/conda/envs/gsgen/lib/python3.10/site-packages/numpy/linalg/linalg.py", line 20, in <module>
    from typing import NamedTuple, Any
  File "/home/jovyan/gsgen/utils/typing.py", line 12, in <module>
    from typing import (
ImportError: cannot import name 'Any' from partially initialized module 'typing' (most likely due to a circular import) (/home/jovyan/gsgen/utils/typing.py)
Traceback (most recent call last):
  File "/home/jovyan/gsgen/utils/export.py", line 6, in <module>
    from gs.gaussian_splatting import GaussianSplattingRenderer
  File "/home/jovyan/gsgen/utils/gs/gaussian_splatting.py", line 6, in <module>
    from utils.camera import PerspectiveCameras
ModuleNotFoundError: No module named 'utils'

Moving export.py to /gsgen and then installing the plyfile library seemed to fix this issue.

heheyas commented 11 months ago

Hi coolkite,

This issue can be solved by setting the PYTHONPATH env var:

export PYTHONPATH="."

or

PYTHONPATH="." python utils/export.py <your_ckpt> --type ply
heheyas commented 10 months ago

You can also finish exporting by:

python -m utils.export

This also works in colab

coolkite commented 10 months ago

Moving the export file outside the utils directory into the gsgen folder worked for me.

On Fri, Oct 13, 2023 at 4:27 AM Deng_Yao @.***> wrote:

i still got this problem after the operation according to the requirements [image: image] https://user-images.githubusercontent.com/87062331/274842794-b880e2ad-12ff-41b8-bb64-064cd34e1e52.png

— Reply to this email directly, view it on GitHub https://github.com/gsgen3d/gsgen/issues/13#issuecomment-1761121417, or unsubscribe https://github.com/notifications/unsubscribe-auth/AK22S65BZTSHO2VGZHCECADX7D3NPAVCNFSM6AAAAAA54LGT32VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTONRRGEZDCNBRG4 . You are receiving this because you authored the thread.Message ID: @.***>

Iliceth commented 10 months ago

I run into the first problem too, didn't forget to set the pythonpath.

My command:

PYTHONPATH="." python utils/export.py /mnt/c/Users/Andy
/Documents/gsgen/checkpoints/baby_dragon_with_sunglasses_and_a_red_top_hat/2023-11-05/232556/ckpts/step_14000.pt --ty
pe ply

My result:

Traceback (most recent call last):
  File "/mnt/c/Users/Andy/Documents/gsgen/utils/export.py", line 2, in <module>
    import numpy as np
  File "/home/user/miniconda3/envs/gsgen/lib/python3.10/site-packages/numpy/__init__.py", line 144, in <module>
    from . import lib
  File "/home/user/miniconda3/envs/gsgen/lib/python3.10/site-packages/numpy/lib/__init__.py", line 25, in <module>
    from . import index_tricks
  File "/home/user/miniconda3/envs/gsgen/lib/python3.10/site-packages/numpy/lib/index_tricks.py", line 12, in <module>
    import numpy.matrixlib as matrixlib
  File "/home/user/miniconda3/envs/gsgen/lib/python3.10/site-packages/numpy/matrixlib/__init__.py", line 4, in <module>
    from . import defmatrix
  File "/home/user/miniconda3/envs/gsgen/lib/python3.10/site-packages/numpy/matrixlib/defmatrix.py", line 12, in <module>
    from numpy.linalg import matrix_power
  File "/home/user/miniconda3/envs/gsgen/lib/python3.10/site-packages/numpy/linalg/__init__.py", line 73, in <module>
    from . import linalg
  File "/home/user/miniconda3/envs/gsgen/lib/python3.10/site-packages/numpy/linalg/linalg.py", line 20, in <module>
    from typing import NamedTuple, Any
  File "/mnt/c/Users/Andy/Documents/gsgen/utils/typing.py", line 12, in <module>
    from typing import (
ImportError: cannot import name 'Any' from partially initialized module 'typing' (most likely due to a circular import) (/mnt/c/Users/Andy/Documents/gsgen/utils/typing.py)

Are there any other tips you have?

heheyas commented 10 months ago

Using python -m utils.export <your_ckpt> --type <export_type> will solve this problem.

Iliceth commented 10 months ago

Using python -m utils.export <your_ckpt> --type <export_type> will solve this problem.

Yes, that worked for me, thanks a lot! Could you also tell me why that is, so I can learn what happened (wrongly) please?

heheyas commented 10 months ago

The file typing.py shares the same name with python built-in typing package, the -m flag tells python to load from the current working directory first. You can refer official documentation for details.

Iliceth commented 10 months ago

The file typing.py shares the same name with python built-in typing package, the -m flag tells python to load from the current working directory first. You can refer official documentation for details.

Thanks!