GuizzyQC / sd_api_pictures_tag_injection

Based on @Brawlence's extension
24 stars 6 forks source link

AttributeError: module 'modules.shared' has no attribute 'character' #4

Open cochese9000 opened 1 year ago

cochese9000 commented 1 year ago

I'm getting this error with the latest ooba pull.

 File "P:\ai\llms\oobabooga\text-generation-webui\extensions\sd_api_pictures_tag_injection\script.py", line 216, in create_suffix
    if characterfocus and shared.character != 'None':
AttributeError: module 'modules.shared' has no attribute 'character'
GuizzyQC commented 1 year ago

This should be fixed after the latest commit to this extension, can you try updating the extension with a "git pull"?

Le mer. 5 juill. 2023, 21 h 36, cochese9000 @.***> a écrit :

I'm getting this error with the latest ooba pull.

File "P:\ai\llms\oobabooga\text-generation-webui\extensions\sd_api_pictures_tag_injection\script.py", line 216, in create_suffix if characterfocus and shared.character != 'None': AttributeError: module 'modules.shared' has no attribute 'character'

— Reply to this email directly, view it on GitHub https://github.com/GuizzyQC/sd_api_pictures_tag_injection/issues/4, or unsubscribe https://github.com/notifications/unsubscribe-auth/AUVK55N5DKTNGQVHSA4A5DDXOYJCPANCNFSM6AAAAAAZ7WMRRA . You are receiving this because you are subscribed to this thread.Message ID: @.***>

cochese9000 commented 1 year ago

Hey, thanks for checking. I was up to date on everything and can't see a commit I may have missed. I am trying again today, but I'm getting other errors with the webui, so I'll let you know how it goes.

One things I struggled with, btw, is the settigns didn't seem to load up from the webui settings.json. At least, not all of them. I tried looking through the code to see if there was a per-property mapping, but couldn't see one.

My understanding is that if I prefix 'sd_api_pictures_tag_injection-' in front of the props in the script.py file in the extension, then they will overwrite the defaults in that file, is that right?

cochese9000 commented 1 year ago

OK, so update issues with Ooba not fixed, I'm still getting the issue:

  File "P:\ai\llms\oobabooga\text-generation-webui\modules\extensions.py", line 62, in _apply_string_extensions
    text = func(text, state)
  File "P:\ai\llms\oobabooga\text-generation-webui\extensions\sd_api_pictures_tag_injection\script.py", line 351, in output_modifier
    string = get_SD_pictures(string) + "\n" + text
  File "P:\ai\llms\oobabooga\text-generation-webui\extensions\sd_api_pictures_tag_injection\script.py", line 236, in get_SD_pictures
    create_suffix()
  File "P:\ai\llms\oobabooga\text-generation-webui\extensions\sd_api_pictures_tag_injection\script.py", line 216, in create_suffix
    if characterfocus and shared.character != 'None':
AttributeError: module 'modules.shared' has no attribute 'character'

UPDATE: Ah, it is fixed. sorry. I had updated yesterday to your fix, but it was my own changes that were stopping it working! I thought I had rolled them all back, but I hadn't. Sorry for wasting your time.

GuizzyQC commented 1 year ago

No worries!

For the settings.json or yml, everything that's in params in script.py can be set. Yes, it should be in the format sd_api_pictures_tag_injection- with the name of the variable inside of params.

cochese9000 commented 1 year ago

OK, gret thanks for confirming.

This extension is great, btw! I'm struggling to get decent output, though, I can see it's got the right idea. I've changed the way it asks for a description, so I can better mix it with my own pre-made prompt from SD. I found your approach to be very long descriptions that lost any of the intended composition.

For example: I would iterate over a character I had made using a composite of a few loras and quite a long description. I wanted her to be in a scene with objects and people. If I let the char describe the scene using the default script.py instruction it would output a full paragraph of poetic text and none of my details or the checkpoits/translations/chars detail would be present (maybe some, but totally different to intended).

NOTE: It may be very different for different models. I am using TheBloke_WizardLM-13B-V1-0-Uncensored-SuperHOT-8K-GPTQ.

I think this workflow might be common:

  1. iterate over a prompt to get the right kind of output that resembles your char and leave some 'vaiables' that support enough changes to vary the composition.
  2. add global presets to the checkpoint files and translations.
  3. add char prompt
  4. add secondary prompt if desired.
  5. (adv.) change the script.py file to have a custom message for asking for the description of the scene.

I've changed mine to:

(line 135)

string = "Using only terms that appear in danbooru tags, write a comma-separated list of 8 keywords that describe your body, who you are with, your clothing, and the environment (It is important to only use terms that describe the way anyone looks, or any activity being performed).  Do not include a reptition of the instructions. After you have written the list, add the following text: " + after_you.strip()

I find this works a little, but not great. Better than the default (because my char still looks a bit like my char does in SD), but only so-so.

I was thinking that it would be great if you could do a batch face swap (BFS) on the {{char}} (but not anyone else) so you could rough the image (you always take a hit on the char if you increase the detail on the scene) and then give batch-face-swap the final pass. But the API doesn't support it yet (though you can call BFS via the api, apparently).