add load existing images by extension on webui

This commit is contained in:
jtydhr88
2023-05-21 22:13:40 -04:00
parent 5af86c8ca7
commit 7d73a79671
2 changed files with 61 additions and 3 deletions

View File

@@ -10,6 +10,7 @@ you can open http://127.0.0.1:7861/docs to double check.
4. once the server started, click settings to check this plugin loaded successfully or not. ![webui-plugin](docs/images/webui-plugin.png)
![overall](docs/images/overall.png)
5. click **Dream**, your webui server should start to process your request from StableStudio.
6. if you need to load existing from webui, you also need to install the extension [sd-webui-StableStudio](https://github.com/jtydhr88/sd-webui-StableStudio))
Still, currently this plugin is a basic implement for webui, and only support a few of features:
- [x] txt2img
@@ -21,11 +22,11 @@ Still, currently this plugin is a basic implement for webui, and only support a
- [x] mask/inpaint/outpaint
- [x] store settings
- [x] webui status could replace images generated status
- [x] load existing images (need an extension on webui: [sd-webui-StableStudio](https://github.com/jtydhr88/sd-webui-StableStudio))
- [x] Need to think about how to deal with extensions ecosystem in webui (made a start with [sd-webui-StableStudio](https://github.com/jtydhr88/sd-webui-StableStudio))
- [ ] upscale (working)
- [ ] Lora support
- [ ] load existing images
- [ ] Lora support
- [ ] plugin could use path in settings along with a field for extra cli flags to launch webui on startup
- [ ] some bugs fix
- [ ] MacOS and Linux support (since I dont have environment with MacOS/Linux, may need someone help with this)
- [ ] Need to think about how to deal with extensions ecosystem in webui
- [ ] many other features from webui...

View File

@@ -30,6 +30,7 @@ export const createPlugin = StableStudio.createPlugin<{
| "getStableDiffusionSamplers"
| "getStableDiffusionDefaultCount"
| "getStableDiffusionDefaultInput"
| "getStableDiffusionExistingImages"
> => {
if (webuiHostUrl === "") {
webuiHostUrl = "http://127.0.0.1:7861";
@@ -292,6 +293,62 @@ export const createPlugin = StableStudio.createPlugin<{
return samplers;
},
getStableDiffusionExistingImages: async () => {
const existingImagesUrl = webuiHostUrl + '/StableStudio/get-generated-images';
const data = {
limit: 10
}
const existingImagesResponse = await fetch(existingImagesUrl, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify(data),
});
if (!existingImagesResponse.ok) {
console.warn("unable to get existing data from webui");
}
const responseData = await existingImagesResponse.json();
const images = [];
for (let i = 0; i < responseData.length; i++) {
const blob = await base64ToBlob(responseData[i].content, 'image/jpeg');
const createdAt = new Date();
const stableDiffusionImage = {
id: responseData[i].image_name,
createdAt: createdAt,
blob: blob,
input: {
prompts: [],
style: "",
steps: -1,
seed: -1,
model: "",
width: responseData[i].width,
height: responseData[i].height
}
}
images.push(stableDiffusionImage)
}
const stableDiffusionImages = {
id: `${Math.random() * 10000000}`,
images: images
}
console.log(responseData);
return [stableDiffusionImages]
},
imagesGeneratedSoFar: 0,
settings: {