lkwq007 / stablediffusion-infinity

Outpainting with Stable Diffusion on an infinite canvas
Apache License 2.0
3.82k stars 300 forks source link

app.py can't find opencv in order to compile libpatchmatch.so (solved ?) #163

Closed sbersier closed 1 year ago

sbersier commented 1 year ago

OS: Linux Ubuntu 22.04 Description: installation is OK but when launching app.py, the app doesn't find opencv (in order to compile libpatchmatch.so). The problem is in the Makefile in the PyPatchMatch folder.

I solved the problem by replacing the two occurences of "opencv" (between lines 18 and 20) with "opencv4":

CXXFLAGS += $(shell pkg-config --cflags opencv4) -fPIC CXXFLAGS += $(INCLUDE_DIR) LDFLAGS = $(shell pkg-config --cflags --libs opencv4) -shared -fPIC

joaoescribano commented 1 year ago

That works, i also tried simply duplicating the file to the disired pkgconf:

sudo cp /usr/local/lib/pkgconfig/opencv4.pc /usr/local/lib/pkgconfig/opencv.pc

But it now asks for another module fpie that can be solved by pip pip3.10 install fpie

sbersier commented 1 year ago

@joaoescribano: fpie should (at least in linux) be installed manually after creating the sd-inf environment and activating it. Make sure that you are in the sd-inf conda environment. Then: pip install fpie . Note: the fact that you're "sudoing" to install this piece of software is a clear indication that you're doing it wrong. Don't use "sudo" for that. It might make a mess with your OS python installation as well as introduce security issues.

joaoescribano commented 1 year ago

I don't use conda, i'm running localy into my local ubuntu installation.

sbersier commented 1 year ago

@joaoescribano: Well... That's not a good idea. You really should follow the setup instructions.

DaniByKellogs commented 1 year ago

i think that does not work anymore, help me, plss

when i edit the Makefile, and i try to start the webui it throws this:

Compiling and loading c extensions from "/content/stablediffusion-infinity/PyPatchMatch". rm -rf build/obj libpatchmatch.so mkdir: created directory 'build/obj' mkdir: created directory 'build/obj/csrc/' [dep] csrc/pyinterface.cpp ... [dep] csrc/masked_image.cpp ... [dep] csrc/inpaint.cpp ... [dep] csrc/nnf.cpp ... [CC] csrc/nnf.cpp ... [CC] csrc/inpaint.cpp ... [CC] csrc/masked_image.cpp ... [CC] csrc/pyinterface.cpp ... [link] libpatchmatch.so ... double free or corruption (out)

sbersier commented 1 year ago

@DaniByKellogs : Did you download it more than 2 days ago? I see that the opencv --> opencv4 change was commited 2 days ago (https://github.com/lkwq007/PyPatchMatch/compare/master...hartmutobendorf:PyPatchMatch:master) I don't see more changes to do there. But I see another recent (and related) change committed also 2 days ago ( https://github.com/lkwq007/stablediffusion-infinity/commit/7060f2b96666219d6d0b0f99db3456e2b58fa826 ) together with the addition of PyPatchMatch/makefile_fallback in the PyPatchMatch folder.

So, I would recommend to remove the whole stablediffusion-infinity folder (don't necessarily delete the sd-inf conda environment for the moment) and clone it again (git clone https://github.com/lkwq007/stablediffusion-infinity) (There might be other related commits that I haven't seen...)

If nothing above works, you can remove the sd-inf conda environnment, delete the stablediffusion-infinity folder and restart from scratch.

sbersier commented 1 year ago

@DaniByKellogs :

If the above failed, can you then give more details?

0) Did you re-download it? As suggested above? 1) Are you launching the app within the sd-inf conda environnment? (This is necessary.) 2) What is your OS? (linux, mac, windows,...)

Open a terminal: 3) activate the sd-inf environnment with: conda activate sd-inf 4) Please, give the result of the following command: python -c "import cv2; print(cv2.__version__)" 5) and the result of the following one: python --version #(the result should be 3.10.x)

Launch the app with python app.py 6) Can you give the full terminal output?

sbersier commented 1 year ago

@DaniByKellogs : Actually I don't think I can help you more on that subject. @lkwq007 (the author of SD-infinity) is working on it with @hartmutobendorf (in charge of the PyPatchMatch part). So I close the issue. I'm confident they'll find a solution pretty soon.

lkwq007 commented 1 year ago

@sbersier Thanks. I have fixed this issue by

CXXFLAGS += $(shell pkg-config --cflags opencv 2> /dev/null || pkg-config --cflags opencv4) -fPIC
LDFLAGS = $(shell pkg-config --cflags --libs opencv 2> /dev/null || pkg-config --cflags --libs opencv4) -shared -fPIC

Initially, I thought this should not be a problem for Linux users. However, it seems that I should not have assumed that all Linux users are familiar with programming.

@DaniByKellogs

double free or corruption (out) on colab has been fixed by the latest commit. (https://github.com/lkwq007/stablediffusion-infinity/issues/172)