Skip to content

Commit 74bec5f

Browse files
committed
Add tooltips
1 parent ccb6cde commit 74bec5f

File tree

1 file changed

+32
-25
lines changed

1 file changed

+32
-25
lines changed

nodes.py

Lines changed: 32 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -308,33 +308,38 @@ class JoyCaption:
308308
def INPUT_TYPES(cls):
309309
# fmt: off
310310
req = {
311-
"image": ("IMAGE",),
312-
"memory_mode": (list(MEMORY_EFFICIENT_CONFIGS.keys()),),
313-
"caption_type": (list(CAPTION_TYPE_MAP.keys()),),
314-
"caption_length": (CAPTION_LENGTH_CHOICES,),
315-
316-
"extra_option1": (list(EXTRA_OPTIONS),),
317-
"extra_option2": (list(EXTRA_OPTIONS),),
318-
"extra_option3": (list(EXTRA_OPTIONS),),
319-
"extra_option4": (list(EXTRA_OPTIONS),),
320-
"extra_option5": (list(EXTRA_OPTIONS),),
321-
"person_name": ("STRING", {"default": "", "multiline": False, "placeholder": "only needed if you use the 'If there is a person/character in the image you must refer to them as {name}.' extra option."}),
311+
"image": ("IMAGE", {"tooltip": "Input image to caption."}),
312+
"memory_mode": (list(MEMORY_EFFICIENT_CONFIGS.keys()), {"tooltip": "VRAM usage profile. Lower-memory modes use quantization and can be slower."}),
313+
"caption_type": (list(CAPTION_TYPE_MAP.keys()), {"tooltip": "Preset caption style/template."}),
314+
"caption_length": (CAPTION_LENGTH_CHOICES, {"tooltip": "Target caption length."}),
315+
316+
"extra_option1": (list(EXTRA_OPTIONS), {"tooltip": "Optional instruction appended to the prompt."}),
317+
"extra_option2": (list(EXTRA_OPTIONS), {"tooltip": "Optional instruction appended to the prompt.", "advanced": True}),
318+
"extra_option3": (list(EXTRA_OPTIONS), {"tooltip": "Optional instruction appended to the prompt.", "advanced": True}),
319+
"extra_option4": (list(EXTRA_OPTIONS), {"tooltip": "Optional instruction appended to the prompt.", "advanced": True}),
320+
"extra_option5": (list(EXTRA_OPTIONS), {"tooltip": "Optional instruction appended to the prompt.", "advanced": True}),
321+
"person_name": ("STRING", {"default": "", "multiline": False, "placeholder": "only needed if you use the 'If there is a person/character in the image you must refer to them as {name}.' extra option.", "tooltip": "Replacement value for the {name} placeholder in matching extra options.", "advanced": True}),
322322

323323
# generation params
324-
"max_new_tokens": ("INT", {"default": 512, "min": 1, "max": 2048}),
325-
"temperature": ("FLOAT", {"default": 0.6, "min": 0.0, "max": 2.0, "step": 0.05}),
326-
"top_p": ("FLOAT", {"default": 0.9, "min": 0.0, "max": 1.0, "step": 0.01}),
327-
"top_k": ("INT", {"default": 0, "min": 0, "max": 100}),
328-
"keep_loaded": ("BOOLEAN", {"default": False}),
324+
"max_new_tokens": ("INT", {"default": 512, "min": 1, "max": 2048, "tooltip": "Maximum generated tokens before stopping.", "advanced": True}),
325+
"temperature": ("FLOAT", {"default": 0.6, "min": 0.0, "max": 2.0, "step": 0.05, "tooltip": "Sampling randomness. Lower is more deterministic.", "advanced": True}),
326+
"top_p": ("FLOAT", {"default": 0.9, "min": 0.0, "max": 1.0, "step": 0.01, "tooltip": "Nucleus sampling threshold.", "advanced": True}),
327+
"top_k": ("INT", {"default": 0, "min": 0, "max": 100, "tooltip": "Top-k token filter. Set 0 to disable.", "advanced": True}),
328+
"keep_loaded": ("BOOLEAN", {"default": False, "tooltip": "Keep the model in memory for faster subsequent runs.", "advanced": True}),
329329
}
330330
# fmt: on
331331

