stable-diffusion-api-server icon indicating copy to clipboard operation
stable-diffusion-api-server copied to clipboard

Support for AUTOMATIC1111/stable-diffusion-webui and InvokeAI/InvokeAI via proxy engine mode

Open remixer-dec opened this issue 3 years ago • 11 comments

Greetings! This makes the photoshop plugin compatible with two popular stable diffusion backends. They are optimized differently and have some features, that raw diffusers module does not have + they are easier to install and can handle ckpt files.

In this PR I moved utils and engines into separate files, divided the workflow for each engine into run, prepare_args and process methods, but tried to keep most of the original non-proxy code untouched. I only added "universal" task engine support, since separating tasks does nothing in proxy mode.

Everything seems to be working correctly, but some features are missing in the plugin. For example sampler selection and negative prompts. In InvokeAI negative prompt can be used right in the regular prompt with square brackets syntax, but in A1111 they mean a different thing (word attention reduction), so there is currently no way to use negative prompt. Maybe some other syntax like splitting two linebreaks ('\n\n') can be used as alternative? Sampler names are also different, but If you decide to add sampler selection into the plugin, it can be somehow mapped later.

P.S. Currently in this branch proxy engines output nsfw: False hardcoded, since there is no data from the base server about the output. InvokeAI is compatible in legacy mode because they moved to websocket/session protocols, but later brought back legacy api support. Also I saw "masking" task in the code, but I have no idea how to test it in Photoshop.

Thank you for making the original plugin and hopefully this can help to make it better :)

remixer-dec avatar Nov 16 '22 21:11 remixer-dec

This is awesome. Thanks for the PR. Apologies for the slow response. I'll dig in over the holiday weekend.

cantrell avatar Nov 23 '22 14:11 cantrell

Any chance of reviving this @cantrell?

It was previously working for me, but I updated the PS plugin and it seems to have broken something, getting a Runtime Error now. Tried a quick rebase of this PR against latest but no joy. Would be really good to get this in, having to have diffusers copies of all my models as well as the ckpt files in Automatic1111 really eats some disk space!

Not to mention its pretty handy to be able to have the automatic1111 gui running and jump between using the PS plugin and Automatic depending on what I'm doing. Having to restart one server or the ui between each switch is annoying.

benjamind avatar Jan 09 '23 20:01 benjamind

Notes from the InvokeAI side:

  • InvokeAI is migrating to use the diffusers library, so you'll be able to use the same set of models without converting anything to the CompVis/ldm format.
  • Relying on anything called legacy (like scripts/legacy_api.py) is probably not a good plan for forward compatibility.

keturn avatar Jan 09 '23 20:01 keturn

@keturn 1) Currently most custom models are distributed as a single ckpt/safetensors file, does this migration mean that convertion to diffusers format will be required for use of custom models with InvokeAI? 2) Is the new websocket/session-based API documented somewhere? I understand that it is convenient for InvokeAI's interactivity, but for third party integrations REST is a well established industry standard which can be integrated anywhere without much pain.

remixer-dec avatar Jan 09 '23 23:01 remixer-dec

im having some trouble running this, it keeps asking for the huggingface token. why is it even asking for it if its working directly with a1111, did i miss something?

DrMacabre avatar Jan 18 '23 04:01 DrMacabre

@DrMacabre make sure you have "mode": "proxy" in config.json

remixer-dec avatar Jan 18 '23 18:01 remixer-dec

@DrMacabre make sure you have "mode": "proxy" in config.json

you mean like this ? without hf_token ? image

DrMacabre avatar Jan 18 '23 23:01 DrMacabre

@DrMacabre like this (without ...), no token required

remixer-dec avatar Jan 19 '23 11:01 remixer-dec

@cantrell I understand things are evolving quite fast over the last few months and it may be difficult to predict where everything is heading. With the recent addition of Adobe's "Generative fill" and other recent features, you may have considered that there is no more need for an interface with Stable Diffusion, but I beg to differ and I'd like to assure you that the Photoshop plugin is definitely something that many people would love to use. Any chance to get a direct interfcae with Automatic1111 in the near future?

isben avatar Aug 06 '23 20:08 isben

We're trying to work out whether we should interface with A1111 or emulate the Stable Diffusion REST API.

cantrell avatar Aug 09 '23 13:08 cantrell

@isben here are some alternative plugins that are functional and compatible with a1111: stable.art and APSDP

remixer-dec avatar Aug 10 '23 10:08 remixer-dec