Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stable Diffusion for PhotoPea? #5000

Closed
nigelp opened this issue Sep 19, 2022 · 47 comments
Closed

Stable Diffusion for PhotoPea? #5000

nigelp opened this issue Sep 19, 2022 · 47 comments

Comments

@nigelp
Copy link

nigelp commented Sep 19, 2022

Hi, Christian Cantrell has created a CCX plugin for Photoshop which embeds Stable Diffusion inside the program.

Now we can install local instances of SD on Windows/Mac PCs, I wonder whether it's possible to create a plugin for Photopea which can use the local model to create art from inside Photopea?

@photopea
Copy link
Owner

These models usually are several GB in size. If Photopea downloaded it from our server to your computer, it will not be able to store it permanently (websites can not write data to your hard drive), so Photopea would have to re-download it each time you want to use it.

Do you already have a model in your computer? In that case, maybe we could use it from there.

We would also need something like https://caniuse.com/webgpu to run the model fast.

@nigelp
Copy link
Author

nigelp commented Sep 21, 2022 via email

@photopea
Copy link
Owner

photopea commented Oct 3, 2022

To use that Photoshop plugin, you will need to create a DreamStudio account, and you will need to pay DreamStudio basically for each click of the button "Dream". Each click will cost you 1 cent. I can create such plugin in 2 hours.

Are you aware of this? Or do you expect that this feature in Photopea to work for free?

@nigelp
Copy link
Author

nigelp commented Oct 3, 2022

Ahh...not necessarily so. This is the state of the art in downloadable Stable Diffusion generators. Works on any Windows or Mac computer locally. The AI model is loaded locally, as is Python and the machine's GPU does the heavy lifting. AFAIK there's no payment needed to DreamStudio, just a Hugging Face account. https://github.com/AUTOMATIC1111/stable-diffusion-webui/wiki/Install-and-Run-on-NVidia-GPUs****

@PAEz
Copy link

PAEz commented Oct 3, 2022

Or one that has a simple server you could connect to.....
https://github.com/invoke-ai/InvokeAI
I know the one @nigelp mentioned uses a server, but buggered if I know how it works. Whereas the one I mentioned above has a very simple server to work with (but less options).

And a DreamStudio (or any of the other online APIs) would be great. I want a free one but I know a lot of people wont care and it can be faster and not every one has the GPU needed. I only have a 1060 so its not the quickest, but I dont care still lots o fun.

@photopea
Copy link
Owner

photopea commented Oct 4, 2022

@nigelp I dont think there is a Photoshop plugin which can run a Stable Diffusion method for free, is there? You can not integrate a web app with a Python script, etc.

@PAEz
Copy link

PAEz commented Oct 5, 2022

@nigelp In the meantime if you want a free image editor with local SD support, try Krita with https://github.com/sddebz/stable-diffusion-krita-plugin . Seems to work great.

And Ivan if you know some python the server for the Krita plugin could prolly be altered to work well for a PP plugin as well. Works from a http server you could work with, youd just have to add some stuff to serve/return/delete the work files as the the Krita plugin has access to that stuff through python, but the calls to SD are done through the server.

@photopea
Copy link
Owner

I have added the DALL-E image generator under Window - More - DALL-E. I added them, as they were the only ones with a publicly described API.

@JRowe47
Copy link

JRowe47 commented Oct 25, 2022

https://github.com/AUTOMATIC1111/stable-diffusion-webui
AUTOMATIC1111 might be able to partner with you to integrate SD directly into Photopea.

It'd be really easy to handle inpainting and outpainting with the existing functionality of AUTOMATIC1111's UI.

@photopea
Copy link
Owner

@JRowe47 We do not need any code or a program. We need a computer, which runs the AI model (someone paying the electricity bill, the internet connection bill ...), and can process requests (e.g. through the API) for free or for a low cost.

@JRowe47
Copy link

JRowe47 commented Oct 26, 2022

AUTOMATIC1111 Stable Diffusion web ui runs locally, so you're pulling from http://localhost:7860/ for free. It can be run on systems with as low as 2GB vram GPU, and is very performant even on lower end hardware.

@photopea
Copy link
Owner

The software for stable diffusion is like 20 GB of data. Photopea is only 1.5 MB. With the internet speed of 10 Mbit, you would have to wait 4.5 hours just to download it (while Photopea is downloaded in 1.2 seconds).

