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

Support styles.csv in AUTOMATIC1111 #386

Closed
wants to merge 4 commits into from

Conversation

gmasil
Copy link
Contributor

@gmasil gmasil commented Apr 3, 2023

I noticed that adding styles in AUTOMATIC1111 web UI is not persisted to host fs.

I added a simple example styles.csv containing some common negative expressions and added a mount in docker-compose.yml.
A default file must be present as the mount will cause problems when the file is missing all together.

2023-04-03 15_39_26-docker-compose yml - stable-diffusion-webui-docker - Visual Studio Code

My hopefully sane default negatives are

easynegative, ng_deepnegative_v1_75t, bad-hands-5, (worst quality, low quality:1.3), logo, watermark, text

but I am open for any suggestions, I just wanted to add something as an example.

I also added styles.csv to .gitignore file, as changes will be made by users which should not be upstreamed into the repository.

@AbdBarho
Copy link
Owner

AbdBarho commented Apr 3, 2023

Can you test #180 (comment)

@gmasil
Copy link
Contributor Author

gmasil commented Apr 3, 2023

I tested it, but it doesn't work. Just as you already discovered the changes are not written back into the host file. The file styles.csv is moved to styles.csv.bak before writing the new one.

After clean container startup:

lrwxrwxrwx 1 root root   28 Apr  3 15:49 styles.csv -> /data/config/auto/styles.csv

After saving a style:

-rw------- 1 root root   57 Apr  3 15:50 styles.csv
lrwxrwxrwx 1 root root   28 Apr  3 15:49 styles.csv.bak -> /data/config/auto/styles.csv

File contents of styles.csv:

name,prompt,negative_prompt
None,,
teststyle,,test

File contents of styles.csv.bak:

name,prompt,negative_prompt
None,,

So symlinking won't work.

Interestingly my solution isn't working as well. I thought: why would my solution work then?
I was pretty sure I could save a style, but I just checked it and I get the following expected error:

OSError: [Errno 16] Device or resource busy: '/stable-diffusion-webui/styles.csv' -> '/stable-diffusion-webui/styles.csv.bak'

So I guess we had to mount a folder in order to make that work. I will take a look into AUTOMATIC1111's repo to see if we can find a simpler solution on their side, possible by adding a flag to disable this backup strategy.

I'll come back to you in a couple of days.

Edit:
Here is the code in question: https://github.com/AUTOMATIC1111/stable-diffusion-webui/blob/master/modules/styles.py#L74-L87
I am going to play around with that until I get a clean solution.

@AbdBarho
Copy link
Owner

AbdBarho commented Apr 3, 2023

Thank you for your investigation, please don't invest too much time into this, in my book it is a 'nice to have'.

@gmasil
Copy link
Contributor Author

gmasil commented Apr 3, 2023

I proposed a solution at AUTOMATIC1111's repo. I really appreciate the functionality to quickly save some snippets. I am going to use my changes as of now, hopefully we can merge it into the repos.
I don't want to bother you with any of your time, that's why I am investing a little bit into it, so you don't have to :)

@gmasil
Copy link
Contributor Author

gmasil commented Apr 3, 2023

Here is my temporary patch on how I use it personally in case anyone wants to copy it until we have sorted things out correctly:
gmasil@90f0b1a

wget https://github.com/gmasil/stable-diffusion-webui-docker/commit/90f0b1a8e4f64890a7c05a80f752245f820edede.patch
git apply 90f0b1a8e4f64890a7c05a80f752245f820edede.patch

@Renari
Copy link

Renari commented Apr 13, 2023

I was able to get this working with only:

MOUNTS["${ROOT}/styles.csv"]="/data/styles.csv"

However I did extract a premade styles.csv to /data mounted via a host path prior to making this change.

@gmasil
Copy link
Contributor Author

gmasil commented Apr 14, 2023

Are you sure that you can save new styles from webui? Is it really persisted to your host file?

@Renari
Copy link

Renari commented Apr 14, 2023

The styles.csv saved externally is read and loaded correctly, however it seems saving new styles will overwrite the symlink instead of following it, thus preventing the new additions.

@AbdBarho AbdBarho added the awaiting-response Waiting for the issuer to respond label Apr 16, 2023
@gmasil
Copy link
Contributor Author

gmasil commented Apr 17, 2023

I see that there is little interest in this feature, so I am going to close this PR for now.
Maybe I come back when we resolved this: AUTOMATIC1111/stable-diffusion-webui#9334
I don't see an elegant way to solve this here.

@gmasil gmasil closed this Apr 17, 2023
@LEv145
Copy link
Contributor

LEv145 commented Apr 29, 2023

@gmasil
Copy link
Contributor Author

gmasil commented Apr 30, 2023

@LEv145 it has been merged to dev, that means we still have to wait until it is merged to master and then we have to check what we have to do to use the latest revision as there are a lot of changes.

@LEv145
Copy link
Contributor

LEv145 commented May 1, 2023

@LEv145 it has been merged to dev, that means we still have to wait until it is merged to master and then we have to check what we have to do to use the latest revision as there are a lot of changes.

Merged to master!
AUTOMATIC1111/stable-diffusion-webui@fe8a10d

@AbdBarho
Copy link
Owner

AbdBarho commented May 1, 2023

Nice! I will wait a day or two for emergency bug fixes and then try to update. The last version was so buggy I did not dare to merge it #379

@gmasil
Copy link
Contributor Author

gmasil commented May 2, 2023

And it doesn't count as a contribution when its merged to dev first :P
I used the dev branch for a couple of days (without docker) and that worked fine. Haven't had time to look into it using docker, maybe in the next days.

This was referenced May 4, 2023
@AbdBarho
Copy link
Owner

AbdBarho commented May 4, 2023

@gmasil thank you for the upstream PR, adding this feature is now very easy #440

AbdBarho added a commit that referenced this pull request May 4, 2023
Jordan-Lambda pushed a commit to Jordan-Lambda/lambda-cloud-stable-diffusion-2.0-webui-easy that referenced this pull request Aug 2, 2023
cloudaxes pushed a commit to cloudaxes/stable-diffusion-webui-docker that referenced this pull request Sep 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting-response Waiting for the issuer to respond
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants