AsifBridge commited on
Commit
e6e9295
·
verified ·
1 Parent(s): 76e76d7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +70 -66
app.py CHANGED
@@ -1,63 +1,75 @@
1
  import gradio as gr
 
2
  import random
3
 
4
- # Function to generate detailed and unique video screenplay
5
- def generate_screenplay(client, product, brief, demographic, duration, frame_count, emotional_appeal, key_features, cta, location, music_genre, shot_type, visual_style, additional_input):
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6
  try:
 
 
 
 
 
7
  # Divide total video duration by frame count to get approximate time per frame
8
- duration_per_frame = float(duration) / int(frame_count)
9
  screenplay = f"**Creative Strategy:** {client} - {product}\n\n"
10
- screenplay += f"**Demographic:** {demographic}\n\n"
11
  screenplay += f"**Creative Brief:** {brief}\n\n"
12
  screenplay += f"**Emotional Appeal:** {emotional_appeal}\n\n"
13
  screenplay += f"**Call to Action:** {cta}\n\n"
14
  screenplay += "**Video Screenplay Breakdown:**\n"
15
 
16
  # Generate unique details for each frame
17
- for i in range(1, int(frame_count) + 1):
18
  start_time = round((i - 1) * duration_per_frame, 2)
19
  end_time = round(i * duration_per_frame, 2)
20
 
21
- # Add variety to visual, music, and AI prompts
22
- visual_options = [
23
- f"A vibrant morning scene in a bustling {location}. The camera pans across a warm, golden-lit environment with people interacting joyfully. The protagonist, styled in contemporary business casual attire, confidently uses {product} against a backdrop of sleek urban architecture and lush greenery.",
24
- f"An indoor setup with soft natural light streaming through large windows. The protagonist, dressed in pastel-colored formal wear, interacts with {product} placed on a polished wooden table. Minimalistic decor enhances the scene's sophistication.",
25
- f"A cinematic close-up of {product}, placed elegantly on a textured surface. The backdrop features a blurred skyline with subtle movement, emphasizing depth. Vibrant colors like deep blues and gold highlight the product's premium appeal.",
26
- f"A playful outdoor park setting with children laughing and playing in the background. The protagonist, casually dressed in bright colors, uses {product} to solve a relatable problem. Flowers and greenery add to the cheerful mood.",
27
- f"A high-energy party scene with colorful lighting and dynamic camera angles. The protagonist, styled in trendy evening wear, showcases {product} as the center of attention. The vibrant environment reflects excitement and modernity."
28
- ]
29
-
30
- music_options = [
31
- f"Uplifting {music_genre} tune that crescendos to evoke {emotional_appeal.lower()}.",
32
- f"A melodic {music_genre} soundtrack with subtle tones that perfectly complement the emotional appeal of {product}.",
33
- f"Catchy and rhythmic {music_genre} designed to keep the audience engaged and connected.",
34
- f"A gentle {music_genre} background score that matches the narrative's flow and {emotional_appeal.lower()}.",
35
- f"High-energy {music_genre} that resonates with excitement and passion for {product}."
36
- ]
37
-
38
- voiceover_options = [
39
- f"An engaging voiceover narrating the story of {product} and its transformative impact on {demographic}.",
40
- f"A warm and inviting tone explaining the features of {product} while emphasizing its relevance to {demographic}.",
41
- f"A confident and persuasive voiceover delivering the emotional appeal: {emotional_appeal}.",
42
- f"A story-like narration that connects with the audience, drawing them into the world of {product}.",
43
- f"A direct and empowering voiceover emphasizing why {product} is the perfect choice for {demographic}."
44
- ]
45
-
46
- ai_prompt_options = [
47
- f"Generate a cinematic visual of {product} being used in a {location} setting, highlighting key features like {key_features}.",
48
- f"Create a surreal and {visual_style} scene featuring {product} in an unexpected but delightful {location}.",
49
- f"Develop a {visual_style} animation showing how {product} integrates seamlessly into {demographic}'s lifestyle.",
50
- f"Craft a visually stunning montage of {product} with a focus on emotional appeal: {emotional_appeal}.",
51
- f"Design an engaging visual that blends real-life usage of {product} in {location} with stylized elements."
52
- ]
53
-
54
- # Add frame details
55
  screenplay += f"**Frame {i}:**\n"
