Add simple image submit
This commit is contained in:
+33
-44
@@ -129,54 +129,14 @@ configs = RemoteLoader("configs", "https://api.aiart.doubtech.com/comfyui/config
|
||||
|
||||
|
||||
class SubmitImage:
|
||||
"""
|
||||
A example node
|
||||
|
||||
Class methods
|
||||
-------------
|
||||
INPUT_TYPES (dict):
|
||||
Tell the main program input parameters of nodes.
|
||||
|
||||
Attributes
|
||||
----------
|
||||
RETURN_TYPES (`tuple`):
|
||||
The type of each element in the output tulple.
|
||||
RETURN_NAMES (`tuple`):
|
||||
Optional: The name of each output in the output tulple.
|
||||
FUNCTION (`str`):
|
||||
The name of the entry-point method. For example, if `FUNCTION = "execute"` then it will run Example().execute()
|
||||
OUTPUT_NODE ([`bool`]):
|
||||
If this node is an output node that outputs a result/image from the graph. The SaveImage node is an example.
|
||||
The backend iterates on these output nodes and tries to execute all their parents if their parent graph is properly connected.
|
||||
Assumed to be False if not present.
|
||||
CATEGORY (`str`):
|
||||
The category the node should appear in the UI.
|
||||
execute(s) -> tuple || None:
|
||||
The entry point method. The name of this method must be the same as the value of property `FUNCTION`.
|
||||
For example, if `FUNCTION = "execute"` then this method's name must be `execute`, if `FUNCTION = "foo"` then it must be `foo`.
|
||||
"""
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(s):
|
||||
"""
|
||||
Return a dictionary which contains config for all input fields.
|
||||
Some types (string): "MODEL", "VAE", "CLIP", "CONDITIONING", "LATENT", "IMAGE", "INT", "STRING", "FLOAT".
|
||||
Input types "INT", "STRING" or "FLOAT" are special values for fields on the node.
|
||||
The type can be a list for selection.
|
||||
|
||||
Returns: `dict`:
|
||||
- Key input_fields_group (`string`): Can be either required, hidden or optional. A node class must have property `required`
|
||||
- Value input_fields (`dict`): Contains input fields config:
|
||||
* Key field_name (`string`): Name of a entry-point method's argument
|
||||
* Value field_config (`tuple`):
|
||||
+ First value is a string indicate the type of field or a list for selection.
|
||||
+ Secound value is a config for type "INT", "STRING" or "FLOAT".
|
||||
"""
|
||||
return {
|
||||
"required": {
|
||||
"images": ("IMAGE",),
|
||||
"image": ("IMAGE",),
|
||||
},
|
||||
"optional": {
|
||||
"prompt_text": ("STRING", {
|
||||
@@ -211,7 +171,6 @@ class SubmitImage:
|
||||
}
|
||||
|
||||
RETURN_TYPES = ()
|
||||
#RETURN_NAMES = ("image_output_name",)
|
||||
|
||||
FUNCTION = "upload"
|
||||
|
||||
@@ -244,7 +203,7 @@ class SubmitImage:
|
||||
return None
|
||||
|
||||
|
||||
def upload(self, images, prompt_text, tags, title, alt, caption, set, private, prompt=None, extra_pnginfo=None):
|
||||
def upload(self, image, prompt_text, tags, title, alt, caption, set, private, prompt=None, extra_pnginfo=None):
|
||||
print("uploading image...")
|
||||
|
||||
if variables.generated_prompt is not None:
|
||||
@@ -280,6 +239,7 @@ class SubmitImage:
|
||||
|
||||
print(f"Submitting {prompt_text} with data:\n{prompt}")
|
||||
|
||||
images = image
|
||||
#iterate over the images
|
||||
for image in images:
|
||||
# Convert the image to a png
|
||||
@@ -322,6 +282,33 @@ class SubmitImage:
|
||||
|
||||
return ()
|
||||
|
||||
class DTSimpleSubmitImage(SubmitImage):
|
||||
@classmethod
|
||||
def INPUT_TYPES(s):
|
||||
return {
|
||||
"required": {
|
||||
"image": ("IMAGE",),
|
||||
},
|
||||
"hidden": {"prompt": "PROMPT", "extra_pnginfo": "EXTRA_PNGINFO"},
|
||||
}
|
||||
|
||||
CATEGORY = "DoubTech/Image"
|
||||
|
||||
OUTPUT_NODE = True
|
||||
|
||||
def submit(self, image, prompt=None, extra_pnginfo=None):
|
||||
return super().upload(
|
||||
image,
|
||||
prompt_text=variables.state["prompt"],
|
||||
tags=variables.state["tags"],
|
||||
title=variables.state["title"],
|
||||
alt=variables.state["alt"],
|
||||
caption=variables.state["caption"],
|
||||
set=variables.state["set"],
|
||||
private=variables.state["private"],
|
||||
prompt=prompt,
|
||||
extra_pnginfo=extra_pnginfo,
|
||||
)
|
||||
|
||||
class DTNodeCheckpointLoader:
|
||||
@classmethod
|
||||
@@ -682,6 +669,7 @@ class DTUpscaleModelLoader:
|
||||
# NOTE: names should be globally unique
|
||||
NODE_CLASS_MAPPINGS = {
|
||||
"DTSubmitImage": SubmitImage,
|
||||
"DTSimpleSubmitImage": DTSimpleSubmitImage,
|
||||
"DTCheckpointLoaderSimple": DTNodeCheckpointLoader,
|
||||
"DTVAELoader": DTVAELoader,
|
||||
"DTLoraLoader": DTLoraLoader,
|
||||
@@ -702,7 +690,8 @@ NODE_CLASS_MAPPINGS = {
|
||||
|
||||
# A dictionary that contains the friendly/humanly readable titles for the nodes
|
||||
NODE_DISPLAY_NAME_MAPPINGS = {
|
||||
"DTSubmitImage": "Submit Image",
|
||||
"DTSubmitImage": "Submit Image (Parameters)",
|
||||
"DTSimpleSubmitImage": "Submit Image",
|
||||
"DTCheckpointLoader": "Load Checkpoint (With Config - Online)",
|
||||
"DTCheckpointLoaderSimple": "Load Checkpoint (Online)",
|
||||
"DTVAELoader": "Load VAE (Online)",
|
||||
|
||||
Reference in New Issue
Block a user