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

Parse lora weights from civitai resources #15712

Open
wants to merge 5 commits into
base: dev
Choose a base branch
from

Conversation

anonstash
Copy link

Description

  • Enables directly parsing the Lora weights from the "Civitai resources:" string that is included in an image's metadata when downloaded from Civitai. You can see this in action by clicking the blue arrow to "Read generation params" or when clicking "Send to txt2img" and such
  • Adds logic in extensions-builtin/Lora/networks.py to check for a .json file with the same name as a model's file, and extracts the modelVersionId which is what Civitai uses to identify a specific model + version
  • Adds a function to modules/infotext_utils.py to handle parsing the resources string
  • I've opened a separate PR to the Civitai browser plus plugin to record the modelVersionId in the model json, but this works regardless assuming you have a json file with the modelVersionId as one of the fields

Example prompt:

score_9, score_8_up, score_7_up, car, tree, hill
Negative prompt: score_6, score_5, score_4, simple background, black and white, mono color
Steps: 30, Sampler: DPM++ 2M Karras, CFG scale: 13.5, Seed: 839351144, Size: 832x1216, Clip skip: 2, Civitai resources: [{"type":"checkpoint","modelVersionId":290640},{"type":"ImageJobNetworkParams { Strength = 0.4, TriggerWord = , Type = lora }","weight":0.4,"modelVersionId":426797},{"type":"ImageJobNetworkParams { Strength = 0.4, TriggerWord = , Type = lora }","weight":0.4,"modelVersionId":135867},{"type":"embed","weight":1,"modelVersionId":94057},{"type":"embed","modelVersionId":250708},{"type":"embed","modelVersionId":250712}]

Final prompt:

score_9, score_8_up, score_7_up, car, tree, hill <lora:43stl1ght1ngXLP2:0.4> <lora:add-detail-xl:0.4>

Screenshots/videos:

demo.mp4

Checklist:

@@ -230,6 +231,47 @@ def restore_old_hires_fix_params(res):
res['Hires resize-2'] = height


def parse_civitai_resources(x: str):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be implemented in an extension using script_callbacks.on_infotext_pasted

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants