zhiweili commited on
Commit
e4f596a
1 Parent(s): 7f5e423
Files changed (2) hide show
  1. app_base.py +7 -7
  2. inversion_run_base.py +7 -2
app_base.py CHANGED
@@ -114,18 +114,18 @@ def create_demo() -> gr.Blocks:
114
  edit_prompt = gr.Textbox(lines=1, label="Edit Prompt", value=DEFAULT_EDIT_PROMPT)
115
  category = gr.Textbox(label="Category", value=DEFAULT_CATEGORY, visible=False)
116
  with gr.Column():
117
- num_steps = gr.Slider(minimum=1, maximum=100, value=5, step=1, label="Num Steps")
118
- start_step = gr.Slider(minimum=1, maximum=100, value=1, step=1, label="Start Step")
119
- guidance_scale = gr.Slider(minimum=0, maximum=20, value=2.5, step=0.5, label="Guidance Scale")
120
  with gr.Accordion("Advanced Options", open=False):
121
- generate_size = gr.Number(label="Generate Size", value=512)
 
122
  mask_expansion = gr.Number(label="Mask Expansion", value=50, visible=True)
123
  mask_dilation = gr.Slider(minimum=0, maximum=10, value=2, step=1, label="Mask Dilation")
124
- enhance_face = gr.Checkbox(label="Enhance Face", value=True)
 
125
  with gr.Column():
126
  seed = gr.Number(label="Seed", value=8)
127
- w1 = gr.Number(label="W1", value=1.5)
128
- adapter_weights = gr.Slider(minimum=0, maximum=1, value=0.5, step=0.1, label="Adapter Weights", visible=False)
129
  g_btn = gr.Button("Edit Image")
130
 
131
  with gr.Row():
 
114
  edit_prompt = gr.Textbox(lines=1, label="Edit Prompt", value=DEFAULT_EDIT_PROMPT)
115
  category = gr.Textbox(label="Category", value=DEFAULT_CATEGORY, visible=False)
116
  with gr.Column():
117
+ num_steps = gr.Slider(minimum=1, maximum=100, value=20, step=1, label="Num Steps")
118
+ start_step = gr.Slider(minimum=1, maximum=100, value=15, step=1, label="Start Step")
 
119
  with gr.Accordion("Advanced Options", open=False):
120
+ guidance_scale = gr.Slider(minimum=0, maximum=20, value=0, step=0.5, label="Guidance Scale")
121
+ generate_size = gr.Number(label="Generate Size", value=1024)
122
  mask_expansion = gr.Number(label="Mask Expansion", value=50, visible=True)
123
  mask_dilation = gr.Slider(minimum=0, maximum=10, value=2, step=1, label="Mask Dilation")
124
+ enhance_face = gr.Checkbox(label="Enhance Face", value=False)
125
+ adapter_weights = gr.Slider(minimum=0, maximum=1, value=0.5, step=0.1, label="Adapter Weights", visible=True)
126
  with gr.Column():
127
  seed = gr.Number(label="Seed", value=8)
128
+ w1 = gr.Number(label="W1", value=2)
 
129
  g_btn = gr.Button("Edit Image")
130
 
131
  with gr.Row():
inversion_run_base.py CHANGED
@@ -1,4 +1,5 @@
1
  import torch
 
2
 
3
  from diffusers import (
4
  DDPMScheduler,
@@ -55,7 +56,11 @@ pipeline.scheduler = DDPMScheduler.from_pretrained(
55
  subfolder="scheduler",
56
  )
57
 
58
- # pipeline.load_lora_weights("checkpoints/lora", weight_name="zy_AmateurStyle_v2.safetensors", adapter_name="zy_AmateurStyle_v2")
 
 
 
 
59
 
60
  config = get_config(args)
61
 
@@ -79,7 +84,7 @@ def run(
79
  guidance_scale:float,
80
  adapter_weights:float,
81
  ):
82
- # pipeline.set_adapters(["zy_AmateurStyle_v2"], adapter_weights=[adapter_weights])
83
  generator = torch.Generator().manual_seed(seed)
84
 
85
  config.num_steps_inversion = num_steps
 
1
  import torch
2
+ import os
3
 
4
  from diffusers import (
5
  DDPMScheduler,
 
56
  subfolder="scheduler",
57
  )
58
 
59
+ os.makedirs('checkpoints/lora', exist_ok=True)
60
+ if not os.path.exists('checkpoints/lora/perfection_style.safetensors'):
61
+ os.system("wget https://civitai.com/api/download/models/458257?type=Model&format=SafeTensor -O ./checkpoints/lora/perfection_style.safetensors")
62
+
63
+ pipeline.load_lora_weights("checkpoints/lora", weight_name="perfection_style.safetensors", adapter_name="perfection_style")
64
 
65
  config = get_config(args)
66
 
 
84
  guidance_scale:float,
85
  adapter_weights:float,
86
  ):
87
+ pipeline.set_adapters(["perfection_style"], adapter_weights=[adapter_weights])
88
  generator = torch.Generator().manual_seed(seed)
89
 
90
  config.num_steps_inversion = num_steps