save clipspace files to input/clipspace instead of temp

This commit is contained in:
Lt.Dr.Data 2023-05-02 15:32:39 +09:00
parent 8c8bedbaf2
commit 3a28a28000
6 changed files with 25 additions and 8 deletions

View File

@ -57,6 +57,10 @@ def get_input_directory():
global input_directory global input_directory
return input_directory return input_directory
def get_clipspace_directory():
global input_directory
return input_directory+"/clipspace"
#NOTE: used in http server so don't put folders that should not be accessed remotely #NOTE: used in http server so don't put folders that should not be accessed remotely
def get_directory_by_type(type_name): def get_directory_by_type(type_name):
@ -66,6 +70,8 @@ def get_directory_by_type(type_name):
return get_temp_directory() return get_temp_directory()
if type_name == "input": if type_name == "input":
return get_input_directory() return get_input_directory()
if type_name == "clipspace":
return get_clipspace_directory()
return None return None
@ -81,6 +87,9 @@ def annotated_filepath(name):
elif name.endswith("[temp]"): elif name.endswith("[temp]"):
base_dir = get_temp_directory() base_dir = get_temp_directory()
name = name[:-7] name = name[:-7]
elif name.endswith("[clipspace]"):
base_dir = get_clipspace_directory()
name = name[:-12]
else: else:
return name, None return name, None

View File

@ -970,8 +970,9 @@ class LoadImage:
@classmethod @classmethod
def INPUT_TYPES(s): def INPUT_TYPES(s):
input_dir = folder_paths.get_input_directory() input_dir = folder_paths.get_input_directory()
input_dir = [f for f in os.listdir(input_dir) if os.path.isfile(os.path.join(input_dir, f))]
return {"required": return {"required":
{"image": (sorted(os.listdir(input_dir)), )}, {"image": (sorted(input_dir), )},
} }
CATEGORY = "image" CATEGORY = "image"

View File

@ -118,6 +118,8 @@ class PromptServer():
type_dir = folder_paths.get_input_directory() type_dir = folder_paths.get_input_directory()
elif dir_type == "input": elif dir_type == "input":
type_dir = folder_paths.get_input_directory() type_dir = folder_paths.get_input_directory()
elif dir_type == "clipspace":
type_dir = folder_paths.get_clipspace_directory()
elif dir_type == "temp": elif dir_type == "temp":
type_dir = folder_paths.get_temp_directory() type_dir = folder_paths.get_temp_directory()
elif dir_type == "output": elif dir_type == "output":

View File

@ -118,8 +118,7 @@ export class ClipspaceDialog extends ComfyDialog {
]); ]);
const td = $el("td", {align:'center', width:'100px', height:'100px', colSpan:'2'}, const td = $el("td", {align:'center', width:'100px', height:'100px', colSpan:'2'},
[ $el("img",{id:"clipspace_preview"},[]) ] [ $el("img",{id:"clipspace_preview", ondragstart:() => false},[]) ]);
);
const row3 = const row3 =
$el("tr", {}, [td]); $el("tr", {}, [td]);
@ -133,7 +132,7 @@ export class ClipspaceDialog extends ComfyDialog {
createImgPreview() { createImgPreview() {
if(ComfyApp.clipspace.imgs) { if(ComfyApp.clipspace.imgs) {
return $el("img",{id:"clipspace_preview"}); return $el("img",{id:"clipspace_preview", ondragstart:() => false});
} }
else else
return []; return [];

View File

@ -42,7 +42,9 @@ async function uploadMask(filepath, formData) {
ComfyApp.clipspace.imgs[ComfyApp.clipspace['selectedIndex']] = new Image(); ComfyApp.clipspace.imgs[ComfyApp.clipspace['selectedIndex']] = new Image();
ComfyApp.clipspace.imgs[ComfyApp.clipspace['selectedIndex']].src = `view?filename=${filepath.filename}&type=${filepath.type}`; ComfyApp.clipspace.imgs[ComfyApp.clipspace['selectedIndex']].src = `view?filename=${filepath.filename}&type=${filepath.type}`;
ComfyApp.clipspace.images[ComfyApp.clipspace['selectedIndex']] = filepath;
if(ComfyApp.clipspace.images)
ComfyApp.clipspace.images[ComfyApp.clipspace['selectedIndex']] = filepath;
ClipspaceDialog.invalidatePreview(); ClipspaceDialog.invalidatePreview();
} }
@ -527,7 +529,7 @@ class MaskEditorDialog extends ComfyDialog {
{ {
"filename": filename, "filename": filename,
"subfolder": "", "subfolder": "",
"type": "temp", "type": "clipspace",
}; };
if(ComfyApp.clipspace.images) if(ComfyApp.clipspace.images)
@ -547,7 +549,7 @@ class MaskEditorDialog extends ComfyDialog {
formData.append('image', blob, filename); formData.append('image', blob, filename);
formData.append('original_image', original_blob); formData.append('original_image', original_blob);
formData.append('type', "temp"); formData.append('type', "clipspace");
uploadMask(item, formData); uploadMask(item, formData);
this.close(); this.close();

View File

@ -219,7 +219,11 @@ export class ComfyApp {
else if(ComfyApp.clipspace.widgets) { else if(ComfyApp.clipspace.widgets) {
const index_in_clip = ComfyApp.clipspace.widgets.findIndex(obj => obj.name === 'image'); const index_in_clip = ComfyApp.clipspace.widgets.findIndex(obj => obj.name === 'image');
if(index_in_clip >= 0) { if(index_in_clip >= 0) {
filename = `${ComfyApp.clipspace.widgets[index_in_clip].value}`; const item = ComfyApp.clipspace.widgets[index_in_clip].value;
if(item.type)
filename = `${item.filename} [${item.type}]`;
else
filename = item.filename;
} }
} }