gokaygokay commited on
Commit
868c4e3
1 Parent(s): 4dc15e0
Files changed (2) hide show
  1. huggingface_inference_node.py +21 -5
  2. ui_components.py +4 -3
huggingface_inference_node.py CHANGED
@@ -28,7 +28,7 @@ class HuggingFaceInferenceNode:
28
 
29
  print(f"Prompt saved to {filename}")
30
 
31
- def generate(self, input_text, happy_talk, compress, compression_level, poster, custom_base_prompt=""):
32
  try:
33
  default_happy_prompt = """Create a detailed visually descriptive caption of this description, which will be used as a prompt for a text to image AI system (caption only, no instructions like "create an image").Remove any mention of digital artwork or artwork style. Give detailed visual descriptions of the character(s), including ethnicity, skin tone, expression etc. Imagine using keywords for a still for someone who has aphantasia. Describe the image style, e.g. any photographic or art styles / techniques utilized. Make sure to fully describe all aspects of the cinematography, with abundant technical details and visual descriptions. If there is more than one image, combine the elements and characters from all of the images creatively into a single cohesive composition with a single background, inventing an interaction between the characters. Be creative in combining the characters into a single cohesive scene. 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, an emotional reaction / interaction. If there is more than one background in the images, pick the most appropriate one. Your output is only the caption itself, no comments or extra formatting. The caption is in a single long paragraph. If you feel the images are inappropriate, invent a new scene / characters inspired by these. Additionally, incorporate a specific movie director's visual style and describe the lighting setup in detail, including the type, color, and placement of light sources to create the desired mood and atmosphere. Always frame the scene, including details about the film grain, color grading, and any artifacts or characteristics specific."""
34
 
@@ -44,12 +44,28 @@ Tagline: Include a tagline that captures the essence of the movie.
44
  Visual style: Ensure that the visual style fits the branding type and tagline.
45
  You are allowed to make up film and branding names, and do them like 80's, 90's or modern movie posters."""
46
 
47
- if poster:
48
- base_prompt = poster_prompt
49
- elif custom_base_prompt.strip():
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
50
  base_prompt = custom_base_prompt
51
  else:
52
- base_prompt = default_happy_prompt if happy_talk else default_simple_prompt
53
 
54
  if compress and not poster:
55
  compression_chars = {
 
28
 
29
  print(f"Prompt saved to {filename}")
30
 
31
+ def generate(self, input_text, happy_talk, compress, compression_level, poster, prompt_type, custom_base_prompt=""):
32
  try:
33
  default_happy_prompt = """Create a detailed visually descriptive caption of this description, which will be used as a prompt for a text to image AI system (caption only, no instructions like "create an image").Remove any mention of digital artwork or artwork style. Give detailed visual descriptions of the character(s), including ethnicity, skin tone, expression etc. Imagine using keywords for a still for someone who has aphantasia. Describe the image style, e.g. any photographic or art styles / techniques utilized. Make sure to fully describe all aspects of the cinematography, with abundant technical details and visual descriptions. If there is more than one image, combine the elements and characters from all of the images creatively into a single cohesive composition with a single background, inventing an interaction between the characters. Be creative in combining the characters into a single cohesive scene. 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, an emotional reaction / interaction. If there is more than one background in the images, pick the most appropriate one. Your output is only the caption itself, no comments or extra formatting. The caption is in a single long paragraph. If you feel the images are inappropriate, invent a new scene / characters inspired by these. Additionally, incorporate a specific movie director's visual style and describe the lighting setup in detail, including the type, color, and placement of light sources to create the desired mood and atmosphere. Always frame the scene, including details about the film grain, color grading, and any artifacts or characteristics specific."""
34
 
 
44
  Visual style: Ensure that the visual style fits the branding type and tagline.
