BachiLi / diffvg

Differentiable Vector Graphics Rasterization
https://people.csail.mit.edu/tzumao/diffvg/
Apache License 2.0
923 stars 155 forks source link

module 'diffvg' has no attribute 'FilterType_' #27

Open xieMNll opened 3 years ago

xieMNll commented 3 years ago

!!!I met the same error @BachiLi ,and I really need your help.
_AttributeError: module 'diffvg' has no attribute 'FilterType'_

I git clone the code, and pip install all requirements. Then I run python setup.py install successful.

Using c:\programdata\anaconda3\envs\torch\lib\site-packages Finished processing dependencies for diffvg==0.0.1

But when I run single_circle.py, it showed ModuleNotFoundError: No module named 'diffvg'. So I copied all diffvg project in my conda environment site_packages. when import pydiffvg, the error occured: File "single_circle.py", line 2, in import pydiffvg File "C:\ProgramData\Anaconda3\envs\torch\lib\site-packages\diffvg-0.0.1-py3.7-win-amd64.egg\pydiffvg__init__.py", line 4, in from .render_pytorch import * File "C:\ProgramData\Anaconda3\envs\torch\lib\site-packages\diffvg-0.0.1-py3.7-win-amd64.egg\pydiffvg\render_pytorch.py", line 21, in class RenderFunction(torch.autograd.Function): File "C:\ProgramData\Anaconda3\envs\torch\lib\site-packages\diffvg-0.0.1-py3.7-win-amd64.egg\pydiffvg\render_pytorch.py", line 30, in RenderFunction filter=pydiffvg.PixelFilter(type=diffvg.FilterType.box, AttributeError: module 'diffvg' has no attribute 'FilterType'

My environment: windows10 Anaconda3 python3.7

robinsloan commented 2 years ago

It's possible you have a diffvg directory present in the scope that you're running your program, so it's looking there for the attribute and not finding it. After installing, try renaming diffvg to temp_diffvg or something else; that cleared up this problem for me. (Running in a Colab notebook, not Windows.)

bfrasure commented 2 years ago

this didn't work for me. the only environment that works is python 3.6 for some reason. Every other fresh build of python yields extern errors for Cuda on the build. this builds but can't find diffvg.

firebellys commented 2 years ago

It's the FilterType here, it doesn't exist on which ever version it's importing.

                        filter = pydiffvg.PixelFilter(type = diffvg.FilterType.box,
                                                      radius = torch.tensor(0.5)),
APX403 commented 2 years ago

same error

d00ML0rDz commented 2 years ago

Renaming the site-packages/diffvg-0.0.1-py3.8-win-amd64.egg/diffvg file to diffvg.pyd seems to have fixed this for me.

jam411 commented 2 years ago

I faced the same problems and made some changes until it worked on the Google Colab.

  1. Down grade Tensorflow to version 1.X. %tensorflow_version 1.x import tensorflow as tf print(tf.__version__)

  2. Add "pydiffvg" path to c compiled file? import sys sys.path.append("/content/CLIPasso/diffvg/build/lib.linux-x86_64-3.7")

  3. Upgrade Pillow. !pip3 install --upgrade Pillow

David-Estevez commented 2 years ago

If you are working on Google Colab, try restarting the runtime after installing diffvg, that worked for me!

Gaspa79 commented 2 years ago

Renaming the site-packages/diffvg-0.0.1-py3.8-win-amd64.egg/diffvg file to diffvg.pyd seems to have fixed this for me.

I have no idea why but this solved it for me!

SoundmartellTutorials commented 1 year ago

Renaming the site-packages/diffvg-0.0.1-py3.8-win-amd64.egg/diffvg file to diffvg.pyd seems to have fixed this for me.

Thanks @d00ML0rDz, It work for me.