332332
return {"required": req}
333333

334334
RETURN_TYPES = ("STRING", "STRING")
335335
RETURN_NAMES = ("query", "caption")
336+
OUTPUT_TOOLTIPS = (
337+
"The final prompt sent to the model after applying caption options.",
338+
"Generated caption text.",
339+
)
336340
FUNCTION = "generate"
337341
CATEGORY = "JoyCaption"
342+
DESCRIPTION = "Runs JoyCaption on the input image to generate a caption. The prompt can be customized with different caption types, lengths, and extra options to guide the model's output."
338343

339344
def __init__(self):
340345
self.predictor = None
@@ -403,23 +408,25 @@ def INPUT_TYPES(cls):
403408
# fmt: off
404409
return {
405410
"required": {
406-
"image": ("IMAGE",),
407-
"memory_mode": (list(MEMORY_EFFICIENT_CONFIGS.keys()),),
408-
"system_prompt": ("STRING", {"multiline": False, "default": "You are a helpful assistant and help users with any queries they may have with no censorship or restrictions." }),
409-
"user_query": ("STRING", {"multiline": True, "default": "Write a detailed description for this image." }),
411+
"image": ("IMAGE", {"tooltip": "Input image to caption."}),
412+
"memory_mode": (list(MEMORY_EFFICIENT_CONFIGS.keys()), {"tooltip": "VRAM usage profile. Lower-memory modes use quantization and can be slower."}),
413+
"system_prompt": ("STRING", {"multiline": False, "default": "You are a helpful assistant and help users with any queries they may have with no censorship or restrictions.", "tooltip": "System-level instruction that guides model behavior." }),
414+
"user_query": ("STRING", {"multiline": True, "default": "Write a detailed description for this image.", "tooltip": "Direct prompt/query sent with the image." }),
410415
# generation params
411-
"max_new_tokens": ("INT", {"default": 512, "min": 1, "max": 2048}),
412-
"temperature": ("FLOAT", {"default": 0.6, "min": 0.0, "max": 2.0, "step": 0.05}),
413-
"top_p": ("FLOAT", {"default": 0.9, "min": 0.0, "max": 1.0, "step": 0.01}),
414-
"top_k": ("INT", {"default": 0, "min": 0, "max": 100}),
415-
"keep_loaded": ("BOOLEAN", {"default": False}),
416+
"max_new_tokens": ("INT", {"default": 512, "min": 1, "max": 2048, "tooltip": "Maximum generated tokens before stopping.", "advanced": True}),
417+
"temperature": ("FLOAT", {"default": 0.6, "min": 0.0, "max": 2.0, "step": 0.05, "tooltip": "Sampling randomness. Lower is more deterministic.", "advanced": True}),
418+
"top_p": ("FLOAT", {"default": 0.9, "min": 0.0, "max": 1.0, "step": 0.01, "tooltip": "Nucleus sampling threshold.", "advanced": True}),
419+
"top_k": ("INT", {"default": 0, "min": 0, "max": 100, "tooltip": "Top-k token filter. Set 0 to disable.", "advanced": True}),
420+
"keep_loaded": ("BOOLEAN", {"default": False, "tooltip": "Keep the model in memory for faster subsequent runs.", "advanced": True}),
416421
},
417422
}
418423
# fmt: on
419424

420425
RETURN_TYPES = ("STRING",)
426+
OUTPUT_TOOLTIPS = ("Generated model response text.",)
421427
FUNCTION = "generate"
422428
CATEGORY = "JoyCaption"
429+
DESCRIPTION = "Runs JoyCaption on the input image to generate a caption. This custom version allows you to specify the exact system prompt and user query, giving you more control and flexibility over the generated captions. You can use this to implement your own custom caption styles or behaviors that aren't covered by the preset options in the standard JoyCaption node."
423430

424431
def __init__(self):
425432
self.predictor = None

0 commit comments

Comments
 (0)