Closed VanishX closed 1 year ago
It looks like the problem is:
We pass the model from the request using self.current_models
variable.
But when sd-webui creating the infotext
injected into the image metadata, it is using the current model, in this case it is the model_1_5
:
https://github.com/AUTOMATIC1111/stable-diffusion-webui/blob/0cc0ee1bcb4c24a8c9715f66cede06601bfc00c8/modules/processing.py#L454
def create_infotext(p, all_prompts, all_seeds, all_subseeds, comments=None, iteration=0, position_in_batch=0):
# ....
generation_params = {
# ...
+ "Model hash": getattr(p, 'sd_model_hash', None if not opts.add_model_hash_to_info or not shared.sd_model.sd_model_hash else shared.sd_model.sd_model_hash),
+ "Model": (None if not opts.add_model_name_to_info or not shared.sd_model.sd_checkpoint_info.model_name else shared.sd_model.sd_checkpoint_info.model_name.replace(',', '').replace(':', '')),
# ...
}
So it looks like we should create the infotext
by our own or just set the shared.sd_model
as the requested model?
@theUpsider do you have better thoughts?
Yea definetly cause we use the currently selected model but not the one from the list. After work I'll dig into this
I tried a rough way to replace the model info. Added 2 lines to stable_horde/horde.py, after line 403:
from re import sub
infotext = sub('Model:(.*?),', 'Model: '+local_model.split(".")[0]+',', infotext)
It replaced the model name in the infotext
with the local_model
.
@VanishX I actually thought about something like that too. I was reimplementing the infotext functing but am undecided on what would be the prettier workaround.
This is actually better than I thought. Thinking about the original repo getting an update, and we would have reimplemented the info_text function, we would have to add the new params. Replacing the model name is valid.
@MaikoTan the problem with switching the shared.sd_model
is that it could be too slow or end up saving the wrong name in fast successive requests I assume. Or if one would use parallel computing in different tabs. What do you think about replacing the string? I know its a little dirty, but I dont see any better possibility.
😂Yeah, it is definitely dirty, but I have no a better idea for this. So...let's do the dirty way for the fixing first.
And the Model hash
is still incorrect, which is a parameter of CheckpointInfo, refer to CheckpointInfo.shorthash
.
It will be more dirty if we calculate the hash again, I am trying to figure it out that if there has any pre-calculated variable.
The main purpose of saving images is trying to reuse the prompts, it will be great if the Model hash
can be corrected.
There is an option called When reading generation parameters from text into UI (from PNG info or pasted text), do not change the selected model/checkpoint.
which in the sd-webui Settings-->User Interface
.
This feature can reuse the prompts with Send to txt2img
including an Override settings called Model hash:XXXXXXXXXX
, which don't need to choose the model manually.
@VanishX definitely. We should not recalculate the hash. I assume the hashes must be somewhere. Trying to figure out where they are as well. Please reply if you found them! There is a cache file in the base directory, containing the sha hashes. But we need md5.
Ok apparently the model hash saved to the file is the first 10 characters of the sha model hash in the cache. Ill try to map these.
Thanks for the great work! Ready to lay down to try all the saved prompts hah~
Is there existing issue for this?
Does this happen on the latest commit?
What happened?
After adding the multiple models support, the "Save Images" function saves wrong model information with current model name instead of the request model name.
Steps to reproduce
1.Go to the Stable Horde Worker tag on webui, check the status on coming request in the Preview. It will show information like "Get popped generation id, model Anything v3, sampler k_euler_a" We can get the information about the request model name, which is model "Anything v3" here.
2.Go check the saved image information, use any image browser extensions or even any text editors. We can get the information about saved model name, which is model "model_1_5" here which was my current Stable Diffusion checkpoint(default model).
I have checked it with different requests ,and also changing the default model, the model info saved always be the default model name.
What did you expect to happen?
Please fix it with the actual model name
Stable Diffusion WebUI Commit SHA
0cc0ee1bcb4c24a8c9715f66cede06601bfc00c8
What operating system are you seeing the problem on?
Debian / Ubuntu
What browsers are you seeing the problem on?
Chrome
Additional information
Request model name in Preview![Screenshot from 2023-03-08 12-41-01](https://user-images.githubusercontent.com/10970390/223624298-39721a35-4737-4dff-90ae-8b9eb897b1d6.png)
Saved model name ![Screenshot from 2023-03-08 12-42-06](https://user-images.githubusercontent.com/10970390/223624368-9d4ec67b-da80-47fa-b125-8f7827ef6938.png)