Spaces:
Runtime error
Runtime error
| TEXT_TO_IMAGE_EXAMPLES = [ | |
| ["An orange cat sitting on a windowsill, sunlight streaming through the window onto it, cozy home environment, high-definition photography"], | |
| ["A majestic tiger walking through the jungle, sharp eyes, clear fur details, wildlife photography"], | |
| ["Futuristic tech city at night, neon lights flashing, flying cars shuttling through the air, cyberpunk style, 4K quality"], | |
| ["Steampunk-style robot, intricate gears and steam, retro industrial design, metallic texture"], | |
| ["Beautiful woman in traditional Chinese clothing playing guqin in bamboo forest, elegant atmosphere, Chinese painting style, fine brushwork"], | |
| ["Japanese garden with cherry blossoms falling, ancient wooden buildings, stone lanterns, zen aesthetics, spring"], | |
| ["A castle floating in the clouds, surrounded by rainbows and flying birds, dreamy fairy tale style, Disney animation"], | |
| ["Fairy in magical forest, glowing wings, mysterious mushroom house, fantasy illustration style"], | |
| # Natural Landscape | |
| ["Peaceful lake reflecting snow-capped mountains, sunrise moment, golden sunlight on water surface, landscape photography"], | |
| ["Mysterious creatures in the deep sea, glowing jellyfish and coral, blue dreamy lighting, ocean wonder"], | |
| # Artistic Creative | |
| ["Abstract art style city buildings, geometric combinations, vibrant color contrasts, modern art"], | |
| ["Vaporwave aesthetic sunset, pink-purple tones, retro grid background, 80s nostalgia"] | |
| ] | |
| TEXT_TO_IMAGE_EXAMPLES_WITH_RESULTS = [ | |
| # 格式: [提示词, 分辨率, 图片文件路径] | |
| # Animals | |
| [ | |
| "An orange cat sitting on a windowsill, sunlight streaming through the window onto it, cozy home environment, high-definition photography", | |
| "square - 1024x1024 (1:1)", | |
| "examples/results/cat_windowsill.jpg" | |
| ], | |
| [ | |
| "A majestic tiger walking through the jungle, sharp eyes, clear fur details, wildlife photography", | |
| "landscape - 1152x896 (4:3)", | |
| "examples/results/tiger_jungle.jpg" | |
| ], | |
| # Sci-fi Future | |
| [ | |
| "Futuristic tech city at night, neon lights flashing, flying cars shuttling through the air, cyberpunk style, 4K quality", | |
| "landscape - 1344x768 (16:9)", | |
| "examples/results/cyberpunk_city.jpg" | |
| ], | |
| [ | |
| "Steampunk-style robot, intricate gears and steam, retro industrial design, metallic texture", | |
| "square - 1024x1024 (1:1)", | |
| "examples/results/steampunk_robot.jpg" | |
| ], | |
| # Traditional Oriental | |
| [ | |
| "Beautiful woman in traditional Chinese clothing playing guqin in bamboo forest, elegant atmosphere, Chinese painting style, fine brushwork", | |
| "portrait - 768x1344 (9:16)", | |
| "examples/results/chinese_woman_guqin.jpg" | |
| ], | |
| [ | |
| "Japanese garden with cherry blossoms falling, ancient wooden buildings, stone lanterns, zen aesthetics, spring", | |
| "landscape - 1216x832 (3:2)", | |
| "examples/results/japanese_garden.jpg" | |
| ], | |
| # Fantasy Fairy Tale | |
| [ | |
| "A castle floating in the clouds, surrounded by rainbows and flying birds, dreamy fairy tale style, Disney animation", | |
| "landscape - 1152x896 (4:3)", | |
| "examples/results/floating_castle.jpg" | |
| ], | |
| [ | |
| "Fairy in magical forest, glowing wings, mysterious mushroom house, fantasy illustration style", | |
| "square - 1024x1024 (1:1)", | |
| "examples/results/fairy_forest.jpg" | |
| ], | |
| # Natural Landscape | |
| [ | |
| "Peaceful lake reflecting snow-capped mountains, sunrise moment, golden sunlight on water surface, landscape photography", | |
| "landscape - 1344x768 (16:9)", | |
| "examples/results/mountain_lake.jpg" | |
| ], | |
| [ | |
| "Mysterious creatures in the deep sea, glowing jellyfish and coral, blue dreamy lighting, ocean wonder", | |
| "portrait - 896x1152 (3:4)", | |
| "examples/results/deep_sea_creatures.jpg" | |
| ], | |
| # Artistic Creative | |
| [ | |
| "Abstract art style city buildings, geometric combinations, vibrant color contrasts, modern art", | |
| "square - 1024x1024 (1:1)", | |
| "examples/results/abstract_buildings.jpg" | |
| ], | |
| [ | |
| "Vaporwave aesthetic sunset, pink-purple tones, retro grid background, 80s nostalgia", | |
| "landscape - 1536x640 (21:9)", | |
| "examples/results/vaporwave_sunset.jpg" | |
| ] | |
| ] | |
| # 文生图示例标签(可选,用于更好的用户体验) | |
| TEXT_TO_IMAGE_LABELS = [ | |
| "🐱 Cozy Cat", | |
| "🐅 Wild Tiger", | |
| "🌃 Cyberpunk City", | |
| "🤖 Steampunk Robot", | |
| "🎵 Elegant Guqin Lady", | |
| "🌸 Japanese Sakura Garden", | |
| "🏰 Castle in the Clouds", | |
| "🧚 Forest Fairy", | |
| "🏔️ Sunrise over Snowy Lake", | |
| "🌊 Deep Sea Wonders", | |
| "🏙️ Abstract Architecture", | |
| "🌅 Vaporwave Sunset" | |
| ] | |
| # 按类别组织的示例(用于高级展示) | |
| CATEGORIZED_EXAMPLES = { | |
| "🐾 Animal World": [ | |
| ["An orange cat sitting on a windowsill, sunlight streaming through the window onto it, cozy home environment, high-definition photography"], | |
| ["A majestic tiger walking through the jungle, sharp eyes, clear fur details, wildlife photography"], | |
| ["An elegant white swan swimming on the lake, feathers white as snow, clear reflection, nature photography"] | |
| ], | |
| "🚀 Sci-Fi Future": [ | |
| ["Futuristic tech city at night, neon lights flashing, flying cars shuttling through the air, cyberpunk style, 4K quality"], | |
| ["Steampunk-style robot, intricate gears and steam, retro industrial design, metallic texture"], | |
| ["Inside a space station, astronauts floating in zero gravity, sci-fi movie scene, high-tech equipment"] | |
| ], | |
| "🏮 Traditional Aesthetics": [ | |
| ["Beautiful woman in traditional Chinese clothing playing guqin in bamboo forest, elegant atmosphere, Chinese painting style, fine brushwork"], | |
| ["Japanese garden with cherry blossoms falling, ancient wooden buildings, stone lanterns, zen aesthetics, spring"], | |
| ["Traditional Chinese architecture complex, flying eaves, red walls and yellow tiles, architectural photography"] | |
| ], | |
| "✨ Fantasy Magic": [ | |
| ["A castle floating in the clouds, surrounded by rainbows and flying birds, dreamy fairy tale style, Disney animation"], | |
| ["Fairy in magical forest, glowing wings, mysterious mushroom house, fantasy illustration style"], | |
| ["Dragon hovering over mountain peaks, breathing fire, epic fantasy scene, cinematic quality"] | |
| ], | |
| "🌄 Natural Landscape": [ | |
| ["Peaceful lake reflecting snow-capped mountains, sunrise moment, golden sunlight on water surface, landscape photography"], | |
| ["Mysterious creatures in the deep sea, glowing jellyfish and coral, blue dreamy lighting, ocean wonder"], | |
| ["Autumn maple forest with red and yellow leaves, sunlight filtering through leaves, warm tones"] | |
| ] | |
| } | |
| # 图生图基本信息 | |
| IMAGE_TO_IMAGE_INFO = { | |
| "supported_formats": ["PNG", "JPEG", "BMP", "WEBP"], | |
| "file_size_limit": "10MB" | |
| } | |
| # 摄影风格转换基本信息 | |
| PHOTO_STYLE_INFO = { | |
| "supported_formats": ["PNG", "JPEG", "BMP", "WEBP"], | |
| "file_size_limit": "10MB", | |
| "max_resolution": "2000x2000", | |
| "min_resolution": "500x500", | |
| "auto_resize": True, | |
| "description": "Transform your photos with professional photography styles" | |
| } | |
| # 摄影风格列表和描述 | |
| PHOTO_STYLES = [ | |
| "Photo-Camera Movement", # 移动镜头 | |
| "Photo-Relighting", # 重新布光 | |
| "Photo-Camera Zoom", # 画面缩放 | |
| "Photo-Professional Product Photography", # 专业产品图 | |
| "Photo-Tilt-Shift Miniature", # 微缩世界 | |
| "Photo-Reflection Addition", # 添加倒影 | |
| "Photo-Character Pose & Viewpoint Change" # 角色姿势视角变换 | |
| ] | |
| PHOTO_STYLE_DESCRIPTIONS = { | |
| "Photo-Camera Movement": { | |
| "name": "Camera Movement", | |
| "description": "Create dynamic camera motion effects to enhance movement and visual impact", | |
| "effect": "Best for sports scenes, street photography, dynamic portraits", | |
| "example": "Turn static photos into motion trail and motion blur effects" | |
| }, | |
| "Photo-Relighting": { | |
| "name": "Relighting", | |
| "description": "Modify the lighting and atmosphere of the photo, optimizing light and shadow relationships", | |
| "effect": "Great for portrait, indoor scenes, and product photography", | |
| "example": "Adjust light direction, intensity, and color temperature to create different visual moods" | |
| }, | |
| "Photo-Camera Zoom": { | |
| "name": "Camera Zoom", | |
| "description": "Adjust zoom and focus effects to highlight the subject or change perspective", | |
| "effect": "Suitable for landscapes, architecture, and close-ups", | |
| "example": "Create telephoto compression or wide-angle perspective effects" | |
| }, | |
| "Photo-Professional Product Photography": { | |
| "name": "Professional Product Photography", | |
| "description": "Convert to professional product photography style, highlighting product features", | |
| "effect": "Ideal for e-commerce, industrial design, and showcases", | |
| "example": "Optimize lighting, background, and composition to increase commercial value" | |
| }, | |
| "Photo-Tilt-Shift Miniature": { | |
| "name": "Tilt-Shift Miniature", | |
| "description": "Create a miniature model-like effect for a whimsical atmosphere", | |
| "effect": "Works well for cityscapes, building clusters, and top-down shots", | |
| "example": "Use selective focus and color tuning to make real scenes look like models" | |
| }, | |
| "Photo-Reflection Addition": { | |
| "name": "Reflection Addition", | |
| "description": "Add natural reflections to images to enhance visual layering", | |
| "effect": "Good for water surfaces, glass, and mirror effects", | |
| "example": "Add realistic reflections on water, ground, or other reflective surfaces" | |
| }, | |
| "Photo-Character Pose & Viewpoint Change": { | |
| "name": "Pose & Viewpoint Change", | |
| "description": "Change human pose and shooting angle to create new compositions", | |
| "effect": "Useful for portrait, fashion, and artistic photography", | |
| "example": "Adjust body movements, expressions, and camera angle for better visual results" | |
| } | |
| } | |
| # 摄影风格转换示例配置 | |
| PHOTO_STYLE_EXAMPLES = [ | |
| { | |
| "style": "Photo-Camera Movement", | |
| "description": "Add dynamic camera movement to static portraits", | |
| "tags": ["dynamic", "motion", "street"] | |
| }, | |
| { | |
| "style": "Photo-Relighting", | |
| "description": "Optimize lighting for indoor portraits", | |
| "tags": ["portrait", "lighting", "ambience"] | |
| }, | |
| { | |
| "style": "Photo-Camera Zoom", | |
| "description": "Adjust focal length effects for landscape photos", | |
| "tags": ["landscape", "focal", "perspective"] | |
| }, | |
| { | |
| "style": "Photo-Professional Product Photography", | |
| "description": "Convert regular product photos into professional commercial shots", | |
| "tags": ["product", "commercial", "e-commerce"] | |
| }, | |
| { | |
| "style": "Photo-Tilt-Shift Miniature", | |
| "description": "Turn cityscapes into miniature model effects", | |
| "tags": ["miniature", "whimsical", "creative"] | |
| }, | |
| { | |
| "style": "Photo-Reflection Addition", | |
| "description": "Add water reflections to architecture photos", | |
| "tags": ["reflection", "water", "symmetry"] | |
| }, | |
| { | |
| "style": "Photo-Character Pose & Viewpoint Change", | |
| "description": "Adjust pose and viewpoint for portrait photography", | |
| "tags": ["portrait", "pose", "viewpoint"] | |
| } | |
| ] | |
| # 获取随机示例(用于动态展示) | |
| def get_random_examples(category=None, count=4): | |
| import random | |
| if category and category in CATEGORIZED_EXAMPLES: | |
| examples = CATEGORIZED_EXAMPLES[category] | |
| else: | |
| examples = TEXT_TO_IMAGE_EXAMPLES | |
| if len(examples) <= count: | |
| return examples | |
| return random.sample(examples, count) | |
| # 获取分类示例(用于标签页展示) | |
| def get_categorized_examples(): | |
| return CATEGORIZED_EXAMPLES | |
| # 室内设计渲染示例配置 | |
| # 室内设计渲染示例配置(重新实现) | |
| INTERIOR_DESIGN_EXAMPLES_WITH_RESULTS = [ | |
| [ | |
| "examples/interior_input.png", # 输入的白膜图 | |
| "japanese_wabi_sabi", # 日本诧寂风格 | |
| "examples/results/interior_japanese_wabi_sabi.jpg" # 渲染结果 | |
| ], | |
| [ | |
| "examples/interior_input.png", # 输入的白膜图 | |
| "nordic_cozy", # 北欧温馨风格 | |
| "examples/results/interior_nordic_cozy.jpg" # 渲染结果 | |
| ], | |
| [ | |
| "examples/interior_input.png", # 输入的白膜图 | |
| "italian_luxury", # 意大利风格 | |
| "examples/results/interior_italian_luxury.jpg" # 渲染结果 | |
| ], | |
| [ | |
| "examples/interior_input.png", # 输入的白膜图 | |
| "parisian_apartment", # 巴黎套间风格 | |
| "examples/results/interior_parisian_apartment.jpg" # 渲染结果 | |
| ] | |
| ] | |
| # 摄影风格转换相关辅助函数 | |
| def get_photo_styles(): | |
| return PHOTO_STYLES.copy() | |
| def get_photo_style_description(style): | |
| return PHOTO_STYLE_DESCRIPTIONS.get(style) | |
| def get_photo_style_info(): | |
| return PHOTO_STYLE_INFO.copy() | |
| def get_photo_style_examples(): | |
| return PHOTO_STYLE_EXAMPLES.copy() | |
| def validate_photo_style(style): | |
| return style in PHOTO_STYLES | |
| def get_photo_styles_with_descriptions(): | |
| return PHOTO_STYLE_DESCRIPTIONS.copy() | |
| def get_random_photo_style_examples(count=3): | |
| import random | |
| if len(PHOTO_STYLE_EXAMPLES) <= count: | |
| return PHOTO_STYLE_EXAMPLES.copy() | |
| return random.sample(PHOTO_STYLE_EXAMPLES, count) | |
| # 线稿转换示例配置 | |
| # 线稿转换基本信息 | |
| LINE_ART_CONVERSION_INFO = { | |
| "supported_formats": ["PNG", "JPEG", "BMP", "WEBP"], | |
| "file_size_limit": "10MB", | |
| "max_resolution": "2000x2000", | |
| "min_resolution": "500x500", | |
| "auto_resize": True, | |
| "description": "Convert your photos into clean line art drawings" | |
| } | |
| # 线稿转换示例配置(简化格式,只包含输入和输出) | |
| # 格式: [输入图片路径, 结果图片路径] | |
| LINE_ART_CONVERSION_EXAMPLES_WITH_RESULTS = [ | |
| [ | |
| "examples/line_art_input/example1.jpg", # 输入图片 | |
| "examples/results/line_art_example1.jpg" # 结果图片 | |
| ], | |
| [ | |
| "examples/line_art_input/example2.jpg", # 输入图片 | |
| "examples/results/line_art_example2.jpg" # 结果图片 | |
| ], | |
| [ | |
| "examples/line_art_input/example3.jpg", # 输入图片 | |
| "examples/results/line_art_example3.jpg" # 结果图片 | |
| ] | |
| ] | |
| # 线稿转换相关辅助函数 | |
| def get_line_art_conversion_info(): | |
| return LINE_ART_CONVERSION_INFO.copy() | |
| def get_line_art_conversion_examples(): | |
| return LINE_ART_CONVERSION_EXAMPLES_WITH_RESULTS.copy() | |
| # 二次元转真人相关配置 | |
| ANIME_TO_REAL_INFO = { | |
| "description": "Convert anime illustrations into realistic photos", | |
| "supported_formats": ["PNG", "JPEG", "JPG", "WEBP"], | |
| "max_file_size": "10MB", | |
| "recommended_resolution": "512x512 to 1024x1024", | |
| "processing_time": "Typically 1–3 minutes" | |
| } | |
| # 二次元转真人示例配置 | |
| ANIME_TO_REAL_EXAMPLES_WITH_RESULTS = [ | |
| ["examples/anime_input/example1.jpg","examples/results/anime_to_real_example1.jpg"] | |
| ] | |
| # 用于显示预生成结果的映射(如果需要) | |
| ANIME_TO_REAL_RESULTS_MAP = { | |
| "examples/anime_input/example1.jpg": "examples/results/anime_to_real_example1.jpg" | |
| } | |
| # 二次元转真人相关辅助函数 | |
| def get_anime_to_real_info(): | |
| return ANIME_TO_REAL_INFO.copy() | |
| def get_anime_to_real_examples(): | |
| return ANIME_TO_REAL_EXAMPLES_WITH_RESULTS.copy() | |
| def get_random_line_art_examples(count=3): | |
| import random | |
| if len(LINE_ART_CONVERSION_EXAMPLES_WITH_RESULTS) <= count: | |
| return LINE_ART_CONVERSION_EXAMPLES_WITH_RESULTS.copy() | |
| return random.sample(LINE_ART_CONVERSION_EXAMPLES_WITH_RESULTS, count) | |
| # 真实图片转动漫插画相关配置 | |
| REAL_TO_ANIME_INFO = { | |
| "description": "Convert real photos into anime illustration style", | |
| "supported_formats": ["PNG", "JPEG", "JPG", "WEBP"], | |
| "max_file_size": "10MB", | |
| "recommended_resolution": "512x512 to 1024x1024", | |
| "processing_time": "Typically 1–3 minutes" | |
| } | |
| # 真实图片转动漫示例配置 | |
| # 格式: [输入图片路径, 结果图片路径] | |
| REAL_TO_ANIME_EXAMPLES_WITH_RESULTS = [ | |
| ["examples/real_input/example1.jpg", "examples/results/real_to_anime_example1.jpg"], | |
| ["examples/real_input/example2.jpg", "examples/results/real_to_anime_example2.jpg"], | |
| ["examples/real_input/example3.jpg", "examples/results/real_to_anime_example3.jpg"] | |
| ] | |
| # 用于显示预生成结果的映射(如果需要) | |
| REAL_TO_ANIME_RESULTS_MAP = { | |
| "examples/real_input/example1.jpg": "examples/results/real_to_anime_example1.jpg", | |
| "examples/real_input/example2.jpg": "examples/results/real_to_anime_example2.jpg", | |
| "examples/real_input/example3.jpg": "examples/results/real_to_anime_example3.jpg" | |
| } | |
| # 真实图片转动漫相关辅助函数 | |
| def get_real_to_anime_info(): | |
| return REAL_TO_ANIME_INFO.copy() | |
| def get_real_to_anime_examples(): | |
| return REAL_TO_ANIME_EXAMPLES_WITH_RESULTS.copy() | |
| def get_random_real_to_anime_examples(count=3): | |
| import random | |
| if len(REAL_TO_ANIME_EXAMPLES_WITH_RESULTS) <= count: | |
| return REAL_TO_ANIME_EXAMPLES_WITH_RESULTS.copy() | |
| return random.sample(REAL_TO_ANIME_EXAMPLES_WITH_RESULTS, count) | |
| FIVE_VIEW_GENERATION_EXAMPLES_WITH_RESULTS = [ | |
| # 格式: [输入图片路径, 结果图片路径] | |
| [ | |
| "examples/five_view_input/example1.jpg", | |
| "examples/results/five_view_example1.jpg" | |
| ] | |
| ] | |
| def get_random_five_view_examples(count=1): | |
| import random | |
| if len(FIVE_VIEW_GENERATION_EXAMPLES_WITH_RESULTS) <= count: | |
| return FIVE_VIEW_GENERATION_EXAMPLES_WITH_RESULTS.copy() | |
| return random.sample(FIVE_VIEW_GENERATION_EXAMPLES_WITH_RESULTS, count) | |
| # 3D手办生成示例配置 | |
| FIGURE_3D_EXAMPLES_WITH_RESULTS = [ | |
| # 格式: [输入图片路径, 手办风格, 结果图片路径] | |
| [ | |
| "examples/figure_3d_input_example.jpeg", | |
| "professional_lighting", | |
| "examples/results/figure_3d_professional_lighting.png" | |
| ], | |
| [ | |
| "examples/figure_3d_input_example.jpeg", | |
| "collector_shelf", | |
| "examples/results/figure_3d_collector_shelf.png" | |
| ], | |
| [ | |
| "examples/figure_3d_input_example.jpeg", | |
| "desktop_display", | |
| "examples/results/figure_3d_desktop_display.png" | |
| ] | |
| ] | |
| def get_random_figure_3d_examples(count=3): | |
| import random | |
| if len(FIGURE_3D_EXAMPLES_WITH_RESULTS) <= count: | |
| return FIGURE_3D_EXAMPLES_WITH_RESULTS.copy() | |
| return random.sample(FIGURE_3D_EXAMPLES_WITH_RESULTS, count) | |
| # 人物手办合影示例配置 | |
| CHARACTER_FIGURE_COLLABORATION_EXAMPLES_WITH_RESULTS = [ | |
| # 格式: [输入图片路径, 结果图片路径] | |
| [ | |
| "examples/character_figure_input_example1.jpeg", | |
| "examples/results/character_figure_collaboration_example1.jpg" | |
| ], | |
| [ | |
| "examples/character_figure_input_example2.jpeg", | |
| "examples/results/character_figure_collaboration_example2.jpg" | |
| ], | |
| [ | |
| "examples/character_figure_input_example3.jpeg", | |
| "examples/results/character_figure_collaboration_example3.jpg" | |
| ], | |
| [ | |
| "examples/character_figure_input_example4.jpeg", | |
| "examples/results/character_figure_collaboration_example4.jpg" | |
| ] | |
| ] | |
| def get_random_character_figure_collaboration_examples(count=1): | |
| import random | |
| if len(CHARACTER_FIGURE_COLLABORATION_EXAMPLES_WITH_RESULTS) <= count: | |
| return CHARACTER_FIGURE_COLLABORATION_EXAMPLES_WITH_RESULTS.copy() | |
| return random.sample(CHARACTER_FIGURE_COLLABORATION_EXAMPLES_WITH_RESULTS, count) | |
| # 图像扩展示例配置 - 使用多样化图片和真实AI生成的扩图结果 | |
| IMAGE_OUTPAINTING_EXAMPLES_WITH_RESULTS = [ | |
| [ | |
| "examples/outpainting_input/example1.jpg", | |
| 0.2, # 轻度扩展 - 原始测试图片 | |
| 0.3, # 中等宽度扩展 | |
| "examples/results/outpainting_example1.jpg" # 真实AI生成结果 | |
| ], | |
| [ | |
| "examples/outpainting_input/example2.jpg", | |
| 0.2, # 轻度高度扩展 - 日式住宅,适合横向扩展 | |
| 0.4, # 较大宽度扩展 | |
| "examples/results/outpainting_example2.jpg" # 待生成真实AI结果 | |
| ], | |
| [ | |
| "examples/outpainting_input/example3.jpg", | |
| 0.5, # 较大高度扩展 - 不露脸自拍,适合纵向扩展 | |
| 0.2, # 轻度宽度扩展 | |
| "examples/results/outpainting_example3.jpg" # 待生成真实AI结果 | |
| ] | |
| ] | |
| def get_random_outpainting_examples(count=3): | |
| import random | |
| if len(IMAGE_OUTPAINTING_EXAMPLES_WITH_RESULTS) <= count: | |
| return IMAGE_OUTPAINTING_EXAMPLES_WITH_RESULTS.copy() | |
| return random.sample(IMAGE_OUTPAINTING_EXAMPLES_WITH_RESULTS, count) | |