56
  screenplay += f"- **Time:** {start_time}s to {end_time}s\n"
57
- screenplay += f"- **Visual:** {random.choice(visual_options)}\n"
58
- screenplay += f"- **Voiceover:** {random.choice(voiceover_options)}\n"
59
- screenplay += f"- **Music:** {random.choice(music_options)}\n"
60
- screenplay += f"- **AI Prompt:** {random.choice(ai_prompt_options)}\n\n"
61
 
62
  screenplay += f"**Additional Input:** {additional_input}\n"
63
  return screenplay
@@ -72,32 +84,24 @@ iface = gr.Interface(
72
  gr.Textbox(label="Client", placeholder="Enter the client's name (e.g., Elegant Shoes)"),
73
  gr.Textbox(label="Product", placeholder="Enter the product name (e.g., Ladies High Heels)"),
74
  gr.Textbox(label="Creative Brief", placeholder="Describe the creative brief (e.g., Elegance for working-class women)."),
75
- gr.Textbox(label="Demographic", placeholder="Target demographic (e.g., 18-30, working women)."),
76
  gr.Textbox(label="Video Duration (in seconds)", placeholder="Enter the total video duration (e.g., 30)."),
77
  gr.Textbox(label="Number of Frames", placeholder="Enter the number of storyboard frames (e.g., 10)."),
78
- gr.Dropdown(label="Emotional Appeal", choices=[
79
- "Trust", "Excitement", "Happiness", "Inspiration", "Empowerment", "Elegance", "Confidence",
80
- "Love", "Joy", "Ambition", "Passion", "Security", "Nostalgia", "Friendship", "Freedom"]),
81
- gr.Textbox(label="Key Features", placeholder="List the product's key features, separated by commas."),
82
- gr.Textbox(label="Call to Action", placeholder="Write a clear CTA, e.g., 'Buy Now', 'Visit Our Website'."),
83
- gr.Dropdown(label="Primary Location", choices=[
84
- "Urban", "Rural", "Office", "Shopping Mall", "House", "Party", "Outdoor Park",
85
- "Beach", "Restaurant", "Gym", "City Street", "Countryside", "Airport", "Hotel", "Studio"]),
86
- gr.Dropdown(label="Music Genre", choices=[
87
- "Upbeat Electronic", "Soft Acoustic", "Cinematic", "Ambient", "Pop", "Jazz", "Classical",
88
- "Rock", "Dance", "Chillwave", "Lo-Fi", "Hip-Hop", "Orchestral", "World Music", "Funk"]),
89
- gr.Dropdown(label="Shot Types", choices=[
90
- "Mix Shot", "Close-Up", "Wide Shot", "Mid Shot", "Tracking Shot", "Overhead Shot",
91
- "High Angle", "Low Angle", "Point-of-View", "Dutch Angle", "Two-Shot", "Over-the-Shoulder",
92
- "Establishing Shot", "Insert Shot", "Extreme Close-Up"]),
93
- gr.Dropdown(label="AI Visual Style", choices=[
94
- "Realistic", "Illustrative", "Cinematic", "Minimalistic", "Abstract", "Surreal", "Photorealistic",
95
- "Vintage", "Futuristic", "Cartoonish", "Modern", "Retro", "High Contrast", "Black and White", "Dreamlike"]),
96
- gr.Textbox(label="Additional Input", placeholder="Any additional notes or custom input for the creative process."),
97
  ],
98
- outputs=gr.Textbox(label="Generated Detailed Screenplay"),
99
- title="Creative Video Screenplay Generator",
100
- description="Generate a highly detailed video screenplay with creative, visual, and emotional depth for your product."
101
  )
102
 
103
  iface.launch()
 
 
1
  import gradio as gr
2
+ import openai # Ensure OpenAI API is accessible and configured
3
  import random
4
 
5
+ # Predefined lists for variety and efficiency
6
+ visual_options = [
7
+ "A vibrant morning scene in a bustling {location}. The camera pans across a warm, golden-lit environment with people interacting joyfully. The protagonist, styled in contemporary business casual attire, confidently uses {product} against a backdrop of sleek urban architecture and lush greenery.",
8
+ "An indoor setup with soft natural light streaming through large windows. The protagonist, dressed in pastel-colored formal wear, interacts with {product} placed on a polished wooden table. Minimalistic decor enhances the scene's sophistication.",
9
+ "A cinematic close-up of {product}, placed elegantly on a textured surface. The backdrop features a blurred skyline with subtle movement, emphasizing depth. Vibrant colors like deep blues and gold highlight the product's premium appeal.",
10
+ "A playful outdoor park setting with children laughing and playing in the background. The protagonist, casually dressed in bright colors, uses {product} to solve a relatable problem. Flowers and greenery add to the cheerful mood.",
11
+ "A high-energy party scene with colorful lighting and dynamic camera angles. The protagonist, styled in trendy evening wear, showcases {product} as the center of attention. The vibrant environment reflects excitement and modernity."
12
+ ]
13
+
14
+ # Additional predefined lists for dropdown menus
15
+ music_genres = [
16
+ "Classical", "Jazz", "Pop", "Rock", "Hip-Hop", "Electronic", "Ambient", "Folk", "Blues", "Reggae", "Country", "Latin", "R&B", "Soul", "Indie", "Dance", "World", "Acoustic", "Instrumental", "Orchestral", "Techno", "House", "Dubstep", "Lo-fi", "Chillwave"
17
+ ]
18
+
19
+ ai_visual_styles = [
20
+ "Minimalistic", "Vibrant", "Monochromatic", "Surreal", "Photorealistic", "Vintage", "Futuristic", "Cartoonish", "Abstract", "Elegant", "Playful", "Rustic", "Bold", "Edgy", "Soft", "Whimsical", "Industrial", "Luxurious", "Dynamic", "Art Deco", "Flat Design", "3D Rendered", "Organic", "Textured", "High Contrast"
21
+ ]
22
+
23
+ video_qualities = [
24
+ "720p", "1080p", "4K", "8K", "HDR", "SD", "High Frame Rate", "Cinematic", "Mobile Optimized", "Vertical Format", "Square Format", "Wide Format", "IMAX", "Low Light", "Studio Quality", "Dynamic Lighting", "Natural Lighting", "Experimental", "Stop Motion", "Timelapse", "Drone Shot", "Underwater", "Night Mode", "Portrait Mode", "Landscape Mode"
25
+ ]
26
+
27
+ color_themes = [
28
+ "Warm Tones", "Cool Tones", "Neutral", "Pastel", "Bright and Bold", "Earthy", "Black and White", "Sepia", "Gradient", "Complementary", "Analogous", "Triadic", "Monochromatic", "Neon", "Muted", "Jewel Tones", "Desaturated", "Pop Art", "Futuristic Neon", "Sunset", "Forest", "Ocean", "Desert", "Urban", "Vintage Film"
29
+ ]
30
+
31
+ camera_options = [
32
+ "Close-Up", "Wide Angle", "Medium Shot", "Over-the-Shoulder", "POV", "Tracking Shot", "Dolly Zoom", "Crane Shot", "Bird's Eye View", "Low Angle", "High Angle", "Handheld", "Steadicam", "Slow Motion", "Time-Lapse", "Zoom-In", "Zoom-Out", "Pan", "Tilt", "Rack Focus", "360 Shot", "Underwater Shot", "Aerial Shot", "Split Screen", "Reverse Motion"
33
+ ]
34
+
35
+ # Function to generate detailed and unique video screenplay with AI-enhanced creativity
36
+ def generate_screenplay(client, product, brief, duration, frame_count, emotional_appeal, key_features, cta, location, music_genre, shot_type, visual_style, video_quality, color_theme, camera, additional_input):
37
  try:
38
+ # Validate inputs
39
+ key_features = key_features if key_features else "highlighting its unique attributes"
40
+ duration = float(duration) if duration else 30
41
+ frame_count = int(frame_count) if frame_count else 10
42
+
43
  # Divide total video duration by frame count to get approximate time per frame
44
+ duration_per_frame = duration / frame_count
45
  screenplay = f"**Creative Strategy:** {client} - {product}\n\n"
 
