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
d1138e8b
"...git@developer.sourcefind.cn:chenpangpang/open-webui.git" did not exist on "b9b1fdd1a1ff2b0d9984cb78623fc14886d7566e"
Commit
d1138e8b
authored
Mar 19, 2023
by
m957ymj75urz
Browse files
rework payload from server
parent
5fa514fa
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
15 additions
and
13 deletions
+15
-13
nodes.py
nodes.py
+10
-5
server.py
server.py
+2
-2
web/scripts/app.js
web/scripts/app.js
+2
-5
web/scripts/widgets.js
web/scripts/widgets.js
+1
-1
No files found.
nodes.py
View file @
d1138e8b
...
...
@@ -775,7 +775,7 @@ class KSamplerAdvanced:
class
SaveImage
:
def
__init__
(
self
):
self
.
output_dir
=
os
.
path
.
join
(
os
.
path
.
dirname
(
os
.
path
.
realpath
(
__file__
)),
"output"
)
self
.
url_suffix
=
"
"
self
.
type
=
"output
"
@
classmethod
def
INPUT_TYPES
(
s
):
...
...
@@ -822,7 +822,7 @@ class SaveImage:
if
not
os
.
path
.
exists
(
self
.
output_dir
):
os
.
makedirs
(
self
.
output_dir
)
path
s
=
list
()
result
s
=
list
()
for
image
in
images
:
i
=
255.
*
image
.
cpu
().
numpy
()
img
=
Image
.
fromarray
(
np
.
clip
(
i
,
0
,
255
).
astype
(
np
.
uint8
))
...
...
@@ -835,14 +835,19 @@ class SaveImage:
file
=
f
"
{
filename
}
_
{
counter
:
05
}
_.png"
img
.
save
(
os
.
path
.
join
(
full_output_folder
,
file
),
pnginfo
=
metadata
,
optimize
=
True
)
paths
.
append
(
os
.
path
.
join
(
subfolder
,
file
+
self
.
url_suffix
))
results
.
append
({
"filename"
:
file
,
"subfolder"
:
subfolder
,
"type"
:
self
.
type
});
counter
+=
1
return
{
"ui"
:
{
"images"
:
paths
}
}
return
{
"ui"
:
{
"images"
:
results
}
}
class
PreviewImage
(
SaveImage
):
def
__init__
(
self
):
self
.
output_dir
=
os
.
path
.
join
(
os
.
path
.
dirname
(
os
.
path
.
realpath
(
__file__
)),
"temp"
)
self
.
url_suffix
=
"&type=
temp"
self
.
type
=
"
temp"
@
classmethod
def
INPUT_TYPES
(
s
):
...
...
server.py
View file @
d1138e8b
...
...
@@ -111,7 +111,7 @@ class PromptServer():
@
routes
.
get
(
"/view"
)
async
def
view_image
(
request
):
if
"file"
in
request
.
rel_url
.
query
:
if
"file
name
"
in
request
.
rel_url
.
query
:
type
=
request
.
rel_url
.
query
.
get
(
"type"
,
"output"
)
if
type
not
in
[
"output"
,
"input"
,
"temp"
]:
return
web
.
Response
(
status
=
400
)
...
...
@@ -123,7 +123,7 @@ class PromptServer():
return
web
.
Response
(
status
=
403
)
output_dir
=
full_output_dir
file
=
request
.
rel_url
.
query
[
"file"
]
file
=
request
.
rel_url
.
query
[
"file
name
"
]
file
=
os
.
path
.
basename
(
file
)
file
=
os
.
path
.
join
(
output_dir
,
file
)
...
...
web/scripts/app.js
View file @
d1138e8b
...
...
@@ -109,11 +109,8 @@ class ComfyApp {
return
new
Promise
((
r
)
=>
{
const
img
=
new
Image
();
img
.
onload
=
()
=>
r
(
img
);
img
.
onerror
=
()
=>
r
(
null
);
var
filename
=
src
.
replace
(
/^.*
[\\\/]
/
,
''
);
var
subfolder
=
src
.
replace
(
filename
,
''
);
img
.
src
=
"
/view?file=
"
+
filename
+
"
&subfolder=
"
+
subfolder
;
img
.
onerror
=
()
=>
r
(
null
);
img
.
src
=
"
/view?
"
+
new
URLSearchParams
(
src
).
toString
();
});
})
).
then
((
imgs
)
=>
{
...
...
web/scripts/widgets.js
View file @
d1138e8b
...
...
@@ -141,7 +141,7 @@ export const ComfyWidgets = {
node
.
imgs
=
[
img
];
app
.
graph
.
setDirtyCanvas
(
true
);
};
img
.
src
=
`/view
/
${
name
}
?
type=input`
;
img
.
src
=
`/view
?filename=
${
name
}
&
type=input`
;
}
// Add our own callback to the combo widget to render an image when it changes
...
...
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