gokaygokay
commited on
Commit
•
7c1d475
1
Parent(s):
00229d2
Update llm_inference.py
Browse files- llm_inference.py +76 -13
llm_inference.py
CHANGED
@@ -49,9 +49,27 @@ class LLMInferenceNode:
|
|
49 |
):
|
50 |
try:
|
51 |
# Define prompts
|
52 |
-
default_long_prompt = """Create a detailed visually descriptive caption of this description,
|
53 |
-
|
54 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
55 |
|
56 |
poster_prompt = """Analyze the provided description and extract key information to create a movie poster style description. Format the output as follows:
|
57 |
Title: A catchy, intriguing title that captures the essence of the scene, place the title in "".
|
@@ -61,15 +79,60 @@ Supporting characters: Describe the supporting characters.
|
|
61 |
Branding type: Describe the branding type.
|
62 |
Tagline: Include a tagline that captures the essence of the movie.
|
63 |
Visual style: Ensure that the visual style fits the branding type and tagline.
|
64 |
-
You are allowed to make up film and branding names, and do them like 80's, 90's or modern movie posters.
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
73 |
|
74 |
prompt_types = {
|
75 |
"Long": default_long_prompt,
|
@@ -109,7 +172,7 @@ You are allowed to make up film and branding names, and do them like 80's, 90's
|
|
109 |
system_message = "You are a helpful assistant. Try your best to give the best response possible to the user."
|
110 |
|
111 |
if input_text.startswith("Create a random prompt based on"):
|
112 |
-
user_message = f"Create a random
|
113 |
else:
|
114 |
user_message = f"{base_prompt}\nDescription: {input_text}"
|
115 |
|
|
|
49 |
):
|
50 |
try:
|
51 |
# Define prompts
|
52 |
+
default_long_prompt = """Create a detailed visually descriptive caption of this description,
|
53 |
+
which will be used as a prompt for a text to image AI system (caption only, no instructions like "create an image").
|
54 |
+
Remove any mention of digital artwork or artwork style. Give detailed visual descriptions of the character(s), including ethnicity, skin tone, expression etc.
|
55 |
+
Imagine using keywords for a still for someone who has aphantasia. Describe the image style, e.g., any photographic or art styles/techniques utilized.
|
56 |
+
Make sure to fully describe all aspects of the cinematography, with abundant technical details and visual descriptions.
|
57 |
+
If there is more than one image, combine the elements and characters from all of the images creatively into a single
|
58 |
+
cohesive composition with a single background, inventing an interaction between the characters.
|
59 |
+
Be creative in combining the characters into a single cohesive scene.
|
60 |
+
Focus on two primary characters (or one) and describe an interesting interaction between them, such as a hug, a kiss, a fight, giving an object,
|
61 |
+
an emotional reaction/interaction. If there is more than one background in the images, pick the most appropriate one.
|
62 |
+
Your output is only the caption itself, no comments or extra formatting.
|
63 |
+
The caption is in a single long paragraph.
|
64 |
+
If you feel the images are inappropriate, invent a new scene/characters inspired by these.
|
65 |
+
Additionally, incorporate a specific movie director's visual style and describe the lighting setup in detail,
|
66 |
+
including the type, color, and placement of light sources to create the desired mood and atmosphere.
|
67 |
+
Always frame the scene, including details about the film grain, color grading, and any artifacts or characteristics specific."""
|
68 |
+
|
69 |
+
default_simple_prompt = """Create a brief, straightforward caption for this description, suitable for a text-to-image AI system.
|
70 |
+
Focus on the main elements, key characters, and overall scene without elaborate details.
|
71 |
+
Provide a clear and concise description in one or two sentences. Your output is only the caption itself, no comments or extra formatting.
|
72 |
+
The caption is in a single long paragraph."""
|
73 |
|
74 |
poster_prompt = """Analyze the provided description and extract key information to create a movie poster style description. Format the output as follows:
|
75 |
Title: A catchy, intriguing title that captures the essence of the scene, place the title in "".
|
|
|
79 |
Branding type: Describe the branding type.
|
80 |
Tagline: Include a tagline that captures the essence of the movie.
|
81 |
Visual style: Ensure that the visual style fits the branding type and tagline.
|
82 |
+
You are allowed to make up film and branding names, and do them like 80's, 90's or modern movie posters.
|
83 |
+
Your output is only the caption itself, no comments or extra formatting. The caption is in a single long paragraph."""
|
84 |
+
|
85 |
+
only_objects_prompt = """Create a highly detailed and visually rich description focusing solely on inanimate objects,
|
86 |
+
without including any human or animal figures. Describe the objects' shapes, sizes, colors, textures, and materials in great detail.
|
87 |
+
Pay attention to their arrangement, positioning, and how they interact with light and shadow. Include information about the setting
|
88 |
+
or environment these objects are in, such as indoor/outdoor, time of day, weather conditions, and any atmospheric effects.
|
89 |
+
Mention any unique features, patterns, or imperfections on the objects. Describe the overall composition, perspective, and
|
90 |
+
any artistic techniques that might be employed to render these objects (e.g., photorealism, impressionistic style, etc.).
|
91 |
+
Your description should paint a vivid picture that allows someone to imagine the scene without seeing it, focusing on the beauty,
|
92 |
+
complexity, or significance of everyday objects. Your output is only the caption itself, no comments or extra formatting.
|
93 |
+
The caption is in a single long paragraph."""
|
94 |
+
|
95 |
+
no_figure_prompt = """Generate a comprehensive and visually evocative description of a scene
|
96 |
+
or landscape without including any human or animal figures. Focus on the environment, natural elements, and man-made structures if present.
|
97 |
+
Describe the topography, vegetation, weather conditions, and time of day in great detail.
|
98 |
+
Pay attention to colors, textures, and how light interacts with different elements of the scene.
|
99 |
+
If there are buildings or other structures, describe their architecture, condition, and how they fit into the landscape.
|
100 |
+
Include sensory details beyond just visual elements - mention sounds, smells, and the overall atmosphere or mood of the scene.
|
101 |
+
Describe any notable features like bodies of water, geological formations, or sky phenomena.
|
102 |
+
Consider the perspective from which the scene is viewed and how this affects the composition.
|
103 |
+
Your description should transport the reader to this location, allowing them to vividly imagine the scene without any living subjects present.
|
104 |
+
Your output is only the caption itself, no comments or extra formatting. The caption is in a single long paragraph."""
|
105 |
+
|
106 |
+
landscape_prompt = """Create an immersive and detailed description of a landscape,
|
107 |
+
focusing on its natural beauty and geographical features.
|
108 |
+
Begin with the overall topography - is it mountainous, coastal, forested, desert, or a combination?
|
109 |
+
Describe the horizon and how land meets sky. Detail the vegetation, noting types of trees, flowers, or grass,
|
110 |
+
and how they're distributed across the landscape. Include information about any water features -
|
111 |
+
rivers, lakes, oceans - and how they interact with the land. Describe the sky, including cloud formations,
|
112 |
+
color gradients, and any celestial bodies visible.
|
113 |
+
Pay attention to the quality of light, time of day, and season, explaining how these factors affect the colors and shadows in the scene.
|
114 |
+
Include details about weather conditions and how they impact the landscape.
|
115 |
+
Mention any geological features like rock formations, cliffs, or unique land patterns.
|
116 |
+
If there are any distant man-made elements, describe how they integrate with the natural setting.
|
117 |
+
Your description should capture the grandeur and mood of the landscape,
|
118 |
+
allowing the reader to feel as if they're standing within this awe-inspiring natural scene.
|
119 |
+
Your output is only the caption itself, no comments or extra formatting. The caption is in a single long paragraph."""
|
120 |
+
|
121 |
+
fantasy_prompt = """Craft an extraordinarily detailed and imaginative description of a fantasy scene,
|
122 |
+
blending elements of magic, otherworldly creatures, and fantastical environments. Begin by setting the overall tone -
|
123 |
+
is this a dark and foreboding realm, a whimsical fairytale setting, or an epic high-fantasy world?
|
124 |
+
Describe the landscape, including any impossible or magical geographical features like floating islands,
|
125 |
+
crystal forests, or rivers of starlight. Detail the flora and fauna,
|
126 |
+
focusing on fantastical plants and creatures that don't exist in our world.
|
127 |
+
Include descriptions of any structures or ruins, emphasizing their otherworldly architecture and magical properties.
|
128 |
+
Describe the sky and any celestial bodies, considering how they might differ from our reality.
|
129 |
+
Include details about the presence of magic - how it manifests visually,
|
130 |
+
its effects on the environment, and any magical phenomena occurring in the scene.
|
131 |
+
If there are characters present, describe their appearance, focusing on non-human features, magical auras, or
|
132 |
+
fantastical clothing and accessories. Pay attention to colors, textures, and light sources,
|
133 |
+
especially those that couldn't exist in the real world. Your description should transport the
|
134 |
+
reader to a realm of pure imagination, where the laws of physics and nature as we know them don't apply.
|
135 |
+
Your output is only the caption itself, no comments or extra formatting. The caption is in a single long paragraph."""
|
136 |
|
137 |
prompt_types = {
|
138 |
"Long": default_long_prompt,
|
|
|
172 |
system_message = "You are a helpful assistant. Try your best to give the best response possible to the user."
|
173 |
|
174 |
if input_text.startswith("Create a random prompt based on"):
|
175 |
+
user_message = f"Create a random description based on this\nInstructions: {base_prompt}"
|
176 |
else:
|
177 |
user_message = f"{base_prompt}\nDescription: {input_text}"
|
178 |
|