46
  screenplay += f"**Creative Brief:** {brief}\n\n"
47
  screenplay += f"**Emotional Appeal:** {emotional_appeal}\n\n"
48
  screenplay += f"**Call to Action:** {cta}\n\n"
49
  screenplay += "**Video Screenplay Breakdown:**\n"
50
 
51
  # Generate unique details for each frame
52
+ for i in range(1, frame_count + 1):
53
  start_time = round((i - 1) * duration_per_frame, 2)
54
  end_time = round(i * duration_per_frame, 2)
55
 
56
+ # Generate visuals using AI if OpenAI API key is available
57
+ visual_prompt = f"Generate a highly creative scene with {product} in {location}, focusing on {key_features}. Style: {visual_style}. Quality: {video_quality}. Colors: {color_theme}. Camera: {camera}."
58
+ try:
59
+ ai_visual = openai.Completion.create(
60
+ engine="text-davinci-003",
61
+ prompt=visual_prompt,
62
+ max_tokens=100
63
+ ).choices[0].text.strip()
64
+ except Exception:
65
+ ai_visual = random.choice(visual_options).format(location=location, product=product)
66
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
67
  screenplay += f"**Frame {i}:**\n"
68
  screenplay += f"- **Time:** {start_time}s to {end_time}s\n"
69
+ screenplay += f"- **Visual:** {ai_visual}\n"
70
+ screenplay += f"- **Voiceover:** A tailored voiceover emphasizing {emotional_appeal} and {key_features}.\n"
71
+ screenplay += f"- **Music:** {music_genre} track to enhance the emotional appeal.\n"
72
+ screenplay += f"- **AI Prompt for Storyboard:** A vivid description of {product} in {visual_style} style, filmed with {camera}.\n\n"
73
 
74
  screenplay += f"**Additional Input:** {additional_input}\n"
75
  return screenplay
 
84
  gr.Textbox(label="Client", placeholder="Enter the client's name (e.g., Elegant Shoes)"),
85
  gr.Textbox(label="Product", placeholder="Enter the product name (e.g., Ladies High Heels)"),
86
  gr.Textbox(label="Creative Brief", placeholder="Describe the creative brief (e.g., Elegance for working-class women)."),
 
87
  gr.Textbox(label="Video Duration (in seconds)", placeholder="Enter the total video duration (e.g., 30)."),
88
  gr.Textbox(label="Number of Frames", placeholder="Enter the number of storyboard frames (e.g., 10)."),
89
+ gr.Textbox(label="Emotional Appeal", placeholder="E.g., Elegance, Trust, Joy"),
90
+ gr.Textbox(label="Key Features", placeholder="Key product features (e.g., ergonomic design, durable material)."),
91
+ gr.Dropdown(label="Call to Action", choices=[
92
+ "Buy Now", "Sign Up Today", "Learn More", "Order Now", "Try for Free", "Discover More", "Subscribe Today", "Get Started", "Book Your Spot", "Contact Us", "Download Now", "Join Now", "Explore More", "Shop Now", "Request a Demo", "Get Your Free Sample", "Claim Your Offer", "Unlock Your Potential", "Start Your Journey", "Register Now", "Watch Now", "Apply Today", "Find Out More", "Upgrade Now", "Get Access"
93
+ ]),
94
+ gr.Textbox(label="Location", placeholder="E.g., Urban park, Cozy living room"),
95
+ gr.Dropdown(label="Music Genre", choices=music_genres),
96
+ gr.Dropdown(label="Shot Type", choices=camera_options),
97
+ gr.Dropdown(label="AI Visual Style", choices=ai_visual_styles),
98
+ gr.Dropdown(label="Video Quality", choices=video_qualities),
99
+ gr.Dropdown(label="Color Theme", choices=color_themes),
100
+ gr.Dropdown(label="Camera", choices=camera_options),
101
+ gr.Textbox(label="Additional Input", placeholder="Any other specifics or instructions."),
 
 
 
 
 
 
102
  ],
103
+ outputs=gr.Textbox(label="Generated Screenplay")
 
 
104
  )
105
 
106
  iface.launch()
107
+