mirror of
https://github.com/lllyasviel/Fooocus.git
synced 2026-08-16 13:13:16 +02:00
fix: correctly map resolution, use empty styles for A1111
This commit is contained in:
+9
-14
@@ -1,7 +1,6 @@
|
|||||||
import json
|
import json
|
||||||
import re
|
import re
|
||||||
from abc import ABC, abstractmethod
|
from abc import ABC, abstractmethod
|
||||||
from enum import Enum
|
|
||||||
from PIL import Image
|
from PIL import Image
|
||||||
|
|
||||||
import modules.config
|
import modules.config
|
||||||
@@ -30,6 +29,7 @@ class A1111MetadataParser(MetadataParser):
|
|||||||
|
|
||||||
fooocus_to_a1111 = {
|
fooocus_to_a1111 = {
|
||||||
'negative_prompt': 'Negative prompt',
|
'negative_prompt': 'Negative prompt',
|
||||||
|
'styles': 'Styles',
|
||||||
'steps': 'Steps',
|
'steps': 'Steps',
|
||||||
'sampler': 'Sampler',
|
'sampler': 'Sampler',
|
||||||
'guidance_scale': 'CFG scale',
|
'guidance_scale': 'CFG scale',
|
||||||
@@ -44,8 +44,6 @@ class A1111MetadataParser(MetadataParser):
|
|||||||
}
|
}
|
||||||
|
|
||||||
def parse_json(self, metadata: str) -> dict:
|
def parse_json(self, metadata: str) -> dict:
|
||||||
# TODO add correct mapping
|
|
||||||
|
|
||||||
prompt = ''
|
prompt = ''
|
||||||
negative_prompt = ''
|
negative_prompt = ''
|
||||||
|
|
||||||
@@ -66,6 +64,10 @@ class A1111MetadataParser(MetadataParser):
|
|||||||
else:
|
else:
|
||||||
prompt += ('' if prompt == '' else "\n") + line
|
prompt += ('' if prompt == '' else "\n") + line
|
||||||
|
|
||||||
|
# set defaults
|
||||||
|
data = {
|
||||||
|
'styles': '[]'
|
||||||
|
}
|
||||||
# if shared.opts.infotext_styles != "Ignore":
|
# if shared.opts.infotext_styles != "Ignore":
|
||||||
# found_styles, prompt, negative_prompt = shared.prompt_styles.extract_styles_from_prompt(prompt,
|
# found_styles, prompt, negative_prompt = shared.prompt_styles.extract_styles_from_prompt(prompt,
|
||||||
# negative_prompt)
|
# negative_prompt)
|
||||||
@@ -75,9 +77,9 @@ class A1111MetadataParser(MetadataParser):
|
|||||||
# elif shared.opts.infotext_styles == "Apply if any" and found_styles:
|
# elif shared.opts.infotext_styles == "Apply if any" and found_styles:
|
||||||
# res["Styles array"] = found_styles
|
# res["Styles array"] = found_styles
|
||||||
|
|
||||||
data = {
|
data |= {
|
||||||
'prompt': prompt,
|
'prompt': prompt,
|
||||||
'negative_prompt': negative_prompt
|
'negative_prompt': negative_prompt,
|
||||||
}
|
}
|
||||||
|
|
||||||
for k, v in re_param.findall(lastline):
|
for k, v in re_param.findall(lastline):
|
||||||
@@ -87,9 +89,7 @@ class A1111MetadataParser(MetadataParser):
|
|||||||
|
|
||||||
m = re_imagesize.match(v)
|
m = re_imagesize.match(v)
|
||||||
if m is not None:
|
if m is not None:
|
||||||
# TODO check
|
data[f'resolution'] = str((m.group(1), m.group(2)))
|
||||||
data[f"{k}-1"] = m.group(1)
|
|
||||||
data[f"{k}-2"] = m.group(2)
|
|
||||||
else:
|
else:
|
||||||
data[list(self.fooocus_to_a1111.keys())[list(self.fooocus_to_a1111.values()).index(k)]] = v
|
data[list(self.fooocus_to_a1111.keys())[list(self.fooocus_to_a1111.values()).index(k)]] = v
|
||||||
except Exception:
|
except Exception:
|
||||||
@@ -110,7 +110,7 @@ class A1111MetadataParser(MetadataParser):
|
|||||||
data = {k: v for _, k, v, _, _ in metadata}
|
data = {k: v for _, k, v, _, _ in metadata}
|
||||||
|
|
||||||
# TODO check if correct
|
# TODO check if correct
|
||||||
width, heigth = data['resolution'].split(', ')
|
width, heigth = eval(data['resolution'])
|
||||||
|
|
||||||
lora_hashes = []
|
lora_hashes = []
|
||||||
for index in range(5):
|
for index in range(5):
|
||||||
@@ -122,12 +122,7 @@ class A1111MetadataParser(MetadataParser):
|
|||||||
lora_hashes.append(f'{name.split(".")[0]}: {hash}')
|
lora_hashes.append(f'{name.split(".")[0]}: {hash}')
|
||||||
lora_hashes_string = ", ".join(lora_hashes)
|
lora_hashes_string = ", ".join(lora_hashes)
|
||||||
|
|
||||||
# set static defaults
|
|
||||||
generation_params = {
|
generation_params = {
|
||||||
'styles': [],
|
|
||||||
}
|
|
||||||
|
|
||||||
generation_params |= {
|
|
||||||
self.fooocus_to_a1111['steps']: data['steps'],
|
self.fooocus_to_a1111['steps']: data['steps'],
|
||||||
self.fooocus_to_a1111['sampler']: data['sampler'],
|
self.fooocus_to_a1111['sampler']: data['sampler'],
|
||||||
self.fooocus_to_a1111['guidance_scale']: data['guidance_scale'],
|
self.fooocus_to_a1111['guidance_scale']: data['guidance_scale'],
|
||||||
|
|||||||
Reference in New Issue
Block a user