This commit is contained in:
lvmin 2023-10-13 05:02:20 -07:00
parent 10e2db67d6
commit a252f75549
4 changed files with 26 additions and 17 deletions

View File

@ -6,7 +6,7 @@ import fooocus_version
from modules.launch_util import is_installed, run, python, run_pip, requirements_met
from modules.model_loader import load_file_from_url
from modules.path import modelfile_path, lorafile_path, vae_approx_path, fooocus_expansion_path
from modules.path import modelfile_path, lorafile_path, vae_approx_path, fooocus_expansion_path, checkpoint_downloads
REINSTALL_ALL = False
@ -46,13 +46,6 @@ def prepare_environment():
return
model_filenames = [
('sd_xl_base_1.0_0.9vae.safetensors',
'https://huggingface.co/stabilityai/stable-diffusion-xl-base-1.0/resolve/main/sd_xl_base_1.0_0.9vae.safetensors'),
('sd_xl_refiner_1.0_0.9vae.safetensors',
'https://huggingface.co/stabilityai/stable-diffusion-xl-refiner-1.0/resolve/main/sd_xl_refiner_1.0_0.9vae.safetensors')
]
lora_filenames = [
('sd_xl_offset_example-lora_1.0.safetensors',
'https://huggingface.co/stabilityai/stable-diffusion-xl-base-1.0/resolve/main/sd_xl_offset_example-lora_1.0.safetensors')
@ -67,7 +60,7 @@ vae_approx_filenames = [
def download_models():
for file_name, url in model_filenames:
for file_name, url in checkpoint_downloads.items():
load_file_from_url(url=url, model_dir=modelfile_path, file_name=file_name)
for file_name, url in lora_filenames:
load_file_from_url(url=url, model_dir=lorafile_path, file_name=file_name)

View File

@ -5,11 +5,9 @@ import modules.sdxl_styles
from modules.model_loader import load_file_from_url
config_path = "user_path_config.txt"
config_dict = {}
try:
if os.path.exists(config_path):
with open(config_path, "r", encoding="utf-8") as json_file:
@ -38,7 +36,8 @@ upscale_models_path = get_dir_or_set_default('upscale_models_path', '../models/u
inpaint_models_path = get_dir_or_set_default('inpaint_models_path', '../models/inpaint/')
controlnet_models_path = get_dir_or_set_default('controlnet_models_path', '../models/controlnet/')
clip_vision_models_path = get_dir_or_set_default('clip_vision_models_path', '../models/clip_vision/')
fooocus_expansion_path = get_dir_or_set_default('fooocus_expansion_path', '../models/prompt_expansion/fooocus_expansion')
fooocus_expansion_path = get_dir_or_set_default('fooocus_expansion_path',
'../models/prompt_expansion/fooocus_expansion')
temp_outputs_path = get_dir_or_set_default('temp_outputs_path', '../outputs/')
@ -103,11 +102,25 @@ default_negative_prompt = get_config_item_or_set_default(
default_value='low quality, bad hands, bad eyes, cropped, missing fingers, extra digit',
validator=lambda x: isinstance(x, str)
)
default_positive_prompt = get_config_item_or_set_default(
key='default_positive_prompt',
default_value='',
validator=lambda x: isinstance(x, str)
)
checkpoint_downloads = get_config_item_or_set_default(
key='checkpoint_downloads',
default_value={
'sd_xl_base_1.0_0.9vae.safetensors':
'https://huggingface.co/stabilityai/stable-diffusion-xl-base-1.0/resolve/main/sd_xl_base_1.0_0.9vae.safetensors',
'sd_xl_refiner_1.0_0.9vae.safetensors':
'https://huggingface.co/stabilityai/stable-diffusion-xl-refiner-1.0/resolve/main/sd_xl_refiner_1.0_0.9vae.safetensors'
},
validator=lambda x: isinstance(x, dict) and all(isinstance(k, str) and isinstance(v, str) for k, v in x.items())
)
with open(config_path, "w", encoding="utf-8") as json_file:
json.dump(config_dict, json_file, indent=4)
os.makedirs(temp_outputs_path, exist_ok=True)
model_filenames = []
@ -151,7 +164,8 @@ def downloading_inpaint_models(v):
model_dir=inpaint_models_path,
file_name='inpaint.fooocus.patch'
)
return os.path.join(inpaint_models_path, 'fooocus_inpaint_head.pth'), os.path.join(inpaint_models_path, 'inpaint.fooocus.patch')
return os.path.join(inpaint_models_path, 'fooocus_inpaint_head.pth'), os.path.join(inpaint_models_path,
'inpaint.fooocus.patch')
if v == 'v2.5':
load_file_from_url(
@ -159,7 +173,8 @@ def downloading_inpaint_models(v):
model_dir=inpaint_models_path,
file_name='inpaint_v25.fooocus.patch'
)
return os.path.join(inpaint_models_path, 'fooocus_inpaint_head.pth'), os.path.join(inpaint_models_path, 'inpaint_v25.fooocus.patch')
return os.path.join(inpaint_models_path, 'fooocus_inpaint_head.pth'), os.path.join(inpaint_models_path,
'inpaint_v25.fooocus.patch')
def downloading_controlnet_canny():

View File

@ -1,4 +1,3 @@
import modules.path
# https://github.com/twri/sdxl_prompt_styler/blob/main/sdxl_styles.json
styles = [

View File

@ -56,7 +56,9 @@ with shared.gradio_root:
gallery = gr.Gallery(label='Gallery', show_label=False, object_fit='contain', height=720, visible=True, elem_classes='resizable_area')
with gr.Row(elem_classes='type_row'):
with gr.Column(scale=0.85):
prompt = gr.Textbox(show_label=False, placeholder="Type prompt here.", container=False, autofocus=True, elem_classes='type_row', lines=1024)
prompt = gr.Textbox(show_label=False, placeholder="Type prompt here.",
value=modules.path.default_positive_prompt,
container=False, autofocus=True, elem_classes='type_row', lines=1024)
with gr.Column(scale=0.15, min_width=0):
run_button = gr.Button(label="Generate", value="Generate", elem_classes='type_row', visible=True)
skip_button = gr.Button(label="Skip", value="Skip", elem_classes='type_row_half', visible=False)