Upload scripts using SD-Hub extension
Browse filesThis view is limited to 50 files because it contains too many changes.
See raw diff
- scripts/CFG Auto.py +368 -0
- scripts/CFG Schedule.py +369 -0
- scripts/ContorlNet_I2I_sequence_toyxyz_V2.py +367 -0
- scripts/LoopbackWave.py +348 -0
- scripts/Txt2img2img2img.py +291 -0
- scripts/UnsharpMask.py +54 -0
- scripts/__pycache__/CFG Auto.cpython-310.pyc +0 -0
- scripts/__pycache__/CFG Schedule.cpython-310.pyc +0 -0
- scripts/__pycache__/ContorlNet_I2I_sequence_toyxyz_V2.cpython-310.pyc +0 -0
- scripts/__pycache__/LoopbackWave.cpython-310.pyc +0 -0
- scripts/__pycache__/Txt2img2img2img.cpython-310.pyc +0 -0
- scripts/__pycache__/UnsharpMask.cpython-310.pyc +0 -0
- scripts/__pycache__/advanced_loopback.cpython-310.pyc +0 -0
- scripts/__pycache__/advanced_loopback_blend.cpython-310.pyc +0 -0
- scripts/__pycache__/advanced_seed_blending.cpython-310.pyc +0 -0
- scripts/__pycache__/alternate_sampler_noise_schedules.cpython-310.pyc +0 -0
- scripts/__pycache__/block_lora.cpython-310.pyc +0 -0
- scripts/__pycache__/cache_cleaner(from sd-webui-gradio-cleaner).cpython-310.pyc +0 -0
- scripts/__pycache__/custom_code-Copy1.cpython-310.pyc +0 -0
- scripts/__pycache__/custom_code.cpython-310.pyc +0 -0
- scripts/__pycache__/epiCFG_schedule_type.cpython-310.pyc +0 -0
- scripts/__pycache__/external_masking.cpython-310.pyc +0 -0
- scripts/__pycache__/img2imgalt-Copy1.cpython-310.pyc +0 -0
- scripts/__pycache__/img2imgalt.cpython-310.pyc +0 -0
- scripts/__pycache__/loopback-Copy1.cpython-310.pyc +0 -0
- scripts/__pycache__/loopback.cpython-310.pyc +0 -0
- scripts/__pycache__/loopback_for_chain.cpython-310.pyc +0 -0
- scripts/__pycache__/outpainting_mk_2-Copy1.cpython-310.pyc +0 -0
- scripts/__pycache__/outpainting_mk_2.cpython-310.pyc +0 -0
- scripts/__pycache__/poor_mans_outpainting-Copy1.cpython-310.pyc +0 -0
- scripts/__pycache__/poor_mans_outpainting.cpython-310.pyc +0 -0
- scripts/__pycache__/postprocessing_codeformer-Copy1.cpython-310.pyc +0 -0
- scripts/__pycache__/postprocessing_codeformer.cpython-310.pyc +0 -0
- scripts/__pycache__/postprocessing_gfpgan-Copy1.cpython-310.pyc +0 -0
- scripts/__pycache__/postprocessing_gfpgan.cpython-310.pyc +0 -0
- scripts/__pycache__/postprocessing_upscale-Copy1.cpython-310.pyc +0 -0
- scripts/__pycache__/postprocessing_upscale.cpython-310.pyc +0 -0
- scripts/__pycache__/process_png_metadata.cpython-310.pyc +0 -0
- scripts/__pycache__/prompt_matrix-Copy1.cpython-310.pyc +0 -0
- scripts/__pycache__/prompt_matrix.cpython-310.pyc +0 -0
- scripts/__pycache__/prompter.cpython-310.pyc +0 -0
- scripts/__pycache__/prompts_from_file-Copy1.cpython-310.pyc +0 -0
- scripts/__pycache__/prompts_from_file.cpython-310.pyc +0 -0
- scripts/__pycache__/prompts_from_file_2.cpython-310.pyc +0 -0
- scripts/__pycache__/quick_upscale.cpython-310.pyc +0 -0
- scripts/__pycache__/run_n_times.cpython-310.pyc +0 -0
- scripts/__pycache__/save-steps.cpython-310.pyc +0 -0
- scripts/__pycache__/sd_upscale-Copy1.cpython-310.pyc +0 -0
- scripts/__pycache__/sd_upscale.cpython-310.pyc +0 -0
- scripts/__pycache__/size_travel.cpython-310.pyc +0 -0
scripts/CFG Auto.py
ADDED
@@ -0,0 +1,368 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#CFG Scheduler for Automatic1111 Stable Diffusion web-ui
|
2 |
+
#Author: https://github.com/guzuligo/
|
3 |
+
#Based on: https://github.com/tkalayci71/attenuate-cfg-scale
|
4 |
+
#Version: 1.81
|
5 |
+
|
6 |
+
from logging import PlaceHolder
|
7 |
+
import math
|
8 |
+
import os
|
9 |
+
import sys
|
10 |
+
import traceback
|
11 |
+
import copy
|
12 |
+
import numpy as np
|
13 |
+
import modules.scripts as scripts
|
14 |
+
import gradio as gr
|
15 |
+
|
16 |
+
#from modules.processing import Processed, process_images
|
17 |
+
from modules import images,processing
|
18 |
+
from modules.processing import process_images, Processed
|
19 |
+
from modules.processing import Processed
|
20 |
+
from modules.shared import opts, cmd_opts, state
|
21 |
+
class Script(scripts.Script):
|
22 |
+
def run(self,p,n0,dns,ns1,ns2,nr1,nr2 ,loops,nSingle):
|
23 |
+
return self.runBasic(p,n0,dns,ns1,ns2,nr1,nr2 ,loops,nSingle)
|
24 |
+
|
25 |
+
#def run(self,p,cfg,eta,dns ,loops,nSingle):
|
26 |
+
# return self.runAdvanced(p,cfg,eta,dns ,loops,nSingle)
|
27 |
+
|
28 |
+
def show(self, is_img2img):
|
29 |
+
self.isAdvanced=False
|
30 |
+
return True
|
31 |
+
def title(self):
|
32 |
+
return "CFG Scheduling" if (self.isAdvanced) else "CFG Auto"
|
33 |
+
|
34 |
+
def uiAdvanced(self, is_img2img):
|
35 |
+
|
36 |
+
placeholder="The steps on which to modify, in format step:value - example: 0:10 ; 10:15"
|
37 |
+
n0 = gr.Textbox(label="CFG",placeholder=placeholder)
|
38 |
+
placeholder="You can also use functions like: 0: math.fabs(-t) ; 1: (1-t/T) ; 2:=e ;3:t*d"
|
39 |
+
n1 = gr.Textbox(label="ETA",placeholder=placeholder)
|
40 |
+
#loops
|
41 |
+
#n2 = gr.Slider(minimum=1, maximum=32, step=1, label='Loops', value=1)
|
42 |
+
n2 = gr.Slider(minimum=0, maximum=1, step=0.01, label='Target Denoising : Decay per Batch', value=0.5)
|
43 |
+
with gr.Row():
|
44 |
+
loops=gr.Number(value=1,precision=0,label="loops")
|
45 |
+
nSingle= gr.Checkbox(label="Loop returns one")
|
46 |
+
|
47 |
+
return [n0,n1,n2 ,loops,nSingle]
|
48 |
+
#uiBasic
|
49 |
+
def uiAuto(self, is_img2img):
|
50 |
+
self.autoOptions={"b1":"Blur First V1","b2":"Blur Last","f1":"Force at Start V1","f2":"Force Allover"}
|
51 |
+
with gr.Row():
|
52 |
+
dns = gr.Slider(minimum=0, maximum=1, step=0.01, label='Target Denoising : Decay per Batch', value=0.25)
|
53 |
+
n0=gr.Dropdown(list(self.autoOptions.values()),value=self.autoOptions["b1"],label="Scheduler")
|
54 |
+
with gr.Row():
|
55 |
+
n1 = gr.Slider(minimum=0, maximum=100, step=1, label='Main Strength', value=10)
|
56 |
+
n2 = gr.Slider(minimum=0, maximum=100, step=1, label='Sub- Strength', value=10)
|
57 |
+
with gr.Row():
|
58 |
+
n3 = gr.Slider(minimum=0, maximum=100, step=1, label='Main Range', value=10)
|
59 |
+
n4 = gr.Slider(minimum=0, maximum=100, step=1, label='Sub- Range', value=10)
|
60 |
+
with gr.Row():
|
61 |
+
loops=gr.Number(value=1,precision=0,label="loops")
|
62 |
+
nSingle= gr.Checkbox(label="Loop returns one")
|
63 |
+
return [n0,dns, n1,n2,n3,n4 ,loops,nSingle]
|
64 |
+
|
65 |
+
def ui(self, is_img2img):
|
66 |
+
return self.uiAdvanced(is_img2img) if (self.isAdvanced) else self.uiAuto(is_img2img)
|
67 |
+
|
68 |
+
def prepare(self,p,cfg,eta):
|
69 |
+
sampler_name=p.sampler_name
|
70 |
+
if not sampler_name:
|
71 |
+
print("Warning: sampler not specified. Using Euler a")
|
72 |
+
sampler_name="Euler a"
|
73 |
+
#if p.sampler_index in (0,1,2,7,8,10,14):
|
74 |
+
if sampler_name in ('Euler a','Euler','LMS','DPM++ 2M','DPM fast','LMS Karras','DPM++ 2M Karras'):
|
75 |
+
max_mul_count = p.steps * p.batch_size
|
76 |
+
steps_per_mul = p.batch_size
|
77 |
+
#elif p.sampler_index in (3,4,5,6,11,12,13):
|
78 |
+
elif sampler_name in ('Heun','DPM2','DPM2 a','DPM++ 2S a','DPM2 Karras','DPM2 a Karras','DPM++ 2S a Karras'):
|
79 |
+
max_mul_count = ((p.steps*2)-1) * p.batch_size
|
80 |
+
steps_per_mul = 2 * p.batch_size
|
81 |
+
#elif p.sampler_index==15: # ddim
|
82 |
+
elif sampler_name=='DDIM': # ddim
|
83 |
+
max_mul_count = fix_ddim_step_count(p.steps)
|
84 |
+
steps_per_mul = 1
|
85 |
+
#elif p.sampler_index==16: # plms
|
86 |
+
elif sampler_name=='PLMS': # plms
|
87 |
+
max_mul_count = fix_ddim_step_count(p.steps)+1
|
88 |
+
steps_per_mul = 1
|
89 |
+
else:
|
90 |
+
print("Not supported sampler", p.sampler_name, p.sampler_index)
|
91 |
+
return # 9=dpm adaptive
|
92 |
+
|
93 |
+
|
94 |
+
|
95 |
+
#print("it is:",n0t)
|
96 |
+
#for x in range(int(n)):
|
97 |
+
self.p=p
|
98 |
+
cfg=cfg.strip()
|
99 |
+
eta=eta.strip()
|
100 |
+
if cfg:
|
101 |
+
p.cfg_scale=Fake_float(p.cfg_scale,self.split(cfg,str(p.cfg_scale)) , max_mul_count, steps_per_mul)
|
102 |
+
#p.cfg_scale.p=p
|
103 |
+
if eta:
|
104 |
+
if (eta.find("@")==-1):
|
105 |
+
p.s_churn=p.eta =Fake_float(p.eta or 1,self.split(eta,str(p.eta)) , max_mul_count, steps_per_mul)
|
106 |
+
#print(p.s_noise)
|
107 |
+
|
108 |
+
#Fake_float(p.s_churn or 1,self.split(eta,str(p.s_churn)), max_mul_count, steps_per_mul)
|
109 |
+
else:
|
110 |
+
eta=eta.split("@")
|
111 |
+
if eta[0].strip()!="":
|
112 |
+
p.s_churn=Fake_float(p.s_churn or 1,self.split(eta[0],str(p.s_churn)), max_mul_count, steps_per_mul)
|
113 |
+
if len(eta)>1 and eta[1].strip()!="":
|
114 |
+
p.s_noise=Fake_float(p.s_noise or 1,self.split(eta[1],str(p.s_noise)), max_mul_count, steps_per_mul)
|
115 |
+
if len(eta)>2 and eta[2].strip()!="":
|
116 |
+
p.s_tmin=Fake_float(p.s_tmin or 1,self.split(eta[2],str(p.s_tmin)), max_mul_count, steps_per_mul)
|
117 |
+
if len(eta)>3 and eta[3].strip()!="":
|
118 |
+
p.s_tmax=Fake_float(p.s_tmax or 1,self.split(eta[2],str(p.s_tmax)), max_mul_count, steps_per_mul)
|
119 |
+
|
120 |
+
|
121 |
+
#p.cfg_scale.p=p
|
122 |
+
#
|
123 |
+
|
124 |
+
|
125 |
+
|
126 |
+
def runBasic(self,p,n0,dns,ns1,ns2,nr1,nr2 ,loops,nSingle):
|
127 |
+
if(n0==self.autoOptions["b1"]):
|
128 |
+
cfg=f"""0:{ns2}/2 if (t<T* (({nr1}/100)**2)) else cfg"""
|
129 |
+
eta=f"""0:{ns1}+1 if (t<T*(({nr1}/100)**2) ) else e*({nr2}/50)"""
|
130 |
+
elif(n0==self.autoOptions["f1"]):
|
131 |
+
cfg=f"""0:({ns1}*4)*((1-d**0.5)**1.5)/(t*(30-cfg)/30+1)/(l*2+1) if (t<T*{nr1}/100) else 0.1 if (t<T*({nr1}+{nr2}-{nr1}*{nr2})/100) else 7-d*7"""
|
132 |
+
eta=f"""0:0.8+{ns2}/25-min(t*0.1, 0.8+{ns2}/25 -0.01) if (t<T*{nr1}/100) else {ns2}/(10*(1+l*0.5)) if (t<T*({nr1}+{nr2}-{nr1}*{nr2})/100) else 1+e"""
|
133 |
+
elif(n0==self.autoOptions["b2"]):
|
134 |
+
cfg=f"""0:cfg if (e>{nr1}/100 or e<(1-({nr1}+{nr2}*(100-{nr1})/100)/100)) else {ns2}/10"""
|
135 |
+
eta=f"""0:e if (e>{nr1}/100 or e<(1-({nr1}+{nr2}*(100-{nr1})/100)/100)) else {ns1}/10"""
|
136 |
+
elif(n0==self.autoOptions["f2"]):
|
137 |
+
cfg=f"""= min(40,max(0,cfg+x(t)*({ns2}-50)/2 )) """
|
138 |
+
eta=f"""0:(1-(t%(2+ 10-.1*{nr1} ))/ (2+10-.1*{nr1}) )*{ns1}*.1 * (e*(100-{nr2})+{nr2})*.01 """
|
139 |
+
self.cfgsib={"Scheduler":n0,'Main Strength':ns1,'Sub- Strength':ns2,'Main Range':nr1,'Sub- Range':nr2}
|
140 |
+
return self.runAdvanced(p,cfg,eta,dns ,loops,nSingle)
|
141 |
+
|
142 |
+
|
143 |
+
def runAdvanced(self, p, cfg,eta,dns ,loops,nSingle):
|
144 |
+
self.initSeed=p.seed
|
145 |
+
#loops=p.batch_size
|
146 |
+
loops = loops if (loops>0) else 1
|
147 |
+
|
148 |
+
batch_count=p.n_iter
|
149 |
+
state.job_count = loops*p.n_iter
|
150 |
+
p.denoising_strength=p.denoising_strength or (1 if (self.isAdvanced) else 0.2)
|
151 |
+
initial_denoising_strength=p.denoising_strength
|
152 |
+
p.do_not_save_grid = True
|
153 |
+
if hasattr(p,"init_images"):
|
154 |
+
original_init_image = p.init_images
|
155 |
+
initial_color_corrections = [processing.setup_color_correction(p.init_images[0])]
|
156 |
+
else:
|
157 |
+
original_init_image=None
|
158 |
+
|
159 |
+
all_images = []
|
160 |
+
cfgsi=" loops:"+str(loops)+" terget denoising: "+str(dns)+"\nCFG: "+cfg+"\nETA: "+eta+"\n"
|
161 |
+
|
162 |
+
p.extra_generation_params = {
|
163 |
+
"CFG Scheduler Info":cfgsi,
|
164 |
+
}
|
165 |
+
|
166 |
+
|
167 |
+
#if basic, add basic info as well
|
168 |
+
if (self.isAdvanced==False):
|
169 |
+
self.cfgsib.update(p.extra_generation_params)
|
170 |
+
p.extra_generation_params=self.cfgsib
|
171 |
+
|
172 |
+
if loops>1:
|
173 |
+
processing.fix_seed(p)
|
174 |
+
#self.initDenoise=p.denoising_strength
|
175 |
+
|
176 |
+
for n in range(batch_count):
|
177 |
+
proc=None
|
178 |
+
history = []
|
179 |
+
p.denoising_strength=initial_denoising_strength
|
180 |
+
if (original_init_image!=None):
|
181 |
+
p.init_images=original_init_image
|
182 |
+
for loop in range(loops):
|
183 |
+
if opts.img2img_color_correction and original_init_image!=None:
|
184 |
+
p.color_corrections = initial_color_corrections
|
185 |
+
|
186 |
+
p.batch_size = 1
|
187 |
+
p.n_iter = 1
|
188 |
+
self.loop=loop
|
189 |
+
self.prepare(p, cfg,eta)
|
190 |
+
proc = process_images(p)
|
191 |
+
if loop==0:
|
192 |
+
self.initInfo=proc.info
|
193 |
+
self.initSeed=proc.seed
|
194 |
+
if len(proc.images)>0:
|
195 |
+
history.append(proc.images[0])
|
196 |
+
p.seed+=1
|
197 |
+
p.init_images=[proc.images[0]]
|
198 |
+
#p.denoising_strength=min(max(p.denoising_strength * dns, 0.05), 1)
|
199 |
+
p.denoising_strength=initial_denoising_strength+(dns-initial_denoising_strength)*(loop+1)/(loops)
|
200 |
+
else:#interrupted
|
201 |
+
break
|
202 |
+
#print("New denoising:"+str(p.denoising_strength)+"\n" )
|
203 |
+
all_images += history
|
204 |
+
if loops>0:#TODO:maybe this is not needed
|
205 |
+
p.seed=self.initSeed
|
206 |
+
#return proc if (loops==1 and p.batch_size==1) else Processed(p, all_images, self.initSeed, self.initInfo)
|
207 |
+
return proc if(nSingle) else Processed(p, all_images, self.initSeed, self.initInfo)
|
208 |
+
|
209 |
+
|
210 |
+
|
211 |
+
|
212 |
+
|
213 |
+
|
214 |
+
|
215 |
+
def peek(self,val):
|
216 |
+
print(val)
|
217 |
+
return val
|
218 |
+
|
219 |
+
def split(self,src,default='0'):
|
220 |
+
p=self.p
|
221 |
+
self.P=copy.copy({
|
222 |
+
'cfg':float(str(p.cfg_scale)),
|
223 |
+
'd':p.denoising_strength or 1,
|
224 |
+
'l':self.loop,
|
225 |
+
'min':min,
|
226 |
+
'max':max,
|
227 |
+
'abs':abs,
|
228 |
+
'pow':pow,
|
229 |
+
'pi':math.pi,
|
230 |
+
'x':self._interpolate,
|
231 |
+
'int':int,
|
232 |
+
'floor':math.floor,
|
233 |
+
'peek':self.peek,
|
234 |
+
})
|
235 |
+
|
236 |
+
if src[0:4]=="eval":
|
237 |
+
src="0:"+src[4:]
|
238 |
+
if src[0]=="=":
|
239 |
+
src="0:"+src[1:]
|
240 |
+
|
241 |
+
#clean up
|
242 |
+
while src[len(src)-1] in [";"," "]:
|
243 |
+
src=src[0:len(src)-1]
|
244 |
+
while src[0] in [";"," "]:
|
245 |
+
src=src[1:]
|
246 |
+
|
247 |
+
arr0 = src.split(';')##2
|
248 |
+
|
249 |
+
#resort array accounting for commas in indecies
|
250 |
+
arr=[]
|
251 |
+
for j in arr0:
|
252 |
+
#print(j)
|
253 |
+
v=j.split(":")
|
254 |
+
q=v[0].split(",")
|
255 |
+
|
256 |
+
for i in q:
|
257 |
+
arr.append(i+":"+v[1])
|
258 |
+
|
259 |
+
|
260 |
+
|
261 |
+
|
262 |
+
arr.sort(key=self._sort)
|
263 |
+
s=[]
|
264 |
+
val=default
|
265 |
+
for j in range(p.steps+1):
|
266 |
+
i=0
|
267 |
+
while i<len(arr) and i<=j:
|
268 |
+
v=arr[i].split(":")
|
269 |
+
#s=proc[j].n_iter
|
270 |
+
if math.floor(int(v[0]) if v[0].isnumeric() else float(v[0])*p.steps)==j:
|
271 |
+
val=v[1].strip()
|
272 |
+
break
|
273 |
+
i=i+1
|
274 |
+
|
275 |
+
#lets just evaluate all
|
276 |
+
if val[0]=="=":
|
277 |
+
val=val[1:]
|
278 |
+
|
279 |
+
_eta=1-j/p.steps
|
280 |
+
params={'t':j,'T':p.steps,'math':math,'p':p,'e':float(str(_eta))}
|
281 |
+
|
282 |
+
params.update(copy.copy(self.P))
|
283 |
+
#print(params)
|
284 |
+
s.append(float(eval(val,params)))
|
285 |
+
#end while loop
|
286 |
+
#else:
|
287 |
+
#s.append(float(val))
|
288 |
+
print(np.round(s,1),"\n")
|
289 |
+
return s
|
290 |
+
#limits a range of a value
|
291 |
+
def _interpolate(self,v,start=0,end=None,m=1):
|
292 |
+
end=end or self.p.steps
|
293 |
+
v=min(max(v,start),end)-start
|
294 |
+
return v*m/(end-start)+(1 if m<0 else 0)
|
295 |
+
|
296 |
+
def _sort(self,a):
|
297 |
+
_=a.split(":")[0]#splitter tester
|
298 |
+
return math.floor(int(_) if (_.isnumeric()) else float(_)*self.p.steps)
|
299 |
+
|
300 |
+
def evaluate (self,src):
|
301 |
+
s=[]
|
302 |
+
p=self.p
|
303 |
+
T=self.p.steps
|
304 |
+
for j in range(T+1):
|
305 |
+
_eta=1-j/p.steps
|
306 |
+
params={'t':j,'T':p.steps,'math':math,'p':p,'e':_eta}
|
307 |
+
params.update(self.P)
|
308 |
+
s.append(float(eval(src,params)))
|
309 |
+
return s
|
310 |
+
|
311 |
+
class Fake_float(float):
|
312 |
+
def __new__(self, value, arr, max_mul_count, steps_per_mul):
|
313 |
+
return float.__new__(self, value)
|
314 |
+
|
315 |
+
def __init__(self, value, arr, max_mul_count, steps_per_mul):
|
316 |
+
float.__init__(value)
|
317 |
+
self.arr = arr
|
318 |
+
self.curstep = 0
|
319 |
+
#self.p=p
|
320 |
+
|
321 |
+
#self.orig_value = orig_value
|
322 |
+
#self.target_value = target_value
|
323 |
+
self.max_mul_count = max_mul_count
|
324 |
+
self.current_mul = 0
|
325 |
+
self.steps_per_mul = steps_per_mul
|
326 |
+
self.current_step = 0 #fake
|
327 |
+
self.max_step_count = (max_mul_count // steps_per_mul) + (max_mul_count % steps_per_mul > 0)
|
328 |
+
|
329 |
+
|
330 |
+
def __mul__(self,other):
|
331 |
+
return self.fake_mul(other)
|
332 |
+
|
333 |
+
def __rmul__(self,other):
|
334 |
+
return self.fake_mul(other)
|
335 |
+
|
336 |
+
#def __add__(self,other):
|
337 |
+
#print("ADD!")
|
338 |
+
# return self.get_fake_value(other)+other
|
339 |
+
#def __sub__(self,other):
|
340 |
+
#print("SUB!")
|
341 |
+
# return self.get_fake_value(other)-other
|
342 |
+
|
343 |
+
|
344 |
+
|
345 |
+
def fake_mul(self,other):
|
346 |
+
#print("MUL!")
|
347 |
+
return self.get_fake_value(other) * other
|
348 |
+
|
349 |
+
|
350 |
+
def get_fake_value(self,other):
|
351 |
+
if (self.max_step_count==1):
|
352 |
+
fake_value = self.arr[0]
|
353 |
+
else:
|
354 |
+
|
355 |
+
fake_value = self.arr[self.curstep]
|
356 |
+
self.current_mul = (self.current_mul+1) % self.max_mul_count
|
357 |
+
self.curstep = (self.current_mul) // self.steps_per_mul
|
358 |
+
self.current_step+=1#FAKE STEP
|
359 |
+
return fake_value
|
360 |
+
|
361 |
+
|
362 |
+
|
363 |
+
|
364 |
+
def fix_ddim_step_count(steps):
|
365 |
+
valid_step = 999 / (1000 // steps)
|
366 |
+
if valid_step == int(valid_step): steps=int(valid_step)+1
|
367 |
+
if ((1000 % steps)!=0): steps +=1
|
368 |
+
return steps
|
scripts/CFG Schedule.py
ADDED
@@ -0,0 +1,369 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#CFG Scheduler for Automatic1111 Stable Diffusion web-ui
|
2 |
+
#Author: https://github.com/guzuligo/
|
3 |
+
#Based on: https://github.com/tkalayci71/attenuate-cfg-scale
|
4 |
+
#Version: 1.81
|
5 |
+
|
6 |
+
from logging import PlaceHolder
|
7 |
+
import math
|
8 |
+
import os
|
9 |
+
import sys
|
10 |
+
import traceback
|
11 |
+
import copy
|
12 |
+
import numpy as np
|
13 |
+
import modules.scripts as scripts
|
14 |
+
import gradio as gr
|
15 |
+
|
16 |
+
#from modules.processing import Processed, process_images
|
17 |
+
from modules import images,processing
|
18 |
+
from modules.processing import process_images, Processed
|
19 |
+
from modules.processing import Processed
|
20 |
+
from modules.shared import opts, cmd_opts, state
|
21 |
+
class Script(scripts.Script):
|
22 |
+
#def run(self,p,n0,dns,ns1,ns2,nr1,nr2 ,loops,nSingle):
|
23 |
+
# return self.runBasic(p,n0,dns,ns1,ns2,nr1,nr2 ,loops,nSingle)
|
24 |
+
|
25 |
+
def run(self,p,cfg,eta,dns ,loops,nSingle):
|
26 |
+
return self.runAdvanced(p,cfg,eta,dns ,loops,nSingle)
|
27 |
+
|
28 |
+
def show(self, is_img2img):
|
29 |
+
self.isAdvanced=True
|
30 |
+
return True
|
31 |
+
def title(self):
|
32 |
+
return "CFG Scheduling" if (self.isAdvanced) else "CFG Auto"
|
33 |
+
|
34 |
+
def uiAdvanced(self, is_img2img):
|
35 |
+
|
36 |
+
placeholder="The steps on which to modify, in format step:value - example: 0:10 ; 10:15"
|
37 |
+
n0 = gr.Textbox(label="CFG",placeholder=placeholder)
|
38 |
+
placeholder="You can also use functions like: 0: math.fabs(-t) ; 1: (1-t/T) ; 2:=e ;3:t*d"
|
39 |
+
n1 = gr.Textbox(label="ETA",placeholder=placeholder)
|
40 |
+
#loops
|
41 |
+
#n2 = gr.Slider(minimum=1, maximum=32, step=1, label='Loops', value=1)
|
42 |
+
n2 = gr.Slider(minimum=0, maximum=1, step=0.01, label='Target Denoising : Decay per Batch', value=0.5)
|
43 |
+
with gr.Row():
|
44 |
+
loops=gr.Number(value=1,precision=0,label="loops")
|
45 |
+
nSingle= gr.Checkbox(label="Loop returns one")
|
46 |
+
|
47 |
+
return [n0,n1,n2 ,loops,nSingle]
|
48 |
+
#uiBasic
|
49 |
+
def uiAuto(self, is_img2img):
|
50 |
+
self.autoOptions={"b1":"Blur First V1","b2":"Blur Last","f1":"Force at Start V1","f2":"Force Allover"}
|
51 |
+
with gr.Row():
|
52 |
+
dns = gr.Slider(minimum=0, maximum=1, step=0.01, label='Target Denoising : Decay per Batch', value=0.25)
|
53 |
+
n0=gr.Dropdown(list(self.autoOptions.values()),value=self.autoOptions["b1"],label="Scheduler")
|
54 |
+
with gr.Row():
|
55 |
+
n1 = gr.Slider(minimum=0, maximum=100, step=1, label='Main Strength', value=10)
|
56 |
+
n2 = gr.Slider(minimum=0, maximum=100, step=1, label='Sub- Strength', value=10)
|
57 |
+
with gr.Row():
|
58 |
+
n3 = gr.Slider(minimum=0, maximum=100, step=1, label='Main Range', value=10)
|
59 |
+
n4 = gr.Slider(minimum=0, maximum=100, step=1, label='Sub- Range', value=10)
|
60 |
+
with gr.Row():
|
61 |
+
loops=gr.Number(value=1,precision=0,label="loops")
|
62 |
+
nSingle= gr.Checkbox(label="Loop returns one")
|
63 |
+
return [n0,dns, n1,n2,n3,n4 ,loops,nSingle]
|
64 |
+
|
65 |
+
def ui(self, is_img2img):
|
66 |
+
return self.uiAdvanced(is_img2img) if (self.isAdvanced) else self.uiAuto(is_img2img)
|
67 |
+
|
68 |
+
def prepare(self,p,cfg,eta):
|
69 |
+
sampler_name=p.sampler_name
|
70 |
+
if not sampler_name:
|
71 |
+
print("Warning: sampler not specified. Using Euler a")
|
72 |
+
sampler_name="Euler a"
|
73 |
+
#if p.sampler_index in (0,1,2,7,8,10,14):
|
74 |
+
if sampler_name in ('Euler a','Euler','LMS','DPM++ 2M','DPM fast','LMS Karras','DPM++ 2M Karras'):
|
75 |
+
max_mul_count = p.steps * p.batch_size
|
76 |
+
steps_per_mul = p.batch_size
|
77 |
+
#elif p.sampler_index in (3,4,5,6,11,12,13):
|
78 |
+
elif sampler_name in ('Heun','DPM2','DPM2 a','DPM++ 2S a','DPM2 Karras','DPM2 a Karras','DPM++ 2S a Karras'):
|
79 |
+
max_mul_count = ((p.steps*2)-1) * p.batch_size
|
80 |
+
steps_per_mul = 2 * p.batch_size
|
81 |
+
#elif p.sampler_index==15: # ddim
|
82 |
+
elif sampler_name=='DDIM': # ddim
|
83 |
+
max_mul_count = fix_ddim_step_count(p.steps)
|
84 |
+
steps_per_mul = 1
|
85 |
+
#elif p.sampler_index==16: # plms
|
86 |
+
elif sampler_name=='PLMS': # plms
|
87 |
+
max_mul_count = fix_ddim_step_count(p.steps)+1
|
88 |
+
steps_per_mul = 1
|
89 |
+
else:
|
90 |
+
print("Not supported sampler", p.sampler_name, p.sampler_index)
|
91 |
+
return # 9=dpm adaptive
|
92 |
+
|
93 |
+
|
94 |
+
|
95 |
+
#print("it is:",n0t)
|
96 |
+
#for x in range(int(n)):
|
97 |
+
self.p=p
|
98 |
+
cfg=cfg.strip()
|
99 |
+
eta=eta.strip()
|
100 |
+
if cfg:
|
101 |
+
p.cfg_scale=Fake_float(p.cfg_scale,self.split(cfg,str(p.cfg_scale)) , max_mul_count, steps_per_mul)
|
102 |
+
#p.cfg_scale.p=p
|
103 |
+
if eta:
|
104 |
+
if (eta.find("@")==-1):
|
105 |
+
p.s_churn=p.eta =Fake_float(p.eta or 1,self.split(eta,str(p.eta)) , max_mul_count, steps_per_mul)
|
106 |
+
#print(p.s_noise)
|
107 |
+
|
108 |
+
#Fake_float(p.s_churn or 1,self.split(eta,str(p.s_churn)), max_mul_count, steps_per_mul)
|
109 |
+
else:
|
110 |
+
eta=eta.split("@")
|
111 |
+
if eta[0].strip()!="":
|
112 |
+
p.s_churn=Fake_float(p.s_churn or 1,self.split(eta[0],str(p.s_churn)), max_mul_count, steps_per_mul)
|
113 |
+
if len(eta)>1 and eta[1].strip()!="":
|
114 |
+
p.s_noise=Fake_float(p.s_noise or 1,self.split(eta[1],str(p.s_noise)), max_mul_count, steps_per_mul)
|
115 |
+
if len(eta)>2 and eta[2].strip()!="":
|
116 |
+
p.s_tmin=Fake_float(p.s_tmin or 1,self.split(eta[2],str(p.s_tmin)), max_mul_count, steps_per_mul)
|
117 |
+
if len(eta)>3 and eta[3].strip()!="":
|
118 |
+
p.s_tmax=Fake_float(p.s_tmax or 1,self.split(eta[2],str(p.s_tmax)), max_mul_count, steps_per_mul)
|
119 |
+
|
120 |
+
|
121 |
+
#p.cfg_scale.p=p
|
122 |
+
#
|
123 |
+
|
124 |
+
|
125 |
+
|
126 |
+
def runBasic(self,p,n0,dns,ns1,ns2,nr1,nr2 ,loops,nSingle):
|
127 |
+
if(n0==self.autoOptions["b1"]):
|
128 |
+
cfg=f"""0:{ns2}/2 if (t<T* (({nr1}/100)**2)) else cfg"""
|
129 |
+
eta=f"""0:{ns1}+1 if (t<T*(({nr1}/100)**2) ) else e*({nr2}/50)"""
|
130 |
+
elif(n0==self.autoOptions["f1"]):
|
131 |
+
cfg=f"""0:({ns1}*4)*((1-d**0.5)**1.5)/(t*(30-cfg)/30+1)/(l*2+1) if (t<T*{nr1}/100) else 0.1 if (t<T*({nr1}+{nr2}-{nr1}*{nr2})/100) else 7-d*7"""
|
132 |
+
eta=f"""0:0.8+{ns2}/25-min(t*0.1, 0.8+{ns2}/25 -0.01) if (t<T*{nr1}/100) else {ns2}/(10*(1+l*0.5)) if (t<T*({nr1}+{nr2}-{nr1}*{nr2})/100) else 1+e"""
|
133 |
+
elif(n0==self.autoOptions["b2"]):
|
134 |
+
cfg=f"""0:cfg if (e>{nr1}/100 or e<(1-({nr1}+{nr2}*(100-{nr1})/100)/100)) else {ns2}/10"""
|
135 |
+
eta=f"""0:e if (e>{nr1}/100 or e<(1-({nr1}+{nr2}*(100-{nr1})/100)/100)) else {ns1}/10"""
|
136 |
+
elif(n0==self.autoOptions["f2"]):
|
137 |
+
cfg=f"""= min(40,max(0,cfg+x(t)*({ns2}-50)/2 )) """
|
138 |
+
eta=f"""0:(1-(t%(2+ 10-.1*{nr1} ))/ (2+10-.1*{nr1}) )*{ns1}*.1 * (e*(100-{nr2})+{nr2})*.01 """
|
139 |
+
self.cfgsib={"Scheduler":n0,'Main Strength':ns1,'Sub- Strength':ns2,'Main Range':nr1,'Sub- Range':nr2}
|
140 |
+
self.cfgsib={"Scheduler":n0,'Main Strength':ns1,'Sub- Strength':ns2,'Main Range':nr1,'Sub- Range':nr2}
|
141 |
+
return self.runAdvanced(p,cfg,eta,dns ,loops,nSingle)
|
142 |
+
|
143 |
+
|
144 |
+
def runAdvanced(self, p, cfg,eta,dns ,loops,nSingle):
|
145 |
+
self.initSeed=p.seed
|
146 |
+
#loops=p.batch_size
|
147 |
+
loops = loops if (loops>0) else 1
|
148 |
+
|
149 |
+
batch_count=p.n_iter
|
150 |
+
state.job_count = loops*p.n_iter
|
151 |
+
p.denoising_strength=p.denoising_strength or (1 if (self.isAdvanced) else 0.2)
|
152 |
+
initial_denoising_strength=p.denoising_strength
|
153 |
+
p.do_not_save_grid = True
|
154 |
+
if hasattr(p,"init_images"):
|
155 |
+
original_init_image = p.init_images
|
156 |
+
initial_color_corrections = [processing.setup_color_correction(p.init_images[0])]
|
157 |
+
else:
|
158 |
+
original_init_image=None
|
159 |
+
|
160 |
+
all_images = []
|
161 |
+
cfgsi=" loops:"+str(loops)+" terget denoising: "+str(dns)+"\nCFG: "+cfg+"\nETA: "+eta+"\n"
|
162 |
+
|
163 |
+
p.extra_generation_params = {
|
164 |
+
"CFG Scheduler Info":cfgsi,
|
165 |
+
}
|
166 |
+
|
167 |
+
|
168 |
+
#if basic, add basic info as well
|
169 |
+
if (self.isAdvanced==False):
|
170 |
+
self.cfgsib.update(p.extra_generation_params)
|
171 |
+
p.extra_generation_params=self.cfgsib
|
172 |
+
|
173 |
+
if loops>1:
|
174 |
+
processing.fix_seed(p)
|
175 |
+
#self.initDenoise=p.denoising_strength
|
176 |
+
|
177 |
+
for n in range(batch_count):
|
178 |
+
proc=None
|
179 |
+
history = []
|
180 |
+
p.denoising_strength=initial_denoising_strength
|
181 |
+
if (original_init_image!=None):
|
182 |
+
p.init_images=original_init_image
|
183 |
+
for loop in range(loops):
|
184 |
+
if opts.img2img_color_correction and original_init_image!=None:
|
185 |
+
p.color_corrections = initial_color_corrections
|
186 |
+
|
187 |
+
p.batch_size = 1
|
188 |
+
p.n_iter = 1
|
189 |
+
self.loop=loop
|
190 |
+
self.prepare(p, cfg,eta)
|
191 |
+
proc = process_images(p)
|
192 |
+
if loop==0:
|
193 |
+
self.initInfo=proc.info
|
194 |
+
self.initSeed=proc.seed
|
195 |
+
if len(proc.images)>0:
|
196 |
+
history.append(proc.images[0])
|
197 |
+
p.seed+=1
|
198 |
+
p.init_images=[proc.images[0]]
|
199 |
+
#p.denoising_strength=min(max(p.denoising_strength * dns, 0.05), 1)
|
200 |
+
p.denoising_strength=initial_denoising_strength+(dns-initial_denoising_strength)*(loop+1)/(loops)
|
201 |
+
else:#interrupted
|
202 |
+
break
|
203 |
+
#print("New denoising:"+str(p.denoising_strength)+"\n" )
|
204 |
+
all_images += history
|
205 |
+
if loops>0:#TODO:maybe this is not needed
|
206 |
+
p.seed=self.initSeed
|
207 |
+
#return proc if (loops==1 and p.batch_size==1) else Processed(p, all_images, self.initSeed, self.initInfo)
|
208 |
+
return proc if(nSingle) else Processed(p, all_images, self.initSeed, self.initInfo)
|
209 |
+
|
210 |
+
|
211 |
+
|
212 |
+
|
213 |
+
|
214 |
+
|
215 |
+
|
216 |
+
def peek(self,val):
|
217 |
+
print(val)
|
218 |
+
return val
|
219 |
+
|
220 |
+
def split(self,src,default='0'):
|
221 |
+
p=self.p
|
222 |
+
self.P=copy.copy({
|
223 |
+
'cfg':float(str(p.cfg_scale)),
|
224 |
+
'd':p.denoising_strength or 1,
|
225 |
+
'l':self.loop,
|
226 |
+
'min':min,
|
227 |
+
'max':max,
|
228 |
+
'abs':abs,
|
229 |
+
'pow':pow,
|
230 |
+
'pi':math.pi,
|
231 |
+
'x':self._interpolate,
|
232 |
+
'int':int,
|
233 |
+
'floor':math.floor,
|
234 |
+
'peek':self.peek,
|
235 |
+
})
|
236 |
+
|
237 |
+
if src[0:4]=="eval":
|
238 |
+
src="0:"+src[4:]
|
239 |
+
if src[0]=="=":
|
240 |
+
src="0:"+src[1:]
|
241 |
+
|
242 |
+
#clean up
|
243 |
+
while src[len(src)-1] in [";"," "]:
|
244 |
+
src=src[0:len(src)-1]
|
245 |
+
while src[0] in [";"," "]:
|
246 |
+
src=src[1:]
|
247 |
+
|
248 |
+
arr0 = src.split(';')##2
|
249 |
+
|
250 |
+
#resort array accounting for commas in indecies
|
251 |
+
arr=[]
|
252 |
+
for j in arr0:
|
253 |
+
#print(j)
|
254 |
+
v=j.split(":")
|
255 |
+
q=v[0].split(",")
|
256 |
+
|
257 |
+
for i in q:
|
258 |
+
arr.append(i+":"+v[1])
|
259 |
+
|
260 |
+
|
261 |
+
|
262 |
+
|
263 |
+
arr.sort(key=self._sort)
|
264 |
+
s=[]
|
265 |
+
val=default
|
266 |
+
for j in range(p.steps+1):
|
267 |
+
i=0
|
268 |
+
while i<len(arr) and i<=j:
|
269 |
+
v=arr[i].split(":")
|
270 |
+
#s=proc[j].n_iter
|
271 |
+
if math.floor(int(v[0]) if v[0].isnumeric() else float(v[0])*p.steps)==j:
|
272 |
+
val=v[1].strip()
|
273 |
+
break
|
274 |
+
i=i+1
|
275 |
+
|
276 |
+
#lets just evaluate all
|
277 |
+
if val[0]=="=":
|
278 |
+
val=val[1:]
|
279 |
+
|
280 |
+
_eta=1-j/p.steps
|
281 |
+
params={'t':j,'T':p.steps,'math':math,'p':p,'e':float(str(_eta))}
|
282 |
+
|
283 |
+
params.update(copy.copy(self.P))
|
284 |
+
#print(params)
|
285 |
+
s.append(float(eval(val,params)))
|
286 |
+
#end while loop
|
287 |
+
#else:
|
288 |
+
#s.append(float(val))
|
289 |
+
print(np.round(s,1),"\n")
|
290 |
+
return s
|
291 |
+
#limits a range of a value
|
292 |
+
def _interpolate(self,v,start=0,end=None,m=1):
|
293 |
+
end=end or self.p.steps
|
294 |
+
v=min(max(v,start),end)-start
|
295 |
+
return v*m/(end-start)+(1 if m<0 else 0)
|
296 |
+
|
297 |
+
def _sort(self,a):
|
298 |
+
_=a.split(":")[0]#splitter tester
|
299 |
+
return math.floor(int(_) if (_.isnumeric()) else float(_)*self.p.steps)
|
300 |
+
|
301 |
+
def evaluate (self,src):
|
302 |
+
s=[]
|
303 |
+
p=self.p
|
304 |
+
T=self.p.steps
|
305 |
+
for j in range(T+1):
|
306 |
+
_eta=1-j/p.steps
|
307 |
+
params={'t':j,'T':p.steps,'math':math,'p':p,'e':_eta}
|
308 |
+
params.update(self.P)
|
309 |
+
s.append(float(eval(src,params)))
|
310 |
+
return s
|
311 |
+
|
312 |
+
class Fake_float(float):
|
313 |
+
def __new__(self, value, arr, max_mul_count, steps_per_mul):
|
314 |
+
return float.__new__(self, value)
|
315 |
+
|
316 |
+
def __init__(self, value, arr, max_mul_count, steps_per_mul):
|
317 |
+
float.__init__(value)
|
318 |
+
self.arr = arr
|
319 |
+
self.curstep = 0
|
320 |
+
#self.p=p
|
321 |
+
|
322 |
+
#self.orig_value = orig_value
|
323 |
+
#self.target_value = target_value
|
324 |
+
self.max_mul_count = max_mul_count
|
325 |
+
self.current_mul = 0
|
326 |
+
self.steps_per_mul = steps_per_mul
|
327 |
+
self.current_step = 0 #fake
|
328 |
+
self.max_step_count = (max_mul_count // steps_per_mul) + (max_mul_count % steps_per_mul > 0)
|
329 |
+
|
330 |
+
|
331 |
+
def __mul__(self,other):
|
332 |
+
return self.fake_mul(other)
|
333 |
+
|
334 |
+
def __rmul__(self,other):
|
335 |
+
return self.fake_mul(other)
|
336 |
+
|
337 |
+
#def __add__(self,other):
|
338 |
+
#print("ADD!")
|
339 |
+
# return self.get_fake_value(other)+other
|
340 |
+
#def __sub__(self,other):
|
341 |
+
#print("SUB!")
|
342 |
+
# return self.get_fake_value(other)-other
|
343 |
+
|
344 |
+
|
345 |
+
|
346 |
+
def fake_mul(self,other):
|
347 |
+
#print("MUL!")
|
348 |
+
return self.get_fake_value(other) * other
|
349 |
+
|
350 |
+
|
351 |
+
def get_fake_value(self,other):
|
352 |
+
if (self.max_step_count==1):
|
353 |
+
fake_value = self.arr[0]
|
354 |
+
else:
|
355 |
+
|
356 |
+
fake_value = self.arr[self.curstep]
|
357 |
+
self.current_mul = (self.current_mul+1) % self.max_mul_count
|
358 |
+
self.curstep = (self.current_mul) // self.steps_per_mul
|
359 |
+
self.current_step+=1#FAKE STEP
|
360 |
+
return fake_value
|
361 |
+
|
362 |
+
|
363 |
+
|
364 |
+
|
365 |
+
def fix_ddim_step_count(steps):
|
366 |
+
valid_step = 999 / (1000 // steps)
|
367 |
+
if valid_step == int(valid_step): steps=int(valid_step)+1
|
368 |
+
if ((1000 % steps)!=0): steps +=1
|
369 |
+
return steps
|
scripts/ContorlNet_I2I_sequence_toyxyz_V2.py
ADDED
@@ -0,0 +1,367 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import copy
|
2 |
+
import os
|
3 |
+
import shutil
|
4 |
+
|
5 |
+
import cv2
|
6 |
+
import gradio as gr
|
7 |
+
import numpy as np
|
8 |
+
import modules.scripts as scripts
|
9 |
+
|
10 |
+
from modules import images, processing
|
11 |
+
from modules.processing import process_images, Processed
|
12 |
+
from modules.shared import opts
|
13 |
+
from PIL import Image, ImageFilter, ImageColor, ImageOps
|
14 |
+
from pathlib import Path
|
15 |
+
from typing import List, Tuple, Iterable
|
16 |
+
|
17 |
+
|
18 |
+
#Returns a list of images located in the input path. For ControlNet iamges
|
19 |
+
def get_all_frames_from_path(path):
|
20 |
+
if not os.path.isdir(path):
|
21 |
+
return None
|
22 |
+
frame_list = []
|
23 |
+
for filename in sorted(os.listdir(path)):
|
24 |
+
if filename.endswith(".jpg") or filename.endswith(".png"):
|
25 |
+
img_path = os.path.join(path, filename)
|
26 |
+
img = cv2.imread(img_path)
|
27 |
+
if img is not None:
|
28 |
+
frame_list.append(img)
|
29 |
+
frame_list.insert(0, frame_list[0])
|
30 |
+
return frame_list
|
31 |
+
|
32 |
+
|
33 |
+
#Returns a list of images located in the input path. For Color iamges
|
34 |
+
def get_images_from_path(path):
|
35 |
+
if not os.path.isdir(path):
|
36 |
+
return None
|
37 |
+
images = []
|
38 |
+
for filename in os.listdir(path):
|
39 |
+
if filename.endswith('.jpg') or filename.endswith('.png'):
|
40 |
+
img_path = os.path.join(path, filename)
|
41 |
+
img = Image.open(img_path)
|
42 |
+
images.append(img)
|
43 |
+
images.append(images[-1])
|
44 |
+
images.insert(0, images[0])
|
45 |
+
return images
|
46 |
+
|
47 |
+
#Returns the number of the smallest number in the entire image sequence list. For ControlNet
|
48 |
+
def get_min_frame_num(video_list):
|
49 |
+
min_frame_num = -1
|
50 |
+
for video in video_list:
|
51 |
+
if video is None:
|
52 |
+
continue
|
53 |
+
else:
|
54 |
+
frame_num = len(video)
|
55 |
+
print(frame_num)
|
56 |
+
if min_frame_num < 0:
|
57 |
+
min_frame_num = frame_num
|
58 |
+
elif frame_num < min_frame_num:
|
59 |
+
min_frame_num = frame_num
|
60 |
+
return min_frame_num
|
61 |
+
|
62 |
+
|
63 |
+
#Blende method
|
64 |
+
|
65 |
+
|
66 |
+
def basic(target, blend, opacity):
|
67 |
+
return target * opacity + blend * (1-opacity)
|
68 |
+
|
69 |
+
def blender(func):
|
70 |
+
def blend(target, blend, opacity=1, *args):
|
71 |
+
res = func(target, blend, *args)
|
72 |
+
res = basic(res, blend, opacity)
|
73 |
+
return np.clip(res, 0, 1)
|
74 |
+
return blend
|
75 |
+
|
76 |
+
|
77 |
+
class Blend:
|
78 |
+
@classmethod
|
79 |
+
def method(cls, name):
|
80 |
+
return getattr(cls, name)
|
81 |
+
|
82 |
+
normal = basic
|
83 |
+
|
84 |
+
@staticmethod
|
85 |
+
@blender
|
86 |
+
def darken(target, blend, *args):
|
87 |
+
return np.minimum(target, blend)
|
88 |
+
|
89 |
+
@staticmethod
|
90 |
+
@blender
|
91 |
+
def multiply(target, blend, *args):
|
92 |
+
return target * blend
|
93 |
+
|
94 |
+
@staticmethod
|
95 |
+
@blender
|
96 |
+
def color_burn(target, blend, *args):
|
97 |
+
return 1 - (1-target)/blend
|
98 |
+
|
99 |
+
@staticmethod
|
100 |
+
@blender
|
101 |
+
def linear_burn(target, blend, *args):
|
102 |
+
return target+blend-1
|
103 |
+
|
104 |
+
@staticmethod
|
105 |
+
@blender
|
106 |
+
def lighten(target, blend, *args):
|
107 |
+
return np.maximum(target, blend)
|
108 |
+
|
109 |
+
@staticmethod
|
110 |
+
@blender
|
111 |
+
def screen(target, blend, *args):
|
112 |
+
return 1 - (1-target) * (1-blend)
|
113 |
+
|
114 |
+
@staticmethod
|
115 |
+
@blender
|
116 |
+
def color_dodge(target, blend, *args):
|
117 |
+
return target/(1-blend)
|
118 |
+
|
119 |
+
@staticmethod
|
120 |
+
@blender
|
121 |
+
def linear_dodge(target, blend, *args):
|
122 |
+
return target+blend
|
123 |
+
|
124 |
+
@staticmethod
|
125 |
+
@blender
|
126 |
+
def overlay(target, blend, *args):
|
127 |
+
return (target>0.5) * (1-(2-2*target)*(1-blend)) +\
|
128 |
+
(target<=0.5) * (2*target*blend)
|
129 |
+
|
130 |
+
@staticmethod
|
131 |
+
@blender
|
132 |
+
def soft_light(target, blend, *args):
|
133 |
+
return (blend>0.5) * (1 - (1-target)*(1-(blend-0.5))) +\
|
134 |
+
(blend<=0.5) * (target*(blend+0.5))
|
135 |
+
|
136 |
+
@staticmethod
|
137 |
+
@blender
|
138 |
+
def hard_light(target, blend, *args):
|
139 |
+
return (blend>0.5) * (1 - (1-target)*(2-2*blend)) +\
|
140 |
+
(blend<=0.5) * (2*target*blend)
|
141 |
+
|
142 |
+
@staticmethod
|
143 |
+
@blender
|
144 |
+
def vivid_light(target, blend, *args):
|
145 |
+
return (blend>0.5) * (1 - (1-target)/(2*blend-1)) +\
|
146 |
+
(blend<=0.5) * (target/(1-2*blend))
|
147 |
+
|
148 |
+
@staticmethod
|
149 |
+
@blender
|
150 |
+
def linear_light(target, blend, *args):
|
151 |
+
return (blend>0.5) * (target + 2*(blend-0.5)) +\
|
152 |
+
(blend<=0.5) * (target + 2*blend)
|
153 |
+
|
154 |
+
@staticmethod
|
155 |
+
@blender
|
156 |
+
def pin_light(target, blend, *args):
|
157 |
+
return (blend>0.5) * np.maximum(target,2*(blend-0.5)) +\
|
158 |
+
(blend<=0.5) * np.minimum(target,2*blend)
|
159 |
+
|
160 |
+
@staticmethod
|
161 |
+
@blender
|
162 |
+
def difference(target, blend, *args):
|
163 |
+
return np.abs(target - blend)
|
164 |
+
|
165 |
+
@staticmethod
|
166 |
+
@blender
|
167 |
+
def exclusion(target, blend, *args):
|
168 |
+
return 0.5 - 2*(target-0.5)*(blend-0.5)
|
169 |
+
|
170 |
+
blend_methods = [i for i in Blend.__dict__.keys() if i[0]!='_' and i!='method']
|
171 |
+
|
172 |
+
|
173 |
+
|
174 |
+
def blend_images(base_img, blend_img, blend_method, blend_opacity, do_invert):
|
175 |
+
|
176 |
+
img_base = np.array(base_img.convert("RGB")).astype(np.float64)/255
|
177 |
+
|
178 |
+
if do_invert:
|
179 |
+
img_to_blend = ImageOps.invert(blend_img.convert('RGB'))
|
180 |
+
else:
|
181 |
+
img_to_blend = blend_img
|
182 |
+
|
183 |
+
img_to_blend = img_to_blend.resize((int(base_img.width), int(base_img.height)))
|
184 |
+
|
185 |
+
img_to_blend = np.array(img_to_blend.convert("RGB")).astype(np.float64)/255
|
186 |
+
|
187 |
+
img_blended = Blend.method(blend_method)(img_to_blend, img_base, blend_opacity)
|
188 |
+
|
189 |
+
img_blended *= 255
|
190 |
+
|
191 |
+
img_blended = Image.fromarray(img_blended.astype(np.uint8), mode='RGB')
|
192 |
+
|
193 |
+
return img_blended
|
194 |
+
|
195 |
+
|
196 |
+
#Define UI and script properties.
|
197 |
+
class Script(scripts.Script):
|
198 |
+
|
199 |
+
def title(self):
|
200 |
+
return "controlnet I2I sequence_toyxyz_v2"
|
201 |
+
|
202 |
+
def show(self, is_img2img):
|
203 |
+
return is_img2img
|
204 |
+
|
205 |
+
def ui(self, is_img2img):
|
206 |
+
|
207 |
+
ctrls_group = ()
|
208 |
+
max_models = opts.data.get("control_net_max_models_num", 1)
|
209 |
+
|
210 |
+
input_list = []
|
211 |
+
|
212 |
+
with gr.Group():
|
213 |
+
with gr.Accordion("ControlNet-I2I-sequence-toyxyz", open = True):
|
214 |
+
with gr.Column():
|
215 |
+
|
216 |
+
feed_prev_frame = gr.Checkbox(value=False, label="Feed previous frame / Reduce flickering by feeding the previous frame image generated by Img2Img")
|
217 |
+
|
218 |
+
use_init_img = gr.Checkbox(value=False, label="Blend color image / Blend the color image sequence with the initial Img2Img image or previous frame")
|
219 |
+
|
220 |
+
use_TemporalNet = gr.Checkbox(value=False, label="Use TemporalNet / Using TemporalNet to reduce flicker between image sequences. Add TemporalNet in addition to the multi-controlnet you need. It should be placed at the end of the controlnet list.")
|
221 |
+
|
222 |
+
blendmode = gr.Dropdown(blend_methods, value='normal', label='Blend mode / Choose how to blend the color image with the Previous frame or Img2Img initial image')
|
223 |
+
|
224 |
+
opacityvalue = gr.Slider(0, 1, value=0, label="Opacity / Previous frame or Img2Img initial image + (color image * opacity)", info="Choose betwen 0 and 1")
|
225 |
+
|
226 |
+
|
227 |
+
for i in range(max_models):
|
228 |
+
input_path = gr.Textbox(label=f"ControlNet-{i}", placeholder="image sequence path")
|
229 |
+
input_list.append(input_path)
|
230 |
+
|
231 |
+
tone_image_path = gr.Textbox(label=f"Color_Image / Color images to be used for Img2Img in sequence", placeholder="image sequence path")
|
232 |
+
|
233 |
+
output_path = gr.Textbox(label=f"Output_path / Deletes the contents located in the path, and creates a new path if it does not exist", placeholder="Output path")
|
234 |
+
|
235 |
+
ctrls_group += tuple(input_list) + (use_TemporalNet, use_init_img, opacityvalue, blendmode, feed_prev_frame, tone_image_path, output_path)
|
236 |
+
|
237 |
+
return ctrls_group
|
238 |
+
|
239 |
+
|
240 |
+
|
241 |
+
#Image Generate Definition
|
242 |
+
def run(self, p, *args):
|
243 |
+
|
244 |
+
path = p.outpath_samples
|
245 |
+
|
246 |
+
output_path = args[-1] # get the last argument, which is the output path
|
247 |
+
|
248 |
+
feedprev = args[-3]
|
249 |
+
|
250 |
+
blendm = args[-4]
|
251 |
+
|
252 |
+
opacityval = args[-5]
|
253 |
+
|
254 |
+
useinit = args[-6]
|
255 |
+
|
256 |
+
usetempo = args[-7]
|
257 |
+
|
258 |
+
|
259 |
+
# Check whether the output path exists, if it does, delete it and create a new one.
|
260 |
+
if os.path.isdir(output_path):
|
261 |
+
for file in os.scandir(output_path):
|
262 |
+
os.remove(file.path)
|
263 |
+
else :
|
264 |
+
os.mkdir(output_path)
|
265 |
+
|
266 |
+
#Get the number of controlnet models.
|
267 |
+
video_num = opts.data.get("control_net_max_models_num", 1)
|
268 |
+
|
269 |
+
# Get the ControlNet image sequence list.
|
270 |
+
image_list = [get_all_frames_from_path(image) for image in args[:video_num]]
|
271 |
+
|
272 |
+
# Get a list of color image sequences.
|
273 |
+
color_image_list = get_images_from_path(args[-2])
|
274 |
+
|
275 |
+
# Get the first frame
|
276 |
+
previmg = p.init_images
|
277 |
+
|
278 |
+
tempoimg = p.init_images[0]
|
279 |
+
|
280 |
+
#If img2img color correction is enabled in webui settings, color correction is performed based on the first frame.
|
281 |
+
initial_color_corrections = [processing.setup_color_correction(p.init_images[0])]
|
282 |
+
|
283 |
+
#Save initial img2img image
|
284 |
+
initial_image = p.init_images[0]
|
285 |
+
|
286 |
+
# Get the total number of frames.
|
287 |
+
frame_num = get_min_frame_num(image_list)
|
288 |
+
|
289 |
+
# image processing
|
290 |
+
if frame_num > 0:
|
291 |
+
output_image_list = []
|
292 |
+
|
293 |
+
for frame in range(frame_num):
|
294 |
+
copy_p = copy.copy(p)
|
295 |
+
copy_p.control_net_input_image = []
|
296 |
+
for video in image_list:
|
297 |
+
if video is None:
|
298 |
+
continue
|
299 |
+
copy_p.control_net_input_image.append(video[frame])
|
300 |
+
|
301 |
+
if usetempo == True :
|
302 |
+
copy_p.control_net_input_image.append(tempoimg)
|
303 |
+
|
304 |
+
|
305 |
+
if color_image_list and feedprev == False:
|
306 |
+
|
307 |
+
if frame<len(color_image_list):
|
308 |
+
tone_image = color_image_list[frame+1]
|
309 |
+
|
310 |
+
if useinit:
|
311 |
+
tone_image = blend_images(initial_image, tone_image, blendm, opacityval, False)
|
312 |
+
|
313 |
+
p.init_images = [tone_image.convert("RGB")]
|
314 |
+
|
315 |
+
proc = process_images(copy_p)
|
316 |
+
|
317 |
+
|
318 |
+
|
319 |
+
if feedprev == True and useinit == False:
|
320 |
+
if previmg is None:
|
321 |
+
continue
|
322 |
+
else:
|
323 |
+
previmg = proc.images[0]
|
324 |
+
|
325 |
+
if frame == 0:
|
326 |
+
previmg = initial_image
|
327 |
+
|
328 |
+
p.init_images = [previmg]
|
329 |
+
|
330 |
+
if opts.img2img_color_correction:
|
331 |
+
p.color_corrections = initial_color_corrections
|
332 |
+
|
333 |
+
|
334 |
+
if feedprev == True and color_image_list and useinit:
|
335 |
+
if previmg is None:
|
336 |
+
continue
|
337 |
+
else:
|
338 |
+
previmg = proc.images[0]
|
339 |
+
|
340 |
+
if frame == 0:
|
341 |
+
previmg = initial_image
|
342 |
+
|
343 |
+
previmg = blend_images(previmg, color_image_list[frame+1], blendm, opacityval, False)
|
344 |
+
|
345 |
+
|
346 |
+
p.init_images = [previmg]
|
347 |
+
|
348 |
+
if opts.img2img_color_correction:
|
349 |
+
p.color_corrections = initial_color_corrections
|
350 |
+
|
351 |
+
img = proc.images[0]
|
352 |
+
|
353 |
+
if usetempo == True :
|
354 |
+
if frame > 0 :
|
355 |
+
tempoimg = proc.images[0]
|
356 |
+
|
357 |
+
|
358 |
+
#Save image
|
359 |
+
if(frame>0):
|
360 |
+
images.save_image(img, output_path, f"Frame_{frame}")
|
361 |
+
copy_p.close()
|
362 |
+
|
363 |
+
|
364 |
+
else:
|
365 |
+
proc = process_images(p)
|
366 |
+
|
367 |
+
return proc
|
scripts/LoopbackWave.py
ADDED
@@ -0,0 +1,348 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
import platform
|
3 |
+
import numpy as np
|
4 |
+
from tqdm import trange
|
5 |
+
import math
|
6 |
+
import subprocess as sp
|
7 |
+
import string
|
8 |
+
import random
|
9 |
+
from functools import reduce
|
10 |
+
import re
|
11 |
+
|
12 |
+
import modules.scripts as scripts
|
13 |
+
import gradio as gr
|
14 |
+
|
15 |
+
from datetime import datetime
|
16 |
+
from modules import processing, shared, sd_samplers, images
|
17 |
+
from modules.processing import Processed
|
18 |
+
from modules.sd_samplers import samplers
|
19 |
+
from modules.shared import opts, cmd_opts, state
|
20 |
+
import subprocess
|
21 |
+
|
22 |
+
|
23 |
+
wave_completed_regex = r'@wave_completed\(([\-]?[0-9]*\.?[0-9]+), ?([\-]?[0-9]*\.?[0-9]+)\)'
|
24 |
+
wave_remaining_regex = r'@wave_remaining\(([\-]?[0-9]*\.?[0-9]+), ?([\-]?[0-9]*\.?[0-9]+)\)'
|
25 |
+
|
26 |
+
def run_cmd(cmd):
|
27 |
+
cmd = list(map(lambda arg: str(arg), cmd))
|
28 |
+
print("Executing %s" % " ".join(cmd))
|
29 |
+
popen_params = {"stdout": sp.DEVNULL, "stderr": sp.PIPE, "stdin": sp.DEVNULL}
|
30 |
+
|
31 |
+
if os.name == "nt":
|
32 |
+
popen_params["creationflags"] = 0x08000000
|
33 |
+
|
34 |
+
proc = sp.Popen(cmd, **popen_params)
|
35 |
+
out, err = proc.communicate() # proc.wait()
|
36 |
+
proc.stderr.close()
|
37 |
+
|
38 |
+
if proc.returncode:
|
39 |
+
raise IOError(err.decode("utf8"))
|
40 |
+
|
41 |
+
del proc
|
42 |
+
|
43 |
+
def encode_video(input_pattern, starting_number, output_dir, fps, quality, encoding, create_segments, segment_duration, ffmpeg_path):
|
44 |
+
two_pass = (encoding == "VP9 (webm)")
|
45 |
+
alpha_channel = ("webm" in encoding)
|
46 |
+
suffix = "webm" if "webm" in encoding else "mp4"
|
47 |
+
output_location = output_dir + f".{suffix}"
|
48 |
+
|
49 |
+
encoding_lib = {
|
50 |
+
"VP9 (webm)": "libvpx-vp9",
|
51 |
+
"VP8 (webm)": "libvpx",
|
52 |
+
"H.264 (mp4)": "libx264",
|
53 |
+
"H.265 (mp4)": "libx265",
|
54 |
+
}[encoding]
|
55 |
+
|
56 |
+
args = [
|
57 |
+
"-framerate", fps,
|
58 |
+
"-start_number", int(starting_number),
|
59 |
+
"-i", input_pattern,
|
60 |
+
"-c:v", encoding_lib,
|
61 |
+
"-b:v","0",
|
62 |
+
"-crf", quality,
|
63 |
+
]
|
64 |
+
|
65 |
+
if encoding_lib == "libvpx-vp9":
|
66 |
+
args += ["-pix_fmt", "yuva420p"]
|
67 |
+
|
68 |
+
if(ffmpeg_path == ""):
|
69 |
+
ffmpeg_path = "ffmpeg"
|
70 |
+
if(platform.system == "Windows"):
|
71 |
+
ffmpeg_path += ".exe"
|
72 |
+
|
73 |
+
print("\n\n")
|
74 |
+
if two_pass:
|
75 |
+
first_pass_args = args + [
|
76 |
+
"-pass", "1",
|
77 |
+
"-an",
|
78 |
+
"-f", "null",
|
79 |
+
os.devnull
|
80 |
+
]
|
81 |
+
|
82 |
+
second_pass_args = args + [
|
83 |
+
"-pass", "2",
|
84 |
+
output_location
|
85 |
+
]
|
86 |
+
|
87 |
+
print("Running first pass ffmpeg encoding")
|
88 |
+
|
89 |
+
run_cmd([ffmpeg_path] + first_pass_args)
|
90 |
+
print("Running second pass ffmpeg encoding. This could take awhile...")
|
91 |
+
run_cmd([ffmpeg_path] + second_pass_args)
|
92 |
+
else:
|
93 |
+
print("Running ffmpeg encoding. This could take awhile...")
|
94 |
+
run_cmd([ffmpeg_path] + args + [output_location])
|
95 |
+
|
96 |
+
if(create_segments):
|
97 |
+
print("Segmenting video")
|
98 |
+
run_cmd([ffmpeg_path] + [
|
99 |
+
"-i", output_location,
|
100 |
+
"-f", "segment",
|
101 |
+
"-segment_time", segment_duration,
|
102 |
+
"-vcodec", "copy",
|
103 |
+
"-acodec", "copy",
|
104 |
+
f"{output_dir}.%d.{suffix}"
|
105 |
+
])
|
106 |
+
|
107 |
+
def set_weights(match_obj, wave_progress):
|
108 |
+
weight_0 = 0
|
109 |
+
weight_1 = 0
|
110 |
+
if match_obj.group(1) is not None:
|
111 |
+
weight_0 = float(match_obj.group(1))
|
112 |
+
if match_obj.group(2) is not None:
|
113 |
+
weight_1 = float(match_obj.group(2))
|
114 |
+
|
115 |
+
max_weight = max(weight_0, weight_1)
|
116 |
+
min_weight = min(weight_0, weight_1)
|
117 |
+
|
118 |
+
weight_range = max_weight - min_weight
|
119 |
+
weight = min_weight + weight_range * wave_progress
|
120 |
+
return str(weight)
|
121 |
+
|
122 |
+
|
123 |
+
class Script(scripts.Script):
|
124 |
+
def title(self):
|
125 |
+
return "Loopback Wave V1.4.1"
|
126 |
+
|
127 |
+
def show(self, is_img2img):
|
128 |
+
return is_img2img
|
129 |
+
|
130 |
+
def ui(self, is_img2img):
|
131 |
+
frames = gr.Slider(minimum=1, maximum=2048, step=1, label='Frames', value=100)
|
132 |
+
frames_per_wave = gr.Slider(minimum=0, maximum=120, step=1, label='Frames Per Wave', value=20)
|
133 |
+
denoising_strength_change_amplitude = gr.Slider(minimum=0, maximum=1, step=0.01, label='Max additional denoise', value=0.6)
|
134 |
+
denoising_strength_change_offset = gr.Number(minimum=0, maximum=180, step=1, label='Wave offset (ignore this if you don\'t know what it means)', value=0)
|
135 |
+
initial_image_number = gr.Number(minimum=0, label='Initial generated image number', value=0)
|
136 |
+
|
137 |
+
save_prompts = gr.Checkbox(label='Save prompts as text file', value=True)
|
138 |
+
prompts = gr.Textbox(label="Prompt Changes", lines=5, value="")
|
139 |
+
|
140 |
+
save_video = gr.Checkbox(label='Save results as video', value=True)
|
141 |
+
output_dir = gr.Textbox(label="Video Name", lines=1, value="")
|
142 |
+
video_fps = gr.Slider(minimum=1, maximum=120, step=1, label='Frames per second', value=10)
|
143 |
+
video_quality = gr.Slider(minimum=0, maximum=60, step=1, label='Video Quality (crf)', value=40)
|
144 |
+
video_encoding = gr.Dropdown(label='Video encoding', value="VP9 (webm)", choices=["VP9 (webm)", "VP8 (webm)", "H.265 (mp4)", "H.264 (mp4)"])
|
145 |
+
ffmpeg_path = gr.Textbox(label="ffmpeg binary. Only set this if it fails otherwise.", lines=1, value="")
|
146 |
+
|
147 |
+
segment_video = gr.Checkbox(label='Cut video in to segments', value=True)
|
148 |
+
video_segment_duration = gr.Slider(minimum=10, maximum=60, step=1, label='Video Segment Duration (seconds)', value=20)
|
149 |
+
|
150 |
+
|
151 |
+
return [frames, denoising_strength_change_amplitude, frames_per_wave, denoising_strength_change_offset,initial_image_number, prompts, save_prompts, save_video, output_dir, video_fps, video_quality, video_encoding, ffmpeg_path, segment_video, video_segment_duration]
|
152 |
+
|
153 |
+
def run(self, p, frames, denoising_strength_change_amplitude, frames_per_wave, denoising_strength_change_offset, initial_image_number, prompts: str,save_prompts, save_video, output_dir, video_fps, video_quality, video_encoding, ffmpeg_path, segment_video, video_segment_duration):
|
154 |
+
processing.fix_seed(p)
|
155 |
+
batch_count = p.n_iter
|
156 |
+
p.extra_generation_params = {
|
157 |
+
"Max Additional Denoise": denoising_strength_change_amplitude,
|
158 |
+
"Frames per wave": frames_per_wave,
|
159 |
+
"Wave Offset": denoising_strength_change_offset,
|
160 |
+
}
|
161 |
+
|
162 |
+
# We save them ourselves for the sake of ffmpeg
|
163 |
+
p.do_not_save_samples = True
|
164 |
+
|
165 |
+
changes_dict = {}
|
166 |
+
|
167 |
+
|
168 |
+
p.batch_size = 1
|
169 |
+
p.n_iter = 1
|
170 |
+
|
171 |
+
output_images, info = None, None
|
172 |
+
initial_seed = None
|
173 |
+
initial_info = None
|
174 |
+
|
175 |
+
grids = []
|
176 |
+
all_images = []
|
177 |
+
original_init_image = p.init_images
|
178 |
+
state.job_count = frames * batch_count
|
179 |
+
|
180 |
+
initial_color_corrections = [processing.setup_color_correction(p.init_images[0])]
|
181 |
+
initial_denoising_strength = p.denoising_strength
|
182 |
+
|
183 |
+
if(output_dir==""):
|
184 |
+
output_dir = str(p.seed)
|
185 |
+
else:
|
186 |
+
output_dir = output_dir + "-" + str(p.seed)
|
187 |
+
|
188 |
+
loopback_wave_path = os.path.join(p.outpath_samples, "loopback-wave")
|
189 |
+
loopback_wave_images_path = os.path.join(loopback_wave_path, output_dir)
|
190 |
+
|
191 |
+
os.makedirs(loopback_wave_images_path, exist_ok=True)
|
192 |
+
|
193 |
+
p.outpath_samples = loopback_wave_images_path
|
194 |
+
|
195 |
+
prompts = prompts.strip()
|
196 |
+
|
197 |
+
if save_prompts:
|
198 |
+
with open(loopback_wave_images_path + "-prompts.txt", "w") as f:
|
199 |
+
generation_settings = [
|
200 |
+
"Generation Settings",
|
201 |
+
f"Total Frames: {frames}",
|
202 |
+
f"Frames Per Wave: {frames_per_wave}",
|
203 |
+
f"Wave Offset: {denoising_strength_change_offset}",
|
204 |
+
f"Base Denoising Strength: {initial_denoising_strength}",
|
205 |
+
f"Max Additional Denoise: {denoising_strength_change_amplitude}",
|
206 |
+
f"Initial Image Number: {initial_image_number}",
|
207 |
+
"",
|
208 |
+
"Video Encoding Settings",
|
209 |
+
f"Save Video: {save_video}"
|
210 |
+
]
|
211 |
+
|
212 |
+
if save_video:
|
213 |
+
generation_settings = generation_settings + [
|
214 |
+
f"Framerate: {video_fps}",
|
215 |
+
f"Quality: {video_quality}",
|
216 |
+
f"Encoding: {video_encoding}",
|
217 |
+
f"Create Segmented Video: {segment_video}"
|
218 |
+
]
|
219 |
+
|
220 |
+
if segment_video:
|
221 |
+
generation_settings = generation_settings + [f"Segment Duration: {video_segment_duration}"]
|
222 |
+
|
223 |
+
generation_settings = generation_settings + [
|
224 |
+
"",
|
225 |
+
"Prompt Details",
|
226 |
+
"Initial Prompt:" + p.prompt,
|
227 |
+
"",
|
228 |
+
"Negative Prompt:" + p.negative_prompt,
|
229 |
+
"",
|
230 |
+
"Frame change prompts:",
|
231 |
+
prompts
|
232 |
+
]
|
233 |
+
|
234 |
+
|
235 |
+
|
236 |
+
f.write('\n'.join(generation_settings))
|
237 |
+
|
238 |
+
if prompts:
|
239 |
+
lines = prompts.split("\n")
|
240 |
+
for prompt_line in lines:
|
241 |
+
params = prompt_line.split("::")
|
242 |
+
if len(params) == 2:
|
243 |
+
changes_dict[params[0]] = { "prompt": params[1] }
|
244 |
+
elif len(params) == 3:
|
245 |
+
changes_dict[params[0]] = { "seed": params[1], "prompt": params[2] }
|
246 |
+
else:
|
247 |
+
raise IOError(f"Invalid input in prompt line: {prompt_line}")
|
248 |
+
|
249 |
+
raw_prompt = p.prompt
|
250 |
+
|
251 |
+
for n in range(batch_count):
|
252 |
+
history = []
|
253 |
+
|
254 |
+
# Reset to original init image at the start of each batch
|
255 |
+
p.init_images = original_init_image
|
256 |
+
|
257 |
+
seed_state = "adding"
|
258 |
+
current_seed = p.seed
|
259 |
+
|
260 |
+
for i in range(frames):
|
261 |
+
current_seed = p.seed
|
262 |
+
state.job = ""
|
263 |
+
|
264 |
+
if str(i) in changes_dict:
|
265 |
+
raw_prompt = changes_dict[str(i)]["prompt"]
|
266 |
+
state.job = "New prompt: %s\n" % raw_prompt
|
267 |
+
|
268 |
+
if "seed" in changes_dict[str(i)]:
|
269 |
+
current_seed = changes_dict[str(i)]["seed"]
|
270 |
+
|
271 |
+
if current_seed.startswith("+"):
|
272 |
+
seed_state = "adding"
|
273 |
+
current_seed = current_seed.strip("+")
|
274 |
+
elif current_seed.startswith("-"):
|
275 |
+
seed_state = "subtracting"
|
276 |
+
current_seed = current_seed.strip("-")
|
277 |
+
else:
|
278 |
+
seed_state = "constant"
|
279 |
+
|
280 |
+
current_seed = int(current_seed)
|
281 |
+
p.seed = current_seed
|
282 |
+
|
283 |
+
|
284 |
+
|
285 |
+
p.n_iter = 1
|
286 |
+
p.batch_size = 1
|
287 |
+
p.do_not_save_grid = True
|
288 |
+
|
289 |
+
if opts.img2img_color_correction:
|
290 |
+
p.color_corrections = initial_color_corrections
|
291 |
+
|
292 |
+
|
293 |
+
wave_progress = float(1)/(float(frames_per_wave - 1))*float(((float(i)%float(frames_per_wave)) + ((float(1)/float(180))*denoising_strength_change_offset)))
|
294 |
+
print(wave_progress)
|
295 |
+
new_prompt = re.sub(wave_completed_regex, lambda x: set_weights(x, wave_progress), raw_prompt)
|
296 |
+
new_prompt = re.sub(wave_remaining_regex, lambda x: set_weights(x, 1 - wave_progress), new_prompt)
|
297 |
+
p.prompt = new_prompt
|
298 |
+
|
299 |
+
print(new_prompt)
|
300 |
+
|
301 |
+
denoising_strength_change_rate = 180/frames_per_wave
|
302 |
+
|
303 |
+
cos = abs(math.cos(math.radians(i*denoising_strength_change_rate + denoising_strength_change_offset)))
|
304 |
+
p.denoising_strength = initial_denoising_strength + denoising_strength_change_amplitude - (cos * denoising_strength_change_amplitude)
|
305 |
+
|
306 |
+
state.job += f"Iteration {i + 1}/{frames}, batch {n + 1}/{batch_count}. Denoising Strength: {p.denoising_strength}"
|
307 |
+
|
308 |
+
processed = processing.process_images(p)
|
309 |
+
|
310 |
+
if initial_seed is None:
|
311 |
+
initial_seed = processed.seed
|
312 |
+
initial_info = processed.info
|
313 |
+
|
314 |
+
init_img = processed.images[0]
|
315 |
+
|
316 |
+
p.init_images = [init_img]
|
317 |
+
|
318 |
+
if seed_state == "adding":
|
319 |
+
p.seed = processed.seed + 1
|
320 |
+
elif seed_state == "subtracting":
|
321 |
+
p.seed = processed.seed - 1
|
322 |
+
|
323 |
+
image_number = int(initial_image_number + i)
|
324 |
+
images.save_image(init_img, p.outpath_samples, "", processed.seed, processed.prompt, forced_filename=str(image_number))
|
325 |
+
|
326 |
+
history.append(init_img)
|
327 |
+
|
328 |
+
grid = images.image_grid(history, rows=1)
|
329 |
+
if opts.grid_save:
|
330 |
+
images.save_image(grid, p.outpath_grids, "grid", initial_seed, p.prompt, opts.grid_format, info=info, short_filename=not opts.grid_extended_filename, grid=True, p=p)
|
331 |
+
|
332 |
+
grids.append(grid)
|
333 |
+
all_images += history
|
334 |
+
|
335 |
+
if opts.return_grid:
|
336 |
+
all_images = grids + all_images
|
337 |
+
|
338 |
+
if save_video:
|
339 |
+
now = datetime.now() # get the current date and time
|
340 |
+
date_string = now.strftime("%Y-%m-%d")
|
341 |
+
input_pattern = os.path.join(loopback_wave_images_path, date_string,"%d.png")
|
342 |
+
encode_video(input_pattern, initial_image_number, loopback_wave_images_path, video_fps, video_quality, video_encoding, segment_video, video_segment_duration, ffmpeg_path)
|
343 |
+
|
344 |
+
processed = Processed(p, all_images, initial_seed, initial_info)
|
345 |
+
|
346 |
+
return processed
|
347 |
+
|
348 |
+
|
scripts/Txt2img2img2img.py
ADDED
@@ -0,0 +1,291 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from modules.shared import opts, cmd_opts, state
|
2 |
+
from modules.processing import Processed, StableDiffusionProcessingImg2Img, process_images, images
|
3 |
+
from modules import paths, shared, modelloader, sd_models
|
4 |
+
from modules import sd_samplers
|
5 |
+
from PIL import Image, ImageDraw
|
6 |
+
import gradio as gr
|
7 |
+
import modules.scripts as scripts
|
8 |
+
from random import randint
|
9 |
+
from skimage.util import random_noise
|
10 |
+
from gradio.processing_utils import encode_pil_to_base64
|
11 |
+
import numpy as np
|
12 |
+
import os.path
|
13 |
+
from copy import deepcopy
|
14 |
+
def remap_range(value, minIn, MaxIn, minOut, maxOut):
|
15 |
+
if value > MaxIn: value = MaxIn;
|
16 |
+
if value < minIn: value = minIn;
|
17 |
+
if (MaxIn - minIn) == 0 : return maxOut
|
18 |
+
finalValue = ((value - minIn) / (MaxIn - minIn)) * (maxOut - minOut) + minOut;
|
19 |
+
return finalValue;
|
20 |
+
|
21 |
+
class Script(scripts.Script):
|
22 |
+
def title(self):
|
23 |
+
return "Txt2img2img2img"
|
24 |
+
|
25 |
+
def ui(self, is_img2img):
|
26 |
+
if is_img2img: return
|
27 |
+
|
28 |
+
# samplers list
|
29 |
+
img2img_samplers_names = [s.name for s in sd_samplers.samplers_for_img2img]
|
30 |
+
|
31 |
+
# models list
|
32 |
+
model_dir = "Stable-diffusion"
|
33 |
+
model_path = os.path.abspath(os.path.join(paths.models_path, model_dir))
|
34 |
+
model_list = modelloader.load_models(model_path=model_path, command_path=shared.cmd_opts.ckpt_dir, ext_filter=[".ckpt", ".safetensors"], download_name="v1-5-pruned-emaonly.safetensors", ext_blacklist=[".vae.ckpt", ".vae.safetensors"])
|
35 |
+
model_list = [m.split("\\")[-1] for m in model_list]
|
36 |
+
model_list.append("Same")
|
37 |
+
|
38 |
+
t2iii_reprocess = gr.Slider(minimum=1, maximum=128, step=1, label='Number of img2img', value=1)
|
39 |
+
t2iii_steps = gr.Slider(minimum=1, maximum=120, step=1, label='img2img steps', value=24)
|
40 |
+
with gr.Row():
|
41 |
+
t2iii_cfg_scale = gr.Slider(minimum=1, maximum=30, step=0.1, label='img2img cfg scale ', value=8.3)
|
42 |
+
t2iii_cfg_scale_end = gr.Slider(minimum=0, maximum=30, step=0.1, label='img2img cfg end scale (0=disabled) ', value=0)
|
43 |
+
with gr.Row():
|
44 |
+
t2iii_denoising_strength = gr.Slider(minimum=0, maximum=1, step=0.01, label='img2img denoising strength ', value=0.42)
|
45 |
+
t2iii_patch_end_denoising = gr.Slider(minimum=0, maximum=1, step=0.01, label='Last img denoising (0=disabled)', value=0)
|
46 |
+
t2iii_seed_shift = gr.Slider(minimum=-1, maximum=1000000, step=1, label='img2img new seed+ (-1 for random)', value=1)
|
47 |
+
with gr.Row():
|
48 |
+
t2iii_patch_upscale = gr.Checkbox(label='Patch upscale', value=False)
|
49 |
+
t2iii_patch_shift = gr.Checkbox(label='Patch upscale shift grid', value=True)
|
50 |
+
t2iii_save_first = gr.Checkbox(label='Save first image', value=False)
|
51 |
+
t2iii_only_last = gr.Checkbox(label='Only save last img2img', value=True)
|
52 |
+
t2iii_face_correction = gr.Checkbox(label='Face correction on all', value=False)
|
53 |
+
t2iii_face_correction_last = gr.Checkbox(label='Face correction on last', value=False)
|
54 |
+
with gr.Row():
|
55 |
+
t2iii_model = gr.Dropdown(label="Model", choices=model_list, value="Same")
|
56 |
+
t2iii_sampler = gr.Dropdown(label="Sampler", choices=img2img_samplers_names, value="DPM++ 2M")
|
57 |
+
# with gr.Row():
|
58 |
+
# t2iii_override_s_noise = gr.Checkbox(label='Override sampler\'s noise for last pass', value=False)
|
59 |
+
# t2iii_sampler_noise = gr.Slider(minimum=0, maximum=1, step=0.5, label='Sampler\'s noise for last pass', value=0)
|
60 |
+
with gr.Row():
|
61 |
+
t2iii_clip = gr.Slider(minimum=0, maximum=12, step=1, label='change clip for img2img (0 = disabled)', value=0)
|
62 |
+
t2iii_noise = gr.Slider(minimum=0, maximum=0.005, step=0.0001, label='Add noise before img2img ', value=0)
|
63 |
+
with gr.Row():
|
64 |
+
t2iii_patch_square_size = gr.Slider(minimum=64, maximum=2048, step=64, label='Patch upscale square size', value=512)
|
65 |
+
t2iii_patch_padding = gr.Slider(minimum=0, maximum=512, step=8, label='Patch upscale padding', value=128)
|
66 |
+
with gr.Row():
|
67 |
+
t2iii_patch_border = gr.Slider(minimum=0, maximum=64, step=1, label='Patch upscale mask inner border', value=8)
|
68 |
+
t2iii_patch_mask_blur = gr.Slider(minimum=0, maximum=64 , step=1, label='Patch upscale mask blur', value=4)
|
69 |
+
with gr.Row():
|
70 |
+
t2iii_upscale_x = gr.Slider(minimum=64, maximum=16384, step=64, label='img2img width (64 = no rescale) ', value=768)
|
71 |
+
t2iii_upscale_y = gr.Slider(minimum=64, maximum=16384, step=64, label='img2img height (64 = no rescale) ', value=960)
|
72 |
+
t2iii_2x_last = gr.Slider(minimum=1, maximum=4, step=0.1, label='resize time x size for last pass', value=1)
|
73 |
+
with gr.Row():
|
74 |
+
t2iii_replace_prompt = gr.Checkbox(label='Replace the prompt', value=False)
|
75 |
+
t2iii_replace_negative_prompt = gr.Checkbox(label='Replace the negative prompt', value=False)
|
76 |
+
add_to_prompt = gr.Textbox(label="Add to prompt", lines=2, max_lines=2000)
|
77 |
+
add_to_negative_prompt = gr.Textbox(label="Add to prompt", lines=2, max_lines=2000)
|
78 |
+
|
79 |
+
return [t2iii_reprocess,t2iii_steps,t2iii_cfg_scale,t2iii_seed_shift,t2iii_denoising_strength,t2iii_patch_upscale,t2iii_patch_shift,t2iii_2x_last,t2iii_save_first,t2iii_only_last,t2iii_face_correction,t2iii_face_correction_last, t2iii_model, t2iii_sampler,t2iii_clip,t2iii_noise,t2iii_patch_padding,t2iii_patch_square_size,t2iii_patch_border,t2iii_patch_mask_blur,t2iii_patch_end_denoising,t2iii_upscale_x,t2iii_upscale_y,add_to_prompt,add_to_negative_prompt,t2iii_replace_prompt,t2iii_replace_negative_prompt,t2iii_cfg_scale_end]
|
80 |
+
def run(self,p,t2iii_reprocess,t2iii_steps,t2iii_cfg_scale,t2iii_seed_shift,t2iii_denoising_strength,t2iii_patch_upscale,t2iii_patch_shift,t2iii_2x_last,t2iii_save_first,t2iii_only_last,t2iii_face_correction,t2iii_face_correction_last, t2iii_model, t2iii_sampler,t2iii_clip,t2iii_noise,t2iii_patch_padding,t2iii_patch_square_size,t2iii_patch_border,t2iii_patch_mask_blur,t2iii_patch_end_denoising,t2iii_upscale_x,t2iii_upscale_y,add_to_prompt,add_to_negative_prompt,t2iii_replace_prompt,t2iii_replace_negative_prompt,t2iii_cfg_scale_end):
|
81 |
+
def add_noise_to_image(img,seed,t2iii_noise):
|
82 |
+
img = np.array(img)
|
83 |
+
img = random_noise(img, mode='gaussian', seed=proc.seed, clip=True, var=t2iii_noise)
|
84 |
+
img = np.array(255*img, dtype = 'uint8')
|
85 |
+
img = Image.fromarray(np.array(img))
|
86 |
+
return img
|
87 |
+
def create_mask(size, border_width):
|
88 |
+
im = Image.new('RGB', (size, size), color='white')
|
89 |
+
draw = ImageDraw.Draw(im)
|
90 |
+
draw.rectangle((0, 0, size, size), outline='black', width=border_width)
|
91 |
+
return im
|
92 |
+
def clean_model_name(model_name):
|
93 |
+
if "[" in model_name:
|
94 |
+
model_name = model_name.split(" ")[-2]
|
95 |
+
return model_name
|
96 |
+
def get_current_model_name():
|
97 |
+
return clean_model_name(shared.opts.sd_model_checkpoint)
|
98 |
+
def is_model_loaded(wanted):
|
99 |
+
return wanted == get_current_model_name()
|
100 |
+
|
101 |
+
img2img_samplers_names = [s.name for s in sd_samplers.samplers_for_img2img]
|
102 |
+
img2img_sampler_index = [i for i in range(len(img2img_samplers_names)) if img2img_samplers_names[i] == t2iii_sampler][0]
|
103 |
+
|
104 |
+
|
105 |
+
|
106 |
+
# models paths
|
107 |
+
model_dir = "Stable-diffusion"
|
108 |
+
model_path = os.path.abspath(os.path.join(paths.models_path, model_dir))
|
109 |
+
initial_model = get_current_model_name()
|
110 |
+
initial_model_path = os.path.abspath(os.path.join(model_path,initial_model))
|
111 |
+
|
112 |
+
secondary_model_name = clean_model_name(t2iii_model)
|
113 |
+
secondary_model_path = ""
|
114 |
+
if t2iii_model != "Same":
|
115 |
+
secondary_model_name = clean_model_name(t2iii_model)
|
116 |
+
secondary_model_path = os.path.abspath(os.path.join(model_path,secondary_model_name))
|
117 |
+
|
118 |
+
|
119 |
+
|
120 |
+
if p.seed == -1: p.seed = randint(0,1000000000)
|
121 |
+
|
122 |
+
initial_CLIP = opts.data["CLIP_stop_at_last_layers"]
|
123 |
+
p.do_not_save_samples = not t2iii_save_first
|
124 |
+
initial_prompt = deepcopy(p.prompt)
|
125 |
+
initial_negative_prompt = deepcopy(p.negative_prompt)
|
126 |
+
|
127 |
+
n_iter=p.n_iter
|
128 |
+
for j in range(n_iter):
|
129 |
+
|
130 |
+
if t2iii_model != "Same":
|
131 |
+
if not is_model_loaded(initial_model):
|
132 |
+
print()
|
133 |
+
sd_models.load_model(sd_models.CheckpointInfo(initial_model_path))
|
134 |
+
|
135 |
+
p.n_iter=1
|
136 |
+
if t2iii_clip > 0:
|
137 |
+
opts.data["CLIP_stop_at_last_layers"] = initial_CLIP
|
138 |
+
|
139 |
+
p.prompt = initial_prompt
|
140 |
+
p.negative_prompt = initial_negative_prompt
|
141 |
+
|
142 |
+
# PROCESS IMAGE
|
143 |
+
proc = process_images(p)
|
144 |
+
|
145 |
+
if add_to_prompt != "" or t2iii_replace_prompt:
|
146 |
+
if t2iii_replace_prompt:
|
147 |
+
p.prompt = add_to_prompt
|
148 |
+
else:
|
149 |
+
p.prompt = initial_prompt+add_to_prompt
|
150 |
+
|
151 |
+
if add_to_negative_prompt != "" or t2iii_replace_negative_prompt:
|
152 |
+
if t2iii_replace_negative_prompt:
|
153 |
+
p.negative_prompt = add_to_negative_prompt
|
154 |
+
else:
|
155 |
+
p.negative_prompt = initial_negative_prompt+add_to_negative_prompt
|
156 |
+
|
157 |
+
basename = ""
|
158 |
+
extra_gen_parms = {
|
159 |
+
'Initial steps':p.steps,
|
160 |
+
'Initial CFG scale':p.cfg_scale,
|
161 |
+
"Initial seed": p.seed,
|
162 |
+
'Initial sampler': p.sampler_name,
|
163 |
+
'Reprocess amount':t2iii_reprocess
|
164 |
+
}
|
165 |
+
for i in range(t2iii_reprocess):
|
166 |
+
if t2iii_upscale_x > 64:
|
167 |
+
upscale_x = t2iii_upscale_x
|
168 |
+
else:
|
169 |
+
upscale_x = p.width
|
170 |
+
if t2iii_upscale_y > 64:
|
171 |
+
upscale_y = t2iii_upscale_y
|
172 |
+
else:
|
173 |
+
upscale_y = p.height
|
174 |
+
if t2iii_2x_last > 1 and i+1 == t2iii_reprocess:
|
175 |
+
upscale_x = int(upscale_x*t2iii_2x_last)
|
176 |
+
upscale_y = int(upscale_y*t2iii_2x_last)
|
177 |
+
if t2iii_seed_shift == -1:
|
178 |
+
reprocess_seed = randint(0,999999999)
|
179 |
+
else:
|
180 |
+
reprocess_seed = p.seed+t2iii_seed_shift*(i+1)
|
181 |
+
if t2iii_clip > 0:
|
182 |
+
opts.data["CLIP_stop_at_last_layers"] = t2iii_clip
|
183 |
+
|
184 |
+
if state.interrupted:
|
185 |
+
if t2iii_clip > 0:
|
186 |
+
opts.data["CLIP_stop_at_last_layers"] = initial_CLIP
|
187 |
+
break
|
188 |
+
|
189 |
+
if t2iii_model != "Same":
|
190 |
+
if not is_model_loaded(secondary_model_name):
|
191 |
+
print()
|
192 |
+
sd_models.load_model(sd_models.CheckpointInfo(secondary_model_path))
|
193 |
+
|
194 |
+
if i == 0:
|
195 |
+
proc_temp = proc
|
196 |
+
else:
|
197 |
+
proc_temp = proc2
|
198 |
+
if t2iii_noise > 0 :
|
199 |
+
proc_temp.images[0] = add_noise_to_image(proc_temp.images[0],p.seed,t2iii_noise)
|
200 |
+
|
201 |
+
img2img_processing = StableDiffusionProcessingImg2Img(
|
202 |
+
init_images=proc_temp.images,
|
203 |
+
resize_mode=0,
|
204 |
+
denoising_strength=remap_range(i,0,t2iii_reprocess-1,t2iii_denoising_strength,t2iii_patch_end_denoising) if t2iii_patch_end_denoising > 0 else t2iii_denoising_strength,
|
205 |
+
mask=None,
|
206 |
+
mask_blur=t2iii_patch_mask_blur,
|
207 |
+
inpainting_fill=1,
|
208 |
+
inpaint_full_res=False,
|
209 |
+
inpaint_full_res_padding=0,
|
210 |
+
inpainting_mask_invert=0,
|
211 |
+
sd_model=p.sd_model,
|
212 |
+
outpath_samples=p.outpath_samples,
|
213 |
+
outpath_grids=p.outpath_grids,
|
214 |
+
prompt=p.prompt,
|
215 |
+
styles=p.styles,
|
216 |
+
seed=reprocess_seed,
|
217 |
+
subseed=proc_temp.subseed,
|
218 |
+
subseed_strength=p.subseed_strength,
|
219 |
+
seed_resize_from_h=p.seed_resize_from_h,
|
220 |
+
seed_resize_from_w=p.seed_resize_from_w,
|
221 |
+
#seed_enable_extras=p.seed_enable_extras,
|
222 |
+
sampler_name=t2iii_sampler,
|
223 |
+
#sampler_index=img2img_sampler_index,
|
224 |
+
batch_size=p.batch_size,
|
225 |
+
n_iter=p.n_iter,
|
226 |
+
steps=t2iii_steps,
|
227 |
+
cfg_scale=remap_range(i,0,t2iii_reprocess-1,t2iii_cfg_scale,t2iii_cfg_scale_end) if t2iii_cfg_scale_end > 0 else t2iii_cfg_scale,
|
228 |
+
width=upscale_x,
|
229 |
+
height=upscale_y,
|
230 |
+
restore_faces=(t2iii_face_correction or (t2iii_face_correction_last and t2iii_reprocess-1 == i)) and not (t2iii_reprocess-1 == i and not t2iii_face_correction_last),
|
231 |
+
tiling=p.tiling,
|
232 |
+
do_not_save_samples=True,
|
233 |
+
do_not_save_grid=p.do_not_save_grid,
|
234 |
+
extra_generation_params=extra_gen_parms,
|
235 |
+
overlay_images=p.overlay_images,
|
236 |
+
negative_prompt=p.negative_prompt,
|
237 |
+
eta=p.eta
|
238 |
+
)
|
239 |
+
# if t2iii_reprocess-1 == i and t2iii_override_s_noise:
|
240 |
+
# img2img_processing.s_noise = t2iii_sampler_noise
|
241 |
+
if not t2iii_patch_upscale:
|
242 |
+
proc2 = process_images(img2img_processing)
|
243 |
+
if ((t2iii_only_last and t2iii_reprocess-1 == i) or not t2iii_only_last):
|
244 |
+
images.save_image(proc2.images[0], p.outpath_samples, "", proc_temp.seed, proc2.prompt, opts.samples_format, info=proc_temp.info, p=p)
|
245 |
+
else:
|
246 |
+
proc_temp.images[0] = proc_temp.images[0].resize((upscale_x, upscale_y), Image.Resampling.LANCZOS)
|
247 |
+
width_for_patch, height_for_patch = proc_temp.images[0].size
|
248 |
+
real_square_size = int(t2iii_patch_square_size)
|
249 |
+
overlap_pass = int(real_square_size/t2iii_reprocess)*i
|
250 |
+
patch_seed = reprocess_seed
|
251 |
+
for x in range(0, width_for_patch+overlap_pass if i>0 and t2iii_patch_shift else width_for_patch, real_square_size):
|
252 |
+
for y in range(0, height_for_patch+overlap_pass if i>0 and t2iii_patch_shift else height_for_patch, real_square_size):
|
253 |
+
if (
|
254 |
+
x-overlap_pass > width_for_patch or
|
255 |
+
y-overlap_pass > height_for_patch or
|
256 |
+
x+real_square_size-overlap_pass < 0 or
|
257 |
+
y+real_square_size-overlap_pass < 0
|
258 |
+
): continue
|
259 |
+
if t2iii_seed_shift == -1:
|
260 |
+
patch_seed = randint(0,999999999)
|
261 |
+
else:
|
262 |
+
patch_seed = patch_seed+t2iii_seed_shift
|
263 |
+
patch = proc_temp.images[0].crop((x-t2iii_patch_padding-overlap_pass,
|
264 |
+
y-t2iii_patch_padding-overlap_pass,
|
265 |
+
x + real_square_size + t2iii_patch_padding-overlap_pass,
|
266 |
+
y + real_square_size + t2iii_patch_padding-overlap_pass))
|
267 |
+
img2img_processing.init_images = [patch]
|
268 |
+
img2img_processing.do_not_save_samples = True
|
269 |
+
img2img_processing.width = patch.size[0]
|
270 |
+
img2img_processing.height = patch.size[1]
|
271 |
+
img2img_processing.seed = patch_seed
|
272 |
+
mask = create_mask(patch.size[0],t2iii_patch_padding+t2iii_patch_border)
|
273 |
+
img2img_processing.image_mask = mask
|
274 |
+
proc_patch_temp = process_images(img2img_processing)
|
275 |
+
patch = proc_patch_temp.images[0]
|
276 |
+
patch = patch.crop((t2iii_patch_padding, t2iii_patch_padding, patch.size[0] - t2iii_patch_padding, patch.size[1] - t2iii_patch_padding))
|
277 |
+
proc_temp.images[0].paste(patch, (x-overlap_pass, y-overlap_pass))
|
278 |
+
proc2 = proc_patch_temp
|
279 |
+
proc2.images[0] = proc_temp.images[0]
|
280 |
+
images.save_image(proc2.images[0], p.outpath_samples, "", proc2.seed, proc2.prompt, opts.samples_format, info=proc2.info, p=p)
|
281 |
+
|
282 |
+
|
283 |
+
p.subseed = p.subseed + 1 if p.subseed_strength > 0 else p.subseed
|
284 |
+
p.seed = p.seed + 1 if p.subseed_strength == 0 else p.seed
|
285 |
+
if t2iii_model != "Same":
|
286 |
+
if not is_model_loaded(initial_model):
|
287 |
+
print()
|
288 |
+
sd_models.load_model(sd_models.CheckpointInfo(initial_model_path))
|
289 |
+
if t2iii_clip > 0:
|
290 |
+
opts.data["CLIP_stop_at_last_layers"] = initial_CLIP
|
291 |
+
return proc
|
scripts/UnsharpMask.py
ADDED
@@ -0,0 +1,54 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import modules.scripts as scripts
|
2 |
+
import gradio as gr
|
3 |
+
import os
|
4 |
+
from modules import images
|
5 |
+
from modules.processing import process_images, Processed
|
6 |
+
from modules.processing import Processed
|
7 |
+
from modules.shared import opts, cmd_opts, state
|
8 |
+
|
9 |
+
class Script(scripts.Script):
|
10 |
+
|
11 |
+
def title(self):
|
12 |
+
return "Unsharp Mask"
|
13 |
+
|
14 |
+
#only show in img2img tab
|
15 |
+
|
16 |
+
def show(self, is_img2img):
|
17 |
+
return is_img2img
|
18 |
+
|
19 |
+
#Gradio interface parameters
|
20 |
+
|
21 |
+
def ui(self, is_img2img):
|
22 |
+
save = gr.Checkbox(False, label="Save original and effect")
|
23 |
+
umradius = gr.Slider(minimum=0.0, maximum=1000.0, step=1, value=0, label="Radius")
|
24 |
+
umpercent = gr.Slider(minimum=0.0, maximum=500.0, step=1, value=0, label="Percent")
|
25 |
+
umthreshold = gr.Slider(minimum=0.0, maximum=255.0, step=1, value=0, label="Threshold")
|
26 |
+
return [save, umradius, umpercent, umthreshold]
|
27 |
+
|
28 |
+
#processed object
|
29 |
+
def run(self, p, save, umradius, umpercent, umthreshold):
|
30 |
+
|
31 |
+
#perform unsharp mask operation
|
32 |
+
def unsharp_mask(im, umradius, umpercent, umthreshold):
|
33 |
+
from PIL import Image, ImageFilter
|
34 |
+
raf = im
|
35 |
+
raf = raf.filter(filter=ImageFilter.UnsharpMask(radius = umradius, percent = umpercent, threshold = umthreshold))
|
36 |
+
return raf
|
37 |
+
|
38 |
+
# If save is off, save with prefix filename
|
39 |
+
basename = ""
|
40 |
+
if(save):
|
41 |
+
basename += "unsharpmask_"
|
42 |
+
else:
|
43 |
+
p.do_not_save_samples = True
|
44 |
+
|
45 |
+
#process images
|
46 |
+
proc = process_images(p)
|
47 |
+
|
48 |
+
for i in range(len(proc.images)):
|
49 |
+
|
50 |
+
proc.images[i] = unsharp_mask(proc.images[i], umradius, umpercent, umthreshold)
|
51 |
+
images.save_image(proc.images[i], p.outpath_samples, basename,
|
52 |
+
proc.seed + i, proc.prompt, opts.samples_format, info= proc.info, p=p)
|
53 |
+
|
54 |
+
return proc
|
scripts/__pycache__/CFG Auto.cpython-310.pyc
ADDED
Binary file (10.1 kB). View file
|
|
scripts/__pycache__/CFG Schedule.cpython-310.pyc
ADDED
Binary file (10.1 kB). View file
|
|
scripts/__pycache__/ContorlNet_I2I_sequence_toyxyz_V2.cpython-310.pyc
ADDED
Binary file (9.42 kB). View file
|
|
scripts/__pycache__/LoopbackWave.cpython-310.pyc
ADDED
Binary file (8.7 kB). View file
|
|
scripts/__pycache__/Txt2img2img2img.cpython-310.pyc
ADDED
Binary file (10 kB). View file
|
|
scripts/__pycache__/UnsharpMask.cpython-310.pyc
ADDED
Binary file (1.99 kB). View file
|
|
scripts/__pycache__/advanced_loopback.cpython-310.pyc
ADDED
Binary file (7.94 kB). View file
|
|
scripts/__pycache__/advanced_loopback_blend.cpython-310.pyc
ADDED
Binary file (7.84 kB). View file
|
|
scripts/__pycache__/advanced_seed_blending.cpython-310.pyc
ADDED
Binary file (1.97 kB). View file
|
|
scripts/__pycache__/alternate_sampler_noise_schedules.cpython-310.pyc
ADDED
Binary file (2.27 kB). View file
|
|
scripts/__pycache__/block_lora.cpython-310.pyc
ADDED
Binary file (6.85 kB). View file
|
|
scripts/__pycache__/cache_cleaner(from sd-webui-gradio-cleaner).cpython-310.pyc
ADDED
Binary file (1.1 kB). View file
|
|
scripts/__pycache__/custom_code-Copy1.cpython-310.pyc
ADDED
Binary file (2.74 kB). View file
|
|
scripts/__pycache__/custom_code.cpython-310.pyc
ADDED
Binary file (2.73 kB). View file
|
|
scripts/__pycache__/epiCFG_schedule_type.cpython-310.pyc
ADDED
Binary file (8.51 kB). View file
|
|
scripts/__pycache__/external_masking.cpython-310.pyc
ADDED
Binary file (6.59 kB). View file
|
|
scripts/__pycache__/img2imgalt-Copy1.cpython-310.pyc
ADDED
Binary file (6.38 kB). View file
|
|
scripts/__pycache__/img2imgalt.cpython-310.pyc
ADDED
Binary file (6.38 kB). View file
|
|
scripts/__pycache__/loopback-Copy1.cpython-310.pyc
ADDED
Binary file (3.57 kB). View file
|
|
scripts/__pycache__/loopback.cpython-310.pyc
ADDED
Binary file (3.57 kB). View file
|
|
scripts/__pycache__/loopback_for_chain.cpython-310.pyc
ADDED
Binary file (3.35 kB). View file
|
|
scripts/__pycache__/outpainting_mk_2-Copy1.cpython-310.pyc
ADDED
Binary file (8.31 kB). View file
|
|
scripts/__pycache__/outpainting_mk_2.cpython-310.pyc
ADDED
Binary file (8.31 kB). View file
|
|
scripts/__pycache__/poor_mans_outpainting-Copy1.cpython-310.pyc
ADDED
Binary file (4.12 kB). View file
|
|
scripts/__pycache__/poor_mans_outpainting.cpython-310.pyc
ADDED
Binary file (4.12 kB). View file
|
|
scripts/__pycache__/postprocessing_codeformer-Copy1.cpython-310.pyc
ADDED
Binary file (1.71 kB). View file
|
|
scripts/__pycache__/postprocessing_codeformer.cpython-310.pyc
ADDED
Binary file (1.71 kB). View file
|
|
scripts/__pycache__/postprocessing_gfpgan-Copy1.cpython-310.pyc
ADDED
Binary file (1.44 kB). View file
|
|
scripts/__pycache__/postprocessing_gfpgan.cpython-310.pyc
ADDED
Binary file (1.43 kB). View file
|
|
scripts/__pycache__/postprocessing_upscale-Copy1.cpython-310.pyc
ADDED
Binary file (8.63 kB). View file
|
|
scripts/__pycache__/postprocessing_upscale.cpython-310.pyc
ADDED
Binary file (8.62 kB). View file
|
|
scripts/__pycache__/process_png_metadata.cpython-310.pyc
ADDED
Binary file (8.3 kB). View file
|
|
scripts/__pycache__/prompt_matrix-Copy1.cpython-310.pyc
ADDED
Binary file (4.21 kB). View file
|
|
scripts/__pycache__/prompt_matrix.cpython-310.pyc
ADDED
Binary file (4.2 kB). View file
|
|
scripts/__pycache__/prompter.cpython-310.pyc
ADDED
Binary file (17.5 kB). View file
|
|
scripts/__pycache__/prompts_from_file-Copy1.cpython-310.pyc
ADDED
Binary file (5.59 kB). View file
|
|
scripts/__pycache__/prompts_from_file.cpython-310.pyc
ADDED
Binary file (5.59 kB). View file
|
|
scripts/__pycache__/prompts_from_file_2.cpython-310.pyc
ADDED
Binary file (9.19 kB). View file
|
|
scripts/__pycache__/quick_upscale.cpython-310.pyc
ADDED
Binary file (1.84 kB). View file
|
|
scripts/__pycache__/run_n_times.cpython-310.pyc
ADDED
Binary file (1.02 kB). View file
|
|
scripts/__pycache__/save-steps.cpython-310.pyc
ADDED
Binary file (1.56 kB). View file
|
|
scripts/__pycache__/sd_upscale-Copy1.cpython-310.pyc
ADDED
Binary file (3.59 kB). View file
|
|
scripts/__pycache__/sd_upscale.cpython-310.pyc
ADDED
Binary file (3.58 kB). View file
|
|
scripts/__pycache__/size_travel.cpython-310.pyc
ADDED
Binary file (10.7 kB). View file
|
|