@nigelp
Copy link
Author

nigelp commented Oct 26, 2022 via email

@JRowe47
Copy link

JRowe47 commented Oct 26, 2022

Yes, with a decent 100mbps connection, you're looking at about 15-20 minutes to install locally. It takes less than 10 seconds to start up on my laptop - it's an excellent fit, I'm certain you'd find thousands of appreciative users with this one feature, and you'd be stepping on Adobe's toes by matching one of their latest features with an arguably better media synthesis system.

@PAEz
Copy link

PAEz commented Oct 27, 2022

A bunch of us want to use our computer, electricity and wotnot and already have the 4gig model downloaded.
The 1.5 version of the Photoshop plugin/script added local support and to do so made a local server with a publicly described API.....
https://github.com/cantrell/stable-diffusion-api-server

@MilesFarber
Copy link

image
Billing Hard Limit message appears, never used Dall-E before. Maybe make it Premium exclusive if money is an issue?

@photopea
Copy link
Owner

photopea commented Nov 6, 2022

@PAEz I dont think there is a way for a website to detect if you have DALL-E in your computer, or even communicate with Python etc :(

@photopea
Copy link
Owner

photopea commented Nov 6, 2022

I have implemented the AI Inpainting according to a layer mask.

Try it here: https://www.photopea.com/#iy9fmiZ_g.psd . Press Window - More - Dall-E, enable "Inpaint" and click "Generate".

@photopea
Copy link
Owner

photopea commented Nov 6, 2022

I have changed the mechanism of payments. Any user in the world can use it for free, but they can generate 1 image per minute. The usage is unlimited for those who paid for Photopea Premium.

You can still insert your own API Key and use it under your own account.

@VapidLinus
Copy link

I have implemented the AI Inpainting according to a layer mask.

Try it here: https://www.photopea.com/#iy9fmiZ_g.psd . Press Window - More - Dall-E, enable "Inpaint" and click "Generate".

Terrifying! Not sure what's up with the artefacts on both images.
image

Seriously though it's insane how fast you are at adding new features. Both the Dall-E integration in general and now this inpainting feature. I appreciate your work very much and am happy to keep paying for premium 💚

@photopea
Copy link
Owner

photopea commented Nov 6, 2022

It took me about an hour to add inpainting. I am working on other features, too :)

@nigelp
Copy link
Author

nigelp commented Nov 6, 2022 via email

@photopea
Copy link
Owner

photopea commented Nov 6, 2022

Do you know how to use raster masks? The masked area will be filled with a new content according to your prompt.

E.g. I tried to draw content around my eye https://www.photopea.com/#ia-0NAQef.psd

ivan_face (1)

@MichalSZZ
Copy link

I am here just to write - awesome work Ivan! I tried inpaint and I am impressed! Respect!

@DenverCoder1
Copy link

Seems to work great 👍

I noticed that the tab now says "Stable Diffusion" but in the API Keys tab it says "get your own at beta.openai.com" but that is the website for DALLE, not Stable Diffusion.

Is that possibly a mistake?

image

@photopea
Copy link
Owner

we are planning to replace DALL-E with some stable diffusion provider. Do you know about any other than https://stability.ai/ (they have a very bad API) ?

@DenverCoder1
Copy link

I think replicate.com has a pretty good API for Stable Diffusion among other AI models. I've used it via Python, but of course it supports cURL or HTTP through other means as well.

https://replicate.com/stability-ai/stable-diffusion/api

@PAEz
Copy link

PAEz commented Dec 1, 2022

@photopea Maybe youd prefer their new REST API?.....
https://api.stability.ai/docs
...no in/out painting and wotnot, but its alpha so should get better.

@photopea
Copy link
Owner

photopea commented Dec 2, 2022

I tried to implement it, but they do not support CORS, so it is not possible to use their API from the browser.

@PAEz
Copy link

PAEz commented Dec 2, 2022

What!?!?!?!

