Closed ysharma1126 closed 6 years ago
@ysharma1126 , I am unable to reproduce this error, could you check the following?
setup.py
(called by pip install .
) should generate file tv_bregman.so
. If it failed to generate the .so file then ideally you should get an error during pip install .
. You can verify if .so file is created at adversarial/lib/transformations/tv_bregman.so
(PS: The adversarial
directory in the path should be the directory where adversarial
package is installed and not the source directory in adversarial_image_defenses
).import adversarial.lib.transformations.tvm
. With the above error you should also get the path from where tvm.py
is being loaded. Check if the path is the same where "adversarial" package is installed and not the path for the source directory(where you git cloned).1) When I run 'pip install .', I'm alerted that all requirements are satisfied and adversarial-0.1.0 was installed successfully. However, in the transformations directory, tv_bregman.so is not found. If I run python setup.py build_ext, I now have tv_bregman.c and tv_bregman.pyx in the transformations directory, but still not tv_bregman.so. I didn't get any errors.
2) I get the following error:
Traceback (most recent call last):
File "
3) Full error posted above. I'm using Python 2.7
When you do python setup.py build_ext
, It will generate the .so and other build files in the build directory inside adversarial_image_defenses. Its just that they are not copied with the src code files. python setup.py build_ext --inplace
can help with that. That will be able to fix the above error but then you may need to edit the demo.py to import local adversarial. Instead of build_ext, I will recommend the pip install .
, as you won't need to change any code then.
I think whats happening is your pip install .
is successful but you are trying to do import adversarial
or import adversarial.lib.transformations.tvm
from the directory adversarial_image_defenses
. As this directory has a sub directory with the name adversarial
, So when you do import from there it gives preference to the the local directory over the installed package with the same name.
I would recommend, after successful pip install .
, go to the parent directory of adversarial_image_defenses
and then in python do import adversarial
. After import adversarial
, print(adversarial.file) can tell you if your installed package is being loaded or the directory adversarial_image_defenses/adversarial
. If you are able to successfully import adversarial, then you should also be able to import adversarial.lib.transformations.tvm
without the above error.
I will update the setup.py
to print the path of the installed package to remove above confusion. Let me know if you are able to make it work.
Yep, you were correct! The library works if I execute commands from the parent directory of adversarial_image_dfenses! Thanks again!
Now I get the following error when running demo.py:
| Defense: quilting
| load quilting patch data...
Traceback (most recent call last):
File "adversarial_image_defenses/adversarial/examples/demo.py", line 107, in
Yes, because you don't have patch dataset for quilting. See generate quilting patches section in readme for more details on how to generate patches for image quilting, for more details on quilting you can reference this paper.
Once the patches are generated, you can update it's path in path_config.json
. You may also want to update path for imagenet_dir and data_root in the config file so that index_patches code can find the image dataset for generating patches.
Also, if you just want to run the demo and don't want to generate quilting patches, in demo.py
, replace "quilting" in args.defenses with "tvm" which will run TVM defense instead of quilting defense.
Understood. Thanks Mayank!
All dependencies have been installed, including Faiss, as per instructions, however when running the demo script, the following error is triggered. What is meant by 'check build script'?