45
  You are allowed to make up film and branding names, and do them like 80's, 90's or modern movie posters."""
46
 
47
+ only_objects_prompt = """Create a highly detailed and visually rich description focusing solely on inanimate objects, without including any human or animal figures. Describe the objects' shapes, sizes, colors, textures, and materials in great detail. Pay attention to their arrangement, positioning, and how they interact with light and shadow. Include information about the setting or environment these objects are in, such as indoor/outdoor, time of day, weather conditions, and any atmospheric effects. Mention any unique features, patterns, or imperfections on the objects. Describe the overall composition, perspective, and any artistic techniques that might be employed to render these objects (e.g., photorealism, impressionistic style, etc.). Your description should paint a vivid picture that allows someone to imagine the scene without seeing it, focusing on the beauty, complexity, or significance of everyday objects."""
48
+
49
+ no_figure_prompt = """Generate a comprehensive and visually evocative description of a scene or landscape without including any human or animal figures. Focus on the environment, natural elements, and man-made structures if present. Describe the topography, vegetation, weather conditions, and time of day in great detail. Pay attention to colors, textures, and how light interacts with different elements of the scene. If there are buildings or other structures, describe their architecture, condition, and how they fit into the landscape. Include sensory details beyond just visual elements - mention sounds, smells, and the overall atmosphere or mood of the scene. Describe any notable features like bodies of water, geological formations, or sky phenomena. Consider the perspective from which the scene is viewed and how this affects the composition. Your description should transport the reader to this location, allowing them to vividly imagine the scene without any living subjects present."""
50
+
51
+ landscape_prompt = """Create an immersive and detailed description of a landscape, focusing on its natural beauty and geographical features. Begin with the overall topography - is it mountainous, coastal, forested, desert, or a combination? Describe the horizon and how land meets sky. Detail the vegetation, noting types of trees, flowers, or grass, and how they're distributed across the landscape. Include information about any water features - rivers, lakes, oceans - and how they interact with the land. Describe the sky, including cloud formations, color gradients, and any celestial bodies visible. Pay attention to the quality of light, time of day, and season, explaining how these factors affect the colors and shadows in the scene. Include details about weather conditions and how they impact the landscape. Mention any geological features like rock formations, cliffs, or unique land patterns. If there are any distant man-made elements, describe how they integrate with the natural setting. Your description should capture the grandeur and mood of the landscape, allowing the reader to feel as if they're standing within this awe-inspiring natural scene."""
52
+
53
+ fantasy_prompt = """Craft an extraordinarily detailed and imaginative description of a fantasy scene, blending elements of magic, otherworldly creatures, and fantastical environments. Begin by setting the overall tone - is this a dark and foreboding realm, a whimsical fairytale setting, or an epic high-fantasy world? Describe the landscape, including any impossible or magical geographical features like floating islands, crystal forests, or rivers of starlight. Detail the flora and fauna, focusing on fantastical plants and creatures that don't exist in our world. Include descriptions of any structures or ruins, emphasizing their otherworldly architecture and magical properties. Describe the sky and any celestial bodies, considering how they might differ from our reality. Include details about the presence of magic - how it manifests visually, its effects on the environment, and any magical phenomena occurring in the scene. If there are characters present, describe their appearance, focusing on non-human features, magical auras, or fantastical clothing and accessories. Pay attention to colors, textures, and light sources, especially those that couldn't exist in the real world. Your description should transport the reader to a realm of pure imagination, where the laws of physics and nature as we know them don't apply."""
54
+
55
+ prompt_types = {
56
+ "happy": default_happy_prompt,
57
+ "simple": default_simple_prompt,
58
+ "poster": poster_prompt,
59
+ "only_objects": only_objects_prompt,
60
+ "no_figure": no_figure_prompt,
61
+ "landscape": landscape_prompt,
62
+ "fantasy": fantasy_prompt
63
+ }
64
+
65
+ if custom_base_prompt.strip():
66
  base_prompt = custom_base_prompt
67
  else:
68
+ base_prompt = prompt_types.get(prompt_type, default_happy_prompt)
69
 
70
  if compress and not poster:
71
  compression_chars = {
ui_components.py CHANGED
@@ -98,11 +98,12 @@ def create_interface():
98
 
99
  with gr.Column(scale=2):
100
  with gr.Accordion("""Prompt Generation with LLM
101
- (You need to use Generate Prompt first)""", open=False):
102
  happy_talk = gr.Checkbox(label="Happy Talk", value=True)
103
  compress = gr.Checkbox(label="Compress", value=True)
104
  compression_level = gr.Radio(["soft", "medium", "hard"], label="Compression Level", value="hard")
105
- poster = gr.Checkbox(label="Poster", value=False)
 
106
  custom_base_prompt = gr.Textbox(label="Custom Base Prompt", lines=5)
107
  generate_text_button = gr.Button("Generate Prompt with LLM (Llama 3.1 70B)")
108
  text_output = gr.Textbox(label="Generated Text", lines=10)
@@ -164,7 +165,7 @@ def create_interface():
164
 
165
  generate_text_button.click(
166
  huggingface_node.generate,
167
- inputs=[output, happy_talk, compress, compression_level, poster, custom_base_prompt],
168
  outputs=text_output
169
  )
170
 
 
98
 
99
  with gr.Column(scale=2):
100
  with gr.Accordion("""Prompt Generation with LLM
101
+ (You need to use Generate Prompt first)""", open=False):
102
  happy_talk = gr.Checkbox(label="Happy Talk", value=True)
103
  compress = gr.Checkbox(label="Compress", value=True)
104
  compression_level = gr.Radio(["soft", "medium", "hard"], label="Compression Level", value="hard")
105
+ prompt_type = gr.Radio(["happy", "simple", "poster", "only_objects", "no_figure", "landscape", "fantasy"],
106
+ label="Prompt Type", value="happy")
107
  custom_base_prompt = gr.Textbox(label="Custom Base Prompt", lines=5)
108
  generate_text_button = gr.Button("Generate Prompt with LLM (Llama 3.1 70B)")
109
  text_output = gr.Textbox(label="Generated Text", lines=10)
 
165
 
166
  generate_text_button.click(
167
  huggingface_node.generate,
168
+ inputs=[output, happy_talk, compress, compression_level, prompt_type, custom_base_prompt],
169
  outputs=text_output
170
  )
171