megvii-research / CADDM

Official implementation of ID-unaware Deepfake Detection Model
Apache License 2.0
135 stars 19 forks source link

How do I generate so files #7

Closed guotianli closed 1 year ago

guotianli commented 1 year ago

Thank you very much for your contributions in the field of deep forgery detection. As a newbie, I wondered how to compile in the jpegpy folder. Also, I can't always find python.h, even though I have devel installed!

tiamo405 commented 1 year ago

from . import _jpegpy ImportError: cannot import name '_jpegpy' from partially initialized module 'lib.data_preprocess.utils.jpegpy' (most likely due to a circular import) (./CADDM/lib/data_preprocess/utils/jpegpy/init.py) Are you having the same problem as me?

hellogeraldblah commented 1 year ago

Hi, I am having the same issue. I am using a Ubuntu 22.04, Python 3.10.6, and have installed the static libraries and header files as mentioned in this StackOverflow post I still am unable to compile successfully.

Here is the missing Python.h error that I encountered after running the make command inside the lib/data_preprocess/utils/jpegpy folder.

pybind11/common.h:99:10: fatal error: Python.h: No such file or directory
   99 | #include <Python.h>
guotianli commented 1 year ago

yeah. I send an email to the author and got the replay :" 代码相关问题可以直接在github上提issue,我们会优化我们的代码。您的问题是由于没有编译 _jpegpy​ 模块导致的,请在 CADDM/lib/data_preprocess/utils/jpegpy​ 路径下编译 _jpegpy​.so 再执行训练" and then, i tried to compile the .so file but failed.

jinjinw commented 1 year ago

Hi @guotianli @hellogeraldblah @tiamo405 , it seems that the path to Python.h could not be located. I tried to replicate your error and found the following revision may help. You can change lines in CADDM/lib/data_preprocess/utils/jpegpy/pybind11/common.h from `

include

include

include

to

include <python3.7/Python.h>

include <python3.7/frameobject.h>

include <python3.7/pythread.h>

` based on the version of Python you are using.

Then run the make command in the folder of CADDM/lib/data_preprocess/utils/jpegpy.

Hope this could help you.

guotianli commented 1 year ago

Hi @guotianli @hellogeraldblah @tiamo405 , it seems that the path to Python.h could not be located. I tried to replicate your error and found the following revision may help. You can change lines in CADDM/lib/data_preprocess/utils/jpegpy/pybind11/common.h from #include <Python.h> #include <frameobject.h> #include <pythread.h> to #include <python3.7/Python.h> #include <python3.7/frameobject.h> #include <python3.7/pythread.h> based on the version of Python you are using.

Then run the make command in the folder of CADDM/lib/data_preprocess/utils/jpegpy.

Hope this could help you.

Thank you for your patience. Last night, I edited the makefile file with the vim command, changed the default header location, and executed the make command to successfully compile the file. The program has been successfully executed. According to the model ending with pth that you provided in map, I get the evaluation result of 94.7%.

In addition, I changed the storage path of extracting photos from the default test_image to train_image, so that we can train. Thanks again, I now want to enter a picture to get true false and confidence in learning your code.

li-yanhao commented 1 year ago

To compile _jpegpy.cc I simply added the include path -I/usr/include/python3.8 in Makefile to compile the .so file in python3.8. My Makefile is like:

CXXFLAGS =-std=c++11 \
          -O3 $(shell pkg-config --cflags libjpeg) $(shell mdl python3-config --cflags) -UNDEBUG
LDFLAGS = $(shell pkg-config --libs libjpeg) $(shell mdl python3-config --ldflags)

CXX_SOURCES = _jpegpy.cc

LIB_SO = _jpegpy.so

$(LIB_SO) : $(CXX_SOURCES)
    $(CXX) $(CXX_SOURCES) -o $@ $(CXXFLAGS) $(LDFLAGS) --shared -fPIC -I/usr/include/python3.8

clean:
    rm -rf $(LIB_SO)
1802931263 commented 8 months ago

是的。我给作者发了一封电子邮件,得到了重播:“ 代码相关问题可以直接在github上提issue,我们会优化我们的代码。您的问题是由于没有编译 _jpegpy 模块导致的,请在 CADDM/lib/data_preprocess/utils/jpegpy 路径下编译 _jpegpy.so 再执行训练“ 然后,我尝试编译 .so 文件,但失败了。

哪有.so文件啊?

guotianli commented 8 months ago

The so file is generated by your comand "make...."

lazy

@. | ---- Replied Message ---- | From | @.> | | Date | 10/24/2023 19:16 | | To | @.> | | Cc | @.> , @.***> | | Subject | Re: [megvii-research/CADDM] How do I generate so files (Issue #7) |

是的。我给作者发了一封电子邮件,得到了重播:“ 代码相关问题可以直接在github上提issue,我们会优化我们的代码。您的问题是由于没有编译 _jpegpy 模块导致的,请在 CADDM/lib/data_preprocess/utils/jpegpy 路径下编译 _jpegpy.so 再执行训练“ 然后,我尝试编译 .so 文件,但失败了。

哪有.so文件啊?

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.Message ID: @.***>

stddio commented 4 months ago

Maybe you can try it on python3.6. With it I solve the problem. You can see this answer:https://github.com/pybind/pybind11/issues/1444#issue-338427482