Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
chenpangpang
ComfyUI
Commits
8363ef96
Commit
8363ef96
authored
Mar 29, 2023
by
pythongosssss
Browse files
Merge remote-tracking branch 'origin/master' into menu-save-and-anchor
parents
9fdd5245
b2554bc4
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
32 additions
and
10 deletions
+32
-10
comfy/samplers.py
comfy/samplers.py
+5
-2
comfy/sd.py
comfy/sd.py
+8
-3
execution.py
execution.py
+5
-3
notebooks/comfyui_colab.ipynb
notebooks/comfyui_colab.ipynb
+1
-1
web/scripts/app.js
web/scripts/app.js
+9
-0
web/scripts/ui.js
web/scripts/ui.js
+4
-1
No files found.
comfy/samplers.py
View file @
8363ef96
...
@@ -242,7 +242,10 @@ def ddim_scheduler(model, steps):
...
@@ -242,7 +242,10 @@ def ddim_scheduler(model, steps):
sigs
=
[]
sigs
=
[]
ddim_timesteps
=
make_ddim_timesteps
(
ddim_discr_method
=
"uniform"
,
num_ddim_timesteps
=
steps
,
num_ddpm_timesteps
=
model
.
inner_model
.
inner_model
.
num_timesteps
,
verbose
=
False
)
ddim_timesteps
=
make_ddim_timesteps
(
ddim_discr_method
=
"uniform"
,
num_ddim_timesteps
=
steps
,
num_ddpm_timesteps
=
model
.
inner_model
.
inner_model
.
num_timesteps
,
verbose
=
False
)
for
x
in
range
(
len
(
ddim_timesteps
)
-
1
,
-
1
,
-
1
):
for
x
in
range
(
len
(
ddim_timesteps
)
-
1
,
-
1
,
-
1
):
sigs
.
append
(
model
.
t_to_sigma
(
torch
.
tensor
(
ddim_timesteps
[
x
])))
ts
=
ddim_timesteps
[
x
]
if
ts
>
999
:
ts
=
999
sigs
.
append
(
model
.
t_to_sigma
(
torch
.
tensor
(
ts
)))
sigs
+=
[
0.0
]
sigs
+=
[
0.0
]
return
torch
.
FloatTensor
(
sigs
)
return
torch
.
FloatTensor
(
sigs
)
...
@@ -373,7 +376,7 @@ class KSampler:
...
@@ -373,7 +376,7 @@ class KSampler:
def
set_steps
(
self
,
steps
,
denoise
=
None
):
def
set_steps
(
self
,
steps
,
denoise
=
None
):
self
.
steps
=
steps
self
.
steps
=
steps
if
denoise
is
None
:
if
denoise
is
None
or
denoise
>
0.9999
:
self
.
sigmas
=
self
.
_calculate_sigmas
(
steps
)
self
.
sigmas
=
self
.
_calculate_sigmas
(
steps
)
else
:
else
:
new_steps
=
int
(
steps
/
denoise
)
new_steps
=
int
(
steps
/
denoise
)
...
...
comfy/sd.py
View file @
8363ef96
...
@@ -439,9 +439,14 @@ class VAE:
...
@@ -439,9 +439,14 @@ class VAE:
model_management
.
unload_model
()
model_management
.
unload_model
()
self
.
first_stage_model
=
self
.
first_stage_model
.
to
(
self
.
device
)
self
.
first_stage_model
=
self
.
first_stage_model
.
to
(
self
.
device
)
try
:
try
:
samples
=
samples_in
.
to
(
self
.
device
)
free_memory
=
model_management
.
get_free_memory
(
self
.
device
)
pixel_samples
=
self
.
first_stage_model
.
decode
(
1.
/
self
.
scale_factor
*
samples
)
batch_number
=
int
((
free_memory
*
0.7
)
/
(
2562
*
samples_in
.
shape
[
2
]
*
samples_in
.
shape
[
3
]
*
64
))
pixel_samples
=
torch
.
clamp
((
pixel_samples
+
1.0
)
/
2.0
,
min
=
0.0
,
max
=
1.0
)
batch_number
=
max
(
1
,
batch_number
)
pixel_samples
=
torch
.
empty
((
samples_in
.
shape
[
0
],
3
,
round
(
samples_in
.
shape
[
2
]
*
8
),
round
(
samples_in
.
shape
[
3
]
*
8
)),
device
=
"cpu"
)
for
x
in
range
(
0
,
samples_in
.
shape
[
0
],
batch_number
):
samples
=
samples_in
[
x
:
x
+
batch_number
].
to
(
self
.
device
)
pixel_samples
[
x
:
x
+
batch_number
]
=
torch
.
clamp
((
self
.
first_stage_model
.
decode
(
1.
/
self
.
scale_factor
*
samples
)
+
1.0
)
/
2.0
,
min
=
0.0
,
max
=
1.0
).
cpu
()
except
model_management
.
OOM_EXCEPTION
as
e
:
except
model_management
.
OOM_EXCEPTION
as
e
:
print
(
"Warning: Ran out of memory when regular VAE decoding, retrying with tiled VAE decoding."
)
print
(
"Warning: Ran out of memory when regular VAE decoding, retrying with tiled VAE decoding."
)
pixel_samples
=
self
.
decode_tiled_
(
samples_in
)
pixel_samples
=
self
.
decode_tiled_
(
samples_in
)
...
...
execution.py
View file @
8363ef96
...
@@ -10,7 +10,7 @@ import gc
...
@@ -10,7 +10,7 @@ import gc
import
torch
import
torch
import
nodes
import
nodes
def
get_input_data
(
inputs
,
class_def
,
outputs
=
{},
prompt
=
{},
extra_data
=
{}):
def
get_input_data
(
inputs
,
class_def
,
unique_id
,
outputs
=
{},
prompt
=
{},
extra_data
=
{}):
valid_inputs
=
class_def
.
INPUT_TYPES
()
valid_inputs
=
class_def
.
INPUT_TYPES
()
input_data_all
=
{}
input_data_all
=
{}
for
x
in
inputs
:
for
x
in
inputs
:
...
@@ -34,6 +34,8 @@ def get_input_data(inputs, class_def, outputs={}, prompt={}, extra_data={}):
...
@@ -34,6 +34,8 @@ def get_input_data(inputs, class_def, outputs={}, prompt={}, extra_data={}):
if
h
[
x
]
==
"EXTRA_PNGINFO"
:
if
h
[
x
]
==
"EXTRA_PNGINFO"
:
if
"extra_pnginfo"
in
extra_data
:
if
"extra_pnginfo"
in
extra_data
:
input_data_all
[
x
]
=
extra_data
[
'extra_pnginfo'
]
input_data_all
[
x
]
=
extra_data
[
'extra_pnginfo'
]
if
h
[
x
]
==
"UNIQUE_ID"
:
input_data_all
[
x
]
=
unique_id
return
input_data_all
return
input_data_all
def
recursive_execute
(
server
,
prompt
,
outputs
,
current_item
,
extra_data
=
{}):
def
recursive_execute
(
server
,
prompt
,
outputs
,
current_item
,
extra_data
=
{}):
...
@@ -55,7 +57,7 @@ def recursive_execute(server, prompt, outputs, current_item, extra_data={}):
...
@@ -55,7 +57,7 @@ def recursive_execute(server, prompt, outputs, current_item, extra_data={}):
if
input_unique_id
not
in
outputs
:
if
input_unique_id
not
in
outputs
:
executed
+=
recursive_execute
(
server
,
prompt
,
outputs
,
input_unique_id
,
extra_data
)
executed
+=
recursive_execute
(
server
,
prompt
,
outputs
,
input_unique_id
,
extra_data
)
input_data_all
=
get_input_data
(
inputs
,
class_def
,
outputs
,
prompt
,
extra_data
)
input_data_all
=
get_input_data
(
inputs
,
class_def
,
unique_id
,
outputs
,
prompt
,
extra_data
)
if
server
.
client_id
is
not
None
:
if
server
.
client_id
is
not
None
:
server
.
last_node_id
=
unique_id
server
.
last_node_id
=
unique_id
server
.
send_sync
(
"executing"
,
{
"node"
:
unique_id
},
server
.
client_id
)
server
.
send_sync
(
"executing"
,
{
"node"
:
unique_id
},
server
.
client_id
)
...
@@ -96,7 +98,7 @@ def recursive_output_delete_if_changed(prompt, old_prompt, outputs, current_item
...
@@ -96,7 +98,7 @@ def recursive_output_delete_if_changed(prompt, old_prompt, outputs, current_item
if
unique_id
in
old_prompt
and
'is_changed'
in
old_prompt
[
unique_id
]:
if
unique_id
in
old_prompt
and
'is_changed'
in
old_prompt
[
unique_id
]:
is_changed_old
=
old_prompt
[
unique_id
][
'is_changed'
]
is_changed_old
=
old_prompt
[
unique_id
][
'is_changed'
]
if
'is_changed'
not
in
prompt
[
unique_id
]:
if
'is_changed'
not
in
prompt
[
unique_id
]:
input_data_all
=
get_input_data
(
inputs
,
class_def
,
outputs
)
input_data_all
=
get_input_data
(
inputs
,
class_def
,
unique_id
,
outputs
)
if
input_data_all
is
not
None
:
if
input_data_all
is
not
None
:
is_changed
=
class_def
.
IS_CHANGED
(
**
input_data_all
)
is_changed
=
class_def
.
IS_CHANGED
(
**
input_data_all
)
prompt
[
unique_id
][
'is_changed'
]
=
is_changed
prompt
[
unique_id
][
'is_changed'
]
=
is_changed
...
...
notebooks/comfyui_colab.ipynb
View file @
8363ef96
...
@@ -47,7 +47,7 @@
...
@@ -47,7 +47,7 @@
" !git pull\n",
" !git pull\n",
"\n",
"\n",
"!echo -= Install dependencies =-\n",
"!echo -= Install dependencies =-\n",
"!pip -q install xformers -r requirements.txt"
"!pip -q install xformers
==0.0.16
-r requirements.txt"
]
]
},
},
{
{
...
...
web/scripts/app.js
View file @
8363ef96
...
@@ -721,6 +721,8 @@ class ComfyApp {
...
@@ -721,6 +721,8 @@ class ComfyApp {
* @param {*} graphData A serialized graph object
* @param {*} graphData A serialized graph object
*/
*/
loadGraphData
(
graphData
)
{
loadGraphData
(
graphData
)
{
this
.
clean
();
if
(
!
graphData
)
{
if
(
!
graphData
)
{
graphData
=
defaultGraph
;
graphData
=
defaultGraph
;
}
}
...
@@ -903,6 +905,13 @@ class ComfyApp {
...
@@ -903,6 +905,13 @@ class ComfyApp {
}
}
}
}
}
}
/**
* Clean current state
*/
clean
()
{
this
.
nodeOutputs
=
{};
}
}
}
export
const
app
=
new
ComfyApp
();
export
const
app
=
new
ComfyApp
();
web/scripts/ui.js
View file @
8363ef96
...
@@ -485,7 +485,10 @@ export class ComfyUI {
...
@@ -485,7 +485,10 @@ export class ComfyUI {
}),
}),
$el
(
"
button
"
,
{
textContent
:
"
Load
"
,
onclick
:
()
=>
fileInput
.
click
()
}),
$el
(
"
button
"
,
{
textContent
:
"
Load
"
,
onclick
:
()
=>
fileInput
.
click
()
}),
$el
(
"
button
"
,
{
textContent
:
"
Refresh
"
,
onclick
:
()
=>
app
.
refreshComboInNodes
()
}),
$el
(
"
button
"
,
{
textContent
:
"
Refresh
"
,
onclick
:
()
=>
app
.
refreshComboInNodes
()
}),
$el
(
"
button
"
,
{
textContent
:
"
Clear
"
,
onclick
:
()
=>
app
.
graph
.
clear
()
}),
$el
(
"
button
"
,
{
textContent
:
"
Clear
"
,
onclick
:
()
=>
{
app
.
clean
();
app
.
graph
.
clear
();
}}),
$el
(
"
button
"
,
{
textContent
:
"
Load Default
"
,
onclick
:
()
=>
app
.
loadGraphData
()
}),
$el
(
"
button
"
,
{
textContent
:
"
Load Default
"
,
onclick
:
()
=>
app
.
loadGraphData
()
}),
]);
]);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment