s0md3v / sd-webui-roop

roop extension for StableDiffusion web-ui
GNU Affero General Public License v3.0
3.4k stars 880 forks source link

May I ask how to use this script in the API? #199

Open icecreamtohot opened 1 year ago

Gourieff commented 1 year ago

You can use my fork with 100% working api example Or you can modify args and payload of my example and it should also work with this original sd-webui-roop

JanKratochvil1 commented 1 year ago

You can use my fork with 100% working api example Or you can modify args and payload of my example and it should also work with this original sd-webui-roop

Thanks a lot for sharing the code, it's very helpful! I can see how you're providing the input image to roop-ge. Could you please advise me how to provide img_base64 to the original roop? I am trying to add it into the first argument: args = [ { "label": "", "value": img_base64, "minimum": None, "maximum": None, "step": None, "choices": None }, { ...

but I am getting this error: File "/home/jan/stable-diffusion-webui2/stable-diffusion-webui/extensions/sd-webui-roop/scripts/swapper.py", line 121, in swap_face source_img = cv2.cvtColor(np.array(source_img), cv2.COLOR_RGB2BGR) cv2.error: OpenCV(4.7.0) :-1: error: (-5:Bad argument) in function 'cvtColor'

thanks a lot for any help!

icecreamtohot commented 1 year ago

"roop": { "args": [ "imgbase64", true, "0", "C:\stable-diffusion-webui\models\roop\inswapper_128.onnx", "CodeFormer", 1, "4x-UltraSharp", 1, 1, false, true ] }

Go like this to alwayson_scripts in /sdapi/v1/txt2img or /sdapi/v1/img2img. They correspond to each other: "roop": { "args": [ imgBese64, enable, faces_index, model, face_restorer_name, face_restorer_visibility, upscaler_name, upscaler_scale, upscaler_visibility, swap_in_source, swap_in_generated, ] }

JanKratochvil1 commented 1 year ago

It works! 🚀 Thanks a lot! 🙏 No idea how you figured this format out :)) btw I was trying to run your version in the UI, but I couldn't make it work, it was generating images but not replacing the faces. Just fyi, I can test it again and provide feedback, let me know

SpenserCai commented 1 year ago

I have added support for the standard API in #214 . You can use my fork until it is merged by @s0md3v