Spaces:
Sleeping
Sleeping
| """ | |
| Demo script for BuildTheFuture application | |
| Creates sample construction images and demonstrates the application | |
| """ | |
| import os | |
| import sys | |
| from PIL import Image, ImageDraw, ImageFont | |
| import numpy as np | |
| import random | |
| def create_sample_construction_images(): | |
| """Create sample construction site images for demonstration""" | |
| # Create samples directory | |
| os.makedirs("samples", exist_ok=True) | |
| # Sample 1: Incomplete building | |
| create_incomplete_building("samples/building_construction.jpg") | |
| # Sample 2: Bridge construction | |
| create_bridge_construction("samples/bridge_construction.jpg") | |
| # Sample 3: Road construction | |
| create_road_construction("samples/road_construction.jpg") | |
| print("β Sample construction images created in 'samples' directory") | |
| def create_incomplete_building(filename): | |
| """Create an image of an incomplete building""" | |
| width, height = 600, 400 | |
| img = Image.new('RGB', (width, height), color=(135, 206, 235)) # Sky blue background | |
| draw = ImageDraw.Draw(img) | |
| # Ground | |
| draw.rectangle([0, height-100, width, height], fill=(139, 69, 19)) # Brown ground | |
| # Foundation (completed) | |
| draw.rectangle([100, height-200, 500, height-100], fill=(105, 105, 105)) # Gray foundation | |
| # Incomplete walls (only partially built) | |
| draw.rectangle([120, height-300, 200, height-200], fill=(192, 192, 192)) # Left wall | |
| draw.rectangle([300, height-250, 380, height-200], fill=(192, 192, 192)) # Right wall | |
| # Steel beams (exposed) | |
| for i in range(5): | |
| x = 150 + i * 60 | |
| draw.rectangle([x, height-350, x+10, height-200], fill=(64, 64, 64)) # Steel beams | |
| # Construction equipment | |
| draw.rectangle([50, height-150, 80, height-120], fill=(255, 165, 0)) # Crane base | |
| draw.line([65, height-150, 65, height-250], fill=(255, 165, 0), width=3) # Crane mast | |
| # Add some construction debris | |
| for _ in range(10): | |
| x = random.randint(0, width) | |
| y = random.randint(height-100, height-50) | |
| draw.ellipse([x, y, x+10, y+10], fill=(128, 128, 128)) | |
| img.save(filename) | |
| print(f"Created: {filename}") | |
| def create_bridge_construction(filename): | |
| """Create an image of an incomplete bridge""" | |
| width, height = 600, 400 | |
| img = Image.new('RGB', (width, height), color=(135, 206, 235)) # Sky blue | |
| draw = ImageDraw.Draw(img) | |
| # Water | |
| draw.rectangle([0, height-150, width, height], fill=(0, 100, 200)) # Blue water | |
| # Bridge supports (completed) | |
| draw.rectangle([150, height-300, 180, height-150], fill=(105, 105, 105)) # Left support | |
| draw.rectangle([420, height-300, 450, height-150], fill=(105, 105, 105)) # Right support | |
| # Bridge deck (incomplete - missing middle section) | |
| draw.rectangle([100, height-320, 200, height-300], fill=(192, 192, 192)) # Left deck | |
| draw.rectangle([400, height-320, 500, height-300], fill=(192, 192, 192)) # Right deck | |
| # Missing middle section (just steel beams) | |
| for i in range(8): | |
| x = 200 + i * 25 | |
| draw.rectangle([x, height-330, x+5, height-300], fill=(64, 64, 64)) # Steel beams | |
| # Construction equipment | |
| draw.rectangle([300, height-200, 330, height-170], fill=(255, 0, 0)) # Construction vehicle | |
| img.save(filename) | |
| print(f"Created: {filename}") | |
| def create_road_construction(filename): | |
| """Create an image of an incomplete road""" | |
| width, height = 600, 400 | |
| img = Image.new('RGB', (width, height), color=(135, 206, 235)) # Sky blue | |
| draw = ImageDraw.Draw(img) | |
| # Ground | |
| draw.rectangle([0, height-200, width, height], fill=(34, 139, 34)) # Green ground | |
| # Completed road sections | |
| draw.rectangle([0, height-150, 200, height-100], fill=(64, 64, 64)) # Left road | |
| draw.rectangle([400, height-150, width, height-100], fill=(64, 64, 64)) # Right road | |
| # Incomplete middle section (gravel/dirt) | |
| draw.rectangle([200, height-150, 400, height-100], fill=(139, 69, 19)) # Dirt/gravel | |
| # Construction equipment | |
| draw.rectangle([250, height-200, 280, height-170], fill=(255, 255, 0)) # Excavator | |
| draw.rectangle([350, height-200, 380, height-170], fill=(255, 0, 0)) # Dump truck | |
| # Road barriers | |
| for i in range(3): | |
| x = 180 + i * 60 | |
| draw.rectangle([x, height-180, x+20, height-150], fill=(255, 255, 0)) # Barriers | |
| img.save(filename) | |
| print(f"Created: {filename}") | |
| def run_demo(): | |
| """Run a demonstration of the application""" | |
| print("ποΈ BuildTheFuture Demo") | |
| print("=" * 50) | |
| # Create sample images | |
| create_sample_construction_images() | |
| print("\nπ Sample images created:") | |
| print(" - samples/building_construction.jpg") | |
| print(" - samples/bridge_construction.jpg") | |
| print(" - samples/road_construction.jpg") | |
| print("\nπ To run the application:") | |
| print(" 1. Set up your API keys in .env file") | |
| print(" 2. Run: python app.py") | |
| print(" 3. Upload one of the sample images") | |
| print(" 4. Select a completion style") | |
| print(" 5. Click 'Complete Construction'") | |
| print("\nπ‘ Tips:") | |
| print(" - Use realistic style for natural-looking completions") | |
| print(" - Use futuristic style for sci-fi transformations") | |
| print(" - Use artistic style for creative interpretations") | |
| if __name__ == "__main__": | |
| run_demo() | |