Wish I wasnt so tired all the time, Im not that smart and all but I looked at the code for Automatics and I think I could slip a couple of buttons in there to transfer from PP, to it, and back again. Theres some details I dont get for masks and how to handle non square selections and size difference but I could prolly get the basics done. Just getting rid of the save, load, save, load, etc would make me happy. I was hoping someone else would do it, but I might give it a go this week. I just gotta check a couple of things like if I minimize a plugins window/dialog is the frame still running? I want that frame to communicate with a tab so you can have a full window as theres a lot in the interface. Meh, Ill try and look later.

@photopea
Copy link
Owner

photopea commented Dec 2, 2022

@PAEz I dont know what are you talking about. You can learn how to use our current plugin here: https://www.photopea.com/tuts/use-stable-diffusion-for-free/

@photopea
Copy link
Owner

photopea commented Dec 2, 2022

I will close it now, but we can keep discussing it.

@photopea photopea closed this as completed Dec 2, 2022
@remixer-dec
Copy link

This is a good example of a webapp communicating with a local SD api server

@photopea
Copy link
Owner

I have implemented the Stable Diffusion into Photopea, under Window - More - Text to Image.

It is from Dezgo: https://rapidapi.com/dezgo/api/dezgo/pricing and it is 10x cheaper than the current DALL-E. DALL-E is availabe only with your own key now.

@photopea
Copy link
Owner

I have decreased the waiting time from 2 minutes to 1 minute (for non-premium users).

@camoody1
Copy link

This is a good example of a webapp communicating with a local SD api server

This is a really nice implementation of Inpainting and Outpainting. Really great for extending the canvas.

@camoody1
Copy link

I wish I had a newer GPU so I could start using these local Stable Diffusion installations. I'm still using an AMD R9 390, unfortunately. Someday, maybe I'll be able to get am RTX 4070 Ti and really dig into this AI world.

@Mandraw
Copy link

Mandraw commented Mar 28, 2023

So still no news on an implementation using the local API from A1111 ? It would really be the best option for people that have the GPU to support it

@photopea
Copy link
Owner

Hi guys, I found this, maybe it could be useful to you: https://www.reddit.com/r/StableDiffusion/comments/12141hw/wip_simple_photopea_integration_for_webui/

@camoody1
Copy link

Hi guys, I found this, maybe it could be useful to you: https://www.reddit.com/r/StableDiffusion/comments/12141hw/wip_simple_photopea_integration_for_webui/

This would be an excellent plugin for Photopea. I see that you posted a comment. I did as well. Would love to see some more Photopea users comment there asking for a plugin. :)

@huchenlei
Copy link

Just a heads up, I made a plugin to interface A1111 in photopea here:
https://github.com/huchenlei/stable-diffusion-ps-pea

Documentation is WIP, but you can already use it.
Fixing Face Demo: https://www.loom.com/share/fb11c0206d7045469b82fe9d6342bd15

@camoody1
Copy link

Just a heads up, I made a plugin to interface A1111 in photopea here: https://github.com/huchenlei/stable-diffusion-ps-pea

Documentation is WIP, but you can already use it. Fixing Face Demo: https://www.loom.com/share/fb11c0206d7045469b82fe9d6342bd15

Very excited to do some testing on this. I tried to create an image from a blank canvas using the new SDXL model and it got stuck at 12%. I'm not sure if that's a bug on your end, a configuration problem on my end, or just growing pains from the new SDXL integration into Automatic1111.

What you've designed so far, though, is outstanding! You might need to add an option to select a VAE, though, since SDXL has a separate file for that.

@camoody1
Copy link

@huchenlei This works great for Inpainting. Well done!

@huchenlei
Copy link

@camoody1 Thanks! VAE selection is on the development plan. I will make it ready asap.

@photopea
Copy link
Owner

As I understand, people have the Stable Diffusion program running on their computers, which creates a web server and can communicate over the HTTP protocol, using some API. The plugin can connect to any web server and communicate over the pre-defined API. You are supposed to connect to your own local server (made by the Stable Diffusion program).

@huchenlei
Copy link

@camoody1 VAE selection implemented. You can find the selection box under Advanced Settings now.

@camoody1
Copy link

@huchenlei You should absolutely post about your plugin on the Photopea subreddit and Facebook pages. This is really a game changer for integrating Photopea with local installations of Automatic1111. It's so much better than trying to use the built-in Automatic1111 inpaint tool. And it's an amazing upgrade in quality for people editing their own photos and images in Photopea. So many great models and LoRAs to play around with.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests