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
99abc0eb
Commit
99abc0eb
authored
Mar 09, 2023
by
pythongosssss
Browse files
Changed to upload to input dir
Fixed jpg Added dupe support Changed to use existing nodes
parent
4a326a25
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
16 additions
and
14 deletions
+16
-14
nodes.py
nodes.py
+0
-8
server.py
server.py
+12
-4
web/extensions/core/uploadImage.js
web/extensions/core/uploadImage.js
+3
-1
web/scripts/widgets.js
web/scripts/widgets.js
+1
-1
No files found.
nodes.py
View file @
99abc0eb
...
...
@@ -833,9 +833,6 @@ class LoadImage:
m
.
update
(
f
.
read
())
return
m
.
digest
().
hex
()
class
UploadImage
(
LoadImage
):
input_dir
=
os
.
path
.
join
(
os
.
path
.
dirname
(
os
.
path
.
realpath
(
__file__
)),
"uploads"
)
class
LoadImageMask
:
input_dir
=
os
.
path
.
join
(
os
.
path
.
dirname
(
os
.
path
.
realpath
(
__file__
)),
"input"
)
@
classmethod
...
...
@@ -871,9 +868,6 @@ class LoadImageMask:
m
.
update
(
f
.
read
())
return
m
.
digest
().
hex
()
class
UploadImageMask
(
LoadImageMask
):
input_dir
=
os
.
path
.
join
(
os
.
path
.
dirname
(
os
.
path
.
realpath
(
__file__
)),
"uploads"
)
class
ImageScale
:
upscale_methods
=
[
"nearest-exact"
,
"bilinear"
,
"area"
]
crop_methods
=
[
"disabled"
,
"center"
]
...
...
@@ -925,9 +919,7 @@ NODE_CLASS_MAPPINGS = {
"LatentUpscale"
:
LatentUpscale
,
"SaveImage"
:
SaveImage
,
"LoadImage"
:
LoadImage
,
"UploadImage"
:
UploadImage
,
"LoadImageMask"
:
LoadImageMask
,
"UploadImageMask"
:
UploadImageMask
,
"ImageScale"
:
ImageScale
,
"ImageInvert"
:
ImageInvert
,
"ConditioningCombine"
:
ConditioningCombine
,
...
...
server.py
View file @
99abc0eb
...
...
@@ -72,7 +72,7 @@ class PromptServer():
@
routes
.
post
(
"/upload/image"
)
async
def
upload_image
(
request
):
upload_dir
=
os
.
path
.
join
(
os
.
path
.
dirname
(
os
.
path
.
realpath
(
__file__
)),
"
uploads
"
)
upload_dir
=
os
.
path
.
join
(
os
.
path
.
dirname
(
os
.
path
.
realpath
(
__file__
)),
"
input
"
)
if
not
os
.
path
.
exists
(
upload_dir
):
os
.
makedirs
(
upload_dir
)
...
...
@@ -85,7 +85,15 @@ class PromptServer():
if
not
filename
:
return
web
.
Response
(
status
=
400
)
with
open
(
os
.
path
.
join
(
upload_dir
,
filename
),
"wb"
)
as
f
:
split
=
os
.
path
.
splitext
(
filename
)
i
=
1
while
os
.
path
.
exists
(
os
.
path
.
join
(
upload_dir
,
filename
)):
filename
=
f
"
{
split
[
0
]
}
(
{
i
}
)
{
split
[
1
]
}
"
i
+=
1
filepath
=
os
.
path
.
join
(
upload_dir
,
filename
)
with
open
(
filepath
,
"wb"
)
as
f
:
f
.
write
(
image
.
file
.
read
())
return
web
.
json_response
({
"name"
:
filename
})
...
...
@@ -97,12 +105,12 @@ class PromptServer():
async
def
view_image
(
request
):
if
"file"
in
request
.
match_info
:
type
=
request
.
rel_url
.
query
.
get
(
"type"
,
"output"
)
if
type
!=
"output"
and
type
!=
"
uploads
"
:
if
type
!=
"output"
and
type
!=
"
input
"
:
return
web
.
Response
(
status
=
400
)
output_dir
=
os
.
path
.
join
(
os
.
path
.
dirname
(
os
.
path
.
realpath
(
__file__
)),
type
)
file
=
request
.
match_info
[
"file"
]
file
=
os
.
path
.
splitext
(
os
.
path
.
basename
(
file
)
)[
0
]
+
".png"
file
=
os
.
path
.
basename
(
file
)
file
=
os
.
path
.
join
(
output_dir
,
file
)
if
os
.
path
.
isfile
(
file
):
return
web
.
FileResponse
(
file
)
...
...
web/extensions/core/uploadImage.js
View file @
99abc0eb
import
{
app
}
from
"
/scripts/app.js
"
;
// Adds an upload button to the nodes
app
.
registerExtension
({
name
:
"
Comfy.UploadImage
"
,
async
beforeRegisterNodeDef
(
nodeType
,
nodeData
,
app
)
{
if
(
nodeData
.
name
===
"
Upl
oadImage
"
||
nodeData
.
name
===
"
Upl
oadImageMask
"
)
{
if
(
nodeData
.
name
===
"
L
oadImage
"
||
nodeData
.
name
===
"
L
oadImageMask
"
)
{
nodeData
.
input
.
required
.
upload
=
[
"
IMAGEUPLOAD
"
];
}
},
...
...
web/scripts/widgets.js
View file @
99abc0eb
...
...
@@ -141,7 +141,7 @@ export const ComfyWidgets = {
node
.
imgs
=
[
img
];
app
.
graph
.
setDirtyCanvas
(
true
);
};
img
.
src
=
`/view/
${
name
}
?type=
uploads
`
;
img
.
src
=
`/view/
${
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