opencv / opencv_contrib

Repository for OpenCV's extra modules
Apache License 2.0
9.2k stars 5.74k forks source link

EDGE DRAWING LIBRARY #2314

Open sturkmen72 opened 4 years ago

sturkmen72 commented 4 years ago

recently i found https://github.com/CihanTopal/ED_Lib and i see it contains useful algorithms valuable to be included in OpenCV

firstly i contacted with the author and take his permission. i want to work on code adaptation and rewriting according to OpenCV code style

test PR : https://github.com/opencv/opencv_contrib/pull/2313

sturkmen72 commented 3 years ago

Algorithms in the original repo and their estimated completion states after first merged commit #2313

i hope to continue working on the list below

geroldmeisinger commented 8 months ago

@sturkmen72 Thank you so much for your integration of the Edge Drawing algorithms in OpenCV and subsequently for opencv-contrib-python!

I'm using Stable Diffusion, a generative artificial intelligence software, which can turn a simple text prompt into a full blown image. Together with the ControlNet extension it is possible to "guide" the generation process based on edge maps into a specific direction. At the moment I'm training a new ControlNet based on Edge Drawing and the parameter free version already helped me a lot to increase quality of the guidance process. The first version is available on Civitai - ControlNet MySee - Edge Drawing Parameter Free and a web-demo for Edge Drawing Parameter Free, thanks to your integration. This provides a lot of value to users because it doesn't require parameter tuning like canny.

This is what it looks like to most users using the Automatic1111 UI for Stable Diffusion. Left is the "ground truth" image, middle is the processed "edge map" and right is the new "generated image" based on the prompt "photo of a woman in the street, fashine, anime" and guided by the edge map to get a similar pose: image

I was able to compile the EDLib EDColor cpp version to generate the edge maps and the detection quality seems even better, which could further increase the quality of the ControlNet. Unfortunately, without EDColor in opencv-contrib - and therefore in Python - I'm not able to provide a web-demo for users. The EDColor version, especially a parameter free version, would be so nice.

Thank you again for all your work!

AbsurdePhoton commented 1 week ago

@sturkmen72 : you asked me from the EDLib repo to add context here, I am happy to do so.

geroldmeisinger commented 1 week ago

I'm planning to train a new Controlnet with EDPF Color soon for Stable Cascade and Stable Diffusion SDXL+3 (if my hardware allows it). The Canny Controlnet is considered one of the most important Controlnets in image generation AI and thus had multiple reinstatements even though it uses the inferior canny filter, see https://huggingface.co/xinsir/controlnet-canny-sdxl-1.0 for the most recent one

Canny is one of the most important ControlNet series models and can be applied to many jobs associated with drawing and designing.

If edge drawing would also find it's way to the official opencv this would also allow further support in tools (my PR was denied because it is in contrib) which made me even go the javascript route just to get it into the popular ComfyUI app.