=== streamlit_app.py === import streamlit as st from utils import load_css, create_prompt_selector, display_image_gallery, generate_image_placeholder import time def main(): st.set_page_config( page_title="AI Image Generator - Dramatic Scenes", page_icon="🎨", layout="wide", initial_sidebar_state="expanded" ) load_css() # Header st.markdown("""

🎬 AI Image Generator - Dramatic Scenes

Create hyperrealistic, cinematic images with detailed prompts

Built with anycoder

""", unsafe_allow_html=True) # Sidebar with st.sidebar: st.markdown("## βš™οΈ Generation Settings") # Aspect ratio aspect_ratio = st.selectbox( "Aspect Ratio", options=["4:5", "16:9", "1:1", "3:2", "2:3"], index=0 ) # Quality quality = st.selectbox( "Quality", options=["Standard", "High", "Ultra (8K)"], index=2 ) # Style style = st.selectbox( "Style", options=["Cinematic", "Photorealistic", "Dramatic", "Hollywood", "Artistic"], index=0 ) # Resolution resolution = st.selectbox( "Resolution", options=["1024x1024", "1024x1280", "1280x720", "1920x1080", "2048x2560"], index=1 ) st.markdown("---") st.markdown("### πŸ“Š Statistics") if 'generated_count' not in st.session_state: st.session_state.generated_count = 0 st.metric("Images Generated", st.session_state.generated_count) # Main content col1, col2 = st.columns([1, 1]) with col1: st.markdown("## πŸ“ Prompt Editor") # Predefined prompts prompt_option = st.radio( "Choose a scene template:", ["Custom Prompt", "Haunted Hut Scene", "Disaster Scene"], index=0 ) # Predefined prompts prompts = { "Haunted Hut Scene": """Hyperrealistic and dramatic scene showing a terrified man sitting on a bamboo bench in a thatch-roofed hut. He's wearing a black T-shirt with "WALIΔ† RUDEGO" text and symbolic pattern underneath. A semi-transparent, smoky, ghostly figure emerges from the air beside him, grabbing his neck with a misty hand. The ghost has a skeletal, menacing face and glowing eyes, screaming or roaring. The man looks shocked and terrified, with wide eyes and mouth agape, frozen in fear. Natural lighting with warm sunlight filtering through the hut, background shows green vegetation outside. Intense, eerie, and cinematic atmosphere with strong emotional contrast between ghost and victim. 8K resolution, 4:5 aspect ratio.""", "Disaster Scene": """A man and cat falling through the air. Background: skyscrapers curve dramatically in a wide fisheye perspective, as if the entire city is collapsing inward. Flying debris, concrete chunks, and glass shards fill the air. Action elements: A police car floats behind him - its red and blue sirens flash intensely through dust and smoke. Behind the vehicle follows a powerful explosion, casting orange light and shrapnel across the scene. In the background, a police officer is seen waving arms, thrown by the explosion. Lighting and atmosphere: Cinematic lighting with strong, directional shadows, motion blur, and bright lights from sirens and fireball. Dark and gritty color palette with golden-brown tones punctuated by vivid red, blue, and orange accents from explosions and sirens. Clothing: The man wears a torn, olive-green hoodie and dark, worn pants - flailing wildly in the wind. Hollywood disaster movie style - dramatic freeze-frame with intense city destruction, emotions, and surreal action. Hyperrealistic details in skin texture, movement, and lighting.""" } # Text area for prompt if prompt_option == "Custom Prompt": prompt_text = st.text_area( "Enter your prompt:", height=200, placeholder="Describe the image you want to generate in detail..." ) else: prompt_text = st.text_area( "Edit the preset prompt:", value=prompts.get(prompt_option, ""), height=200 ) # Negative prompt negative_prompt = st.text_area( "Negative Prompt (what to avoid):", value="blurry, low quality, distorted, deformed, bad anatomy, watermark, text, signature", height=100 ) # Generate button generate_col1, generate_col2, generate_col3 = st.columns([1, 2, 1]) with generate_col2: if st.button("🎨 Generate Image", type="primary", use_container_width=True): if prompt_text: with st.spinner("Generating your image..."): # Simulate image generation time.sleep(2) # Update session state if 'generated_images' not in st.session_state: st.session_state.generated_images = [] # Add new image to gallery new_image = { 'prompt': prompt_text, 'negative_prompt': negative_prompt, 'aspect_ratio': aspect_ratio, 'quality': quality, 'style': style, 'timestamp': time.time() } st.session_state.generated_images.append(new_image) st.session_state.generated_count += 1 st.success("βœ… Image generated successfully!") st.rerun() else: st.error("❌ Please enter a prompt to generate an image.") with col2: st.markdown("## πŸ–ΌοΈ Generated Images") if 'generated_images' in st.session_state and st.session_state.generated_images: display_image_gallery(st.session_state.generated_images) else: st.markdown("""

No images generated yet

Enter a prompt and click "Generate Image" to start creating!

""", unsafe_allow_html=True) # Show example placeholders st.markdown("### Example Scenes") example_col1, example_col2 = st.columns(2) with example_col1: st.image( generate_image_placeholder("Haunted", "#FF6B6B"), caption="Haunted Hut Scene Example", use_column_width=True ) with example_col2: st.image( generate_image_placeholder("Disaster", "#4ECDC4"), caption="Disaster Scene Example", use_column_width=True ) # Footer st.markdown("---") st.markdown(""" """, unsafe_allow_html=True) if __name__ == "__main__": main() === utils.py === import streamlit as st import base64 from io import BytesIO import time def load_css(): """Load custom CSS styles""" st.markdown(""" """, unsafe_allow_html=True) def create_prompt_selector(): """Create a prompt selection interface""" pass def display_image_gallery(images): """Display a gallery of generated images""" cols = st.columns(2) for idx, image_data in enumerate(reversed(images[-6:])): # Show last 6 images with cols[idx % 2]: st.markdown(f"""
Generated
{time.strftime('%Y-%m-%d %H:%M', time.localtime(image_data['timestamp']))}
Style: {image_data['style']}
Quality: {image_data['quality']}
Aspect: {image_data['aspect_ratio']}
{image_data['prompt'][:100]}{'...' if len(image_data['prompt']) > 100 else ''}
""", unsafe_allow_html=True) if st.button(f"πŸ“‹ Copy Prompt", key=f"copy_{idx}"): st.write(f"**Prompt copied to clipboard:** {image_data['prompt']}") st.success("Prompt ready to copy!") def generate_image_placeholder(text, color="#667eea"): """Generate a placeholder image with text""" # This would normally use an image generation API # For now, we'll create a simple placeholder return f"https://picsum.photos/seed/{text}/400/500" def create_placeholder_image(seed): """Create a base64 encoded placeholder image""" # Simple placeholder - in real app this would be the generated image placeholder_url = f"https://picsum.photos/seed/{seed}/400/500" return "" def save_image_to_history(image_data): """Save generated image to session history""" if 'image_history' not in st.session_state: st.session_state.image_history = [] st.session_state.image_history.append({ 'timestamp': time.time(), 'data': image_data }) # Keep only last 50 images if len(st.session_state.image_history) > 50: st.session_state.image_history = st.session_state.image_history[-50:] def get_prompt_suggestions(): """Get prompt suggestions for users""" return [ "Cinematic portrait with dramatic lighting", "Fantasy landscape with magical elements", "Urban street scene at golden hour", "Abstract art with vibrant colors", "Historical scene with period accuracy" ] === requirements.txt === streamlit pillow numpy requests base64 time