You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# From (https://github.com/gokayfem/ComfyUI_VLM_nodes/blob/1ca496c1c8e8ada94d7d2644b8a7d4b3dc9729b3/nodes/qwen2vl.py)
10
+
# Apache 2.0 License
11
+
MEMORY_EFFICIENT_CONFIGS= {
12
+
"Default": {},
13
+
"Balanced (8-bit)": {
14
+
"load_in_8bit": True,
15
+
},
16
+
"Maximum Savings (4-bit)": {
17
+
"load_in_4bit": True,
18
+
"bnb_4bit_quant_type": "nf4",
19
+
"bnb_4bit_compute_dtype": torch.bfloat16,
20
+
"bnb_4bit_use_double_quant": True,
21
+
},
22
+
}
23
+
24
+
25
+
CAPTION_TYPE_MAP= {
26
+
"Descriptive": [
27
+
"Write a detailed description for this image.",
28
+
"Write a detailed description for this image in {word_count} words or less.",
29
+
"Write a {length} detailed description for this image.",
30
+
],
31
+
"Descriptive (Casual)": [
32
+
"Write a descriptive caption for this image in a casual tone.",
33
+
"Write a descriptive caption for this image in a casual tone within {word_count} words.",
34
+
"Write a {length} descriptive caption for this image in a casual tone.",
35
+
],
36
+
"Straightforward": [
37
+
"Write a straightforward caption for this image. Begin with the main subject and medium. Mention pivotal elements—people, objects, scenery—using confident, definite language. Focus on concrete details like color, shape, texture, and spatial relationships. Show how elements interact. Omit mood and speculative wording. If text is present, quote it exactly. Note any watermarks, signatures, or compression artifacts. Never mention what's absent, resolution, or unobservable details. Vary your sentence structure and keep the description concise, without starting with “This image is…” or similar phrasing.",
38
+
"Write a straightforward caption for this image within {word_count} words. Begin with the main subject and medium. Mention pivotal elements—people, objects, scenery—using confident, definite language. Focus on concrete details like color, shape, texture, and spatial relationships. Show how elements interact. Omit mood and speculative wording. If text is present, quote it exactly. Note any watermarks, signatures, or compression artifacts. Never mention what's absent, resolution, or unobservable details. Vary your sentence structure and keep the description concise, without starting with “This image is…” or similar phrasing.",
39
+
"Write a {length} straightforward caption for this image. Begin with the main subject and medium. Mention pivotal elements—people, objects, scenery—using confident, definite language. Focus on concrete details like color, shape, texture, and spatial relationships. Show how elements interact. Omit mood and speculative wording. If text is present, quote it exactly. Note any watermarks, signatures, or compression artifacts. Never mention what's absent, resolution, or unobservable details. Vary your sentence structure and keep the description concise, without starting with “This image is…” or similar phrasing.",
40
+
],
41
+
"Stable Diffusion Prompt": [
42
+
"Output a stable diffusion prompt that is indistinguishable from a real stable diffusion prompt.",
43
+
"Output a stable diffusion prompt that is indistinguishable from a real stable diffusion prompt. {word_count} words or less.",
44
+
"Output a {length} stable diffusion prompt that is indistinguishable from a real stable diffusion prompt.",
45
+
],
46
+
"MidJourney": [
47
+
"Write a MidJourney prompt for this image.",
48
+
"Write a MidJourney prompt for this image within {word_count} words.",
49
+
"Write a {length} MidJourney prompt for this image.",
50
+
],
51
+
"Danbooru tag list": [
52
+
"Generate only comma-separated Danbooru tags (lowercase_underscores). Strict order: `artist:`, `copyright:`, `character:`, `meta:`, then general tags. Include counts (1girl), appearance, clothing, accessories, pose, expression, actions, background. Use precise Danbooru syntax. No extra text.",
53
+
"Generate only comma-separated Danbooru tags (lowercase_underscores). Strict order: `artist:`, `copyright:`, `character:`, `meta:`, then general tags. Include counts (1girl), appearance, clothing, accessories, pose, expression, actions, background. Use precise Danbooru syntax. No extra text. {word_count} words or less.",
54
+
"Generate only comma-separated Danbooru tags (lowercase_underscores). Strict order: `artist:`, `copyright:`, `character:`, `meta:`, then general tags. Include counts (1girl), appearance, clothing, accessories, pose, expression, actions, background. Use precise Danbooru syntax. No extra text. {length} length.",
55
+
],
56
+
"e621 tag list": [
57
+
"Write a comma-separated list of e621 tags in alphabetical order for this image. Start with the artist, copyright, character, species, meta, and lore tags (if any), prefixed by 'artist:', 'copyright:', 'character:', 'species:', 'meta:', and 'lore:'. Then all the general tags.",
58
+
"Write a comma-separated list of e621 tags in alphabetical order for this image. Start with the artist, copyright, character, species, meta, and lore tags (if any), prefixed by 'artist:', 'copyright:', 'character:', 'species:', 'meta:', and 'lore:'. Then all the general tags. Keep it under {word_count} words.",
59
+
"Write a {length} comma-separated list of e621 tags in alphabetical order for this image. Start with the artist, copyright, character, species, meta, and lore tags (if any), prefixed by 'artist:', 'copyright:', 'character:', 'species:', 'meta:', and 'lore:'. Then all the general tags.",
60
+
],
61
+
"Rule34 tag list": [
62
+
"Write a comma-separated list of rule34 tags in alphabetical order for this image. Start with the artist, copyright, character, and meta tags (if any), prefixed by 'artist:', 'copyright:', 'character:', and 'meta:'. Then all the general tags.",
63
+
"Write a comma-separated list of rule34 tags in alphabetical order for this image. Start with the artist, copyright, character, and meta tags (if any), prefixed by 'artist:', 'copyright:', 'character:', and 'meta:'. Then all the general tags. Keep it under {word_count} words.",
64
+
"Write a {length} comma-separated list of rule34 tags in alphabetical order for this image. Start with the artist, copyright, character, and meta tags (if any), prefixed by 'artist:', 'copyright:', 'character:', and 'meta:'. Then all the general tags.",
65
+
],
66
+
"Booru-like tag list": [
67
+
"Write a list of Booru-like tags for this image.",
68
+
"Write a list of Booru-like tags for this image within {word_count} words.",
69
+
"Write a {length} list of Booru-like tags for this image.",
70
+
],
71
+
"Art Critic": [
72
+
"Analyze this image like an art critic would with information about its composition, style, symbolism, the use of color, light, any artistic movement it might belong to, etc.",
73
+
"Analyze this image like an art critic would with information about its composition, style, symbolism, the use of color, light, any artistic movement it might belong to, etc. Keep it within {word_count} words.",
74
+
"Analyze this image like an art critic would with information about its composition, style, symbolism, the use of color, light, any artistic movement it might belong to, etc. Keep it {length}.",
75
+
],
76
+
"Product Listing": [
77
+
"Write a caption for this image as though it were a product listing.",
78
+
"Write a caption for this image as though it were a product listing. Keep it under {word_count} words.",
79
+
"Write a {length} caption for this image as though it were a product listing.",
80
+
],
81
+
"Social Media Post": [
82
+
"Write a caption for this image as if it were being used for a social media post.",
83
+
"Write a caption for this image as if it were being used for a social media post. Limit the caption to {word_count} words.",
84
+
"Write a {length} caption for this image as if it were being used for a social media post.",
85
+
],
86
+
}
87
+
88
+
EXTRA_OPTIONS= [
89
+
"",
90
+
"If there is a person/character in the image you must refer to them as {name}.",
91
+
"Do NOT include information about people/characters that cannot be changed (like ethnicity, gender, etc), but do still include changeable attributes (like hair style).",
92
+
"Include information about lighting.",
93
+
"Include information about camera angle.",
94
+
"Include information about whether there is a watermark or not.",
95
+
"Include information about whether there are JPEG artifacts or not.",
96
+
"If it is a photo you MUST include information about what camera was likely used and details such as aperture, shutter speed, ISO, etc.",
97
+
"Do NOT include anything sexual; keep it PG.",
98
+
"Do NOT mention the image's resolution.",
99
+
"You MUST include information about the subjective aesthetic quality of the image from low to very high.",
100
+
"Include information on the image's composition style, such as leading lines, rule of thirds, or symmetry.",
101
+
"Do NOT mention any text that is in the image.",
102
+
"Specify the depth of field and whether the background is in focus or blurred.",
103
+
"If applicable, mention the likely use of artificial or natural lighting sources.",
104
+
"Do NOT use any ambiguous language.",
105
+
"Include whether the image is sfw, suggestive, or nsfw.",
106
+
"ONLY describe the most important elements of the image.",
107
+
"If it is a work of art, do not include the artist's name or the title of the work.",
108
+
"Identify the image orientation (portrait, landscape, or square) and aspect ratio if obvious.",
109
+
"""Use vulgar slang and profanity, such as (but not limited to) "fucking," "slut," "cock," etc.""",
110
+
"Do NOT use polite euphemisms—lean into blunt, casual phrasing.",
111
+
"Include information about the ages of any people/characters when applicable.",
112
+
"Mention whether the image depicts an extreme close-up, close-up, medium close-up, medium shot, cowboy shot, medium wide shot, wide shot, or extreme wide shot.",
113
+
"Do not mention the mood/feeling/etc of the image.",
"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."}),
"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." }),
291
+
"user_query": ("STRING", {"multiline": True, "default": "Write a detailed description for this image." }),
0 commit comments