seedream4 / README.md
wapadil
refactor: eliminate dual-architecture confusion (app.py vs app_simple.py)
8e84eda
metadata
title: SeedDream v4 Editor - Optimized
emoji: 🎨
colorFrom: purple
colorTo: pink
sdk: docker
app_port: 7860
pinned: false
license: mit

SeedDream v4 Editor - Optimized

ByteDance SeedDream v4 图像编辑器的优化版本。

🚀 架构特性

模块化设计

  • 清晰的分层架构:Flask应用 + API模块 + FAL客户端
  • 同步API模式:使用FAL queue模式,避免复杂的异步处理
  • 类型安全:正确处理FAL SDK的状态对象(Queued/InProgress/Completed)

部署自动化

  • GitHub Actions:自动同步到 Hugging Face Spaces
  • 环境管理:统一的环境变量配置
  • 健康监控:内置健康检查端点

🛠️ 本地开发

# 安装依赖
pip install -r requirements.txt

# 运行应用
python app.py

A web-based interface for AI-powered image generation and editing using ByteDance's SeedDream v4 models via the FAL API.

Features

  • 🎨 Dual Mode: Switch between Image Editing and Text-to-Image generation
  • 📤 Support for multiple image uploads (up to 10 images for editing)
  • 🔗 URL-based image input support
  • ⚙️ Customizable generation settings with smart dimension detection
  • 🔒 Safety checker disabled for unrestricted creativity
  • 🐳 Docker containerized for easy deployment
  • 🚀 Hugging Face Spaces compatible

Quick Start

Local Development

  1. Clone the repository

    git clone <your-repo-url>
    cd fal_ui
    
  2. Install dependencies

    # Install Python dependencies
    pip install -r requirements.txt
    
  3. Run the application

    python app.py
    

    The app will be available at http://localhost:7860

Docker Deployment

  1. Build the Docker image

    docker build -t seedream-editor .
    
  2. Run the container

    docker run -p 7860:7860 seedream-editor
    

Deployment on Hugging Face Spaces

Method 1: Direct Deployment

  1. Go to Hugging Face Spaces
  2. Click "Create new Space"
  3. Choose "Docker" as the SDK
  4. Upload all project files
  5. The application is ready to deploy - users will enter their API key directly in the interface

Method 2: Using Git

  1. Create a new Space on Hugging Face

  2. Clone your space locally:

    git clone https://huggingface.co/spaces/YOUR_USERNAME/YOUR_SPACE_NAME
    cd YOUR_SPACE_NAME
    
  3. Copy all project files to the space directory

  4. Create a .gitignore file:

    __pycache__/
    *.pyc
    .env
    
  5. Push to Hugging Face:

    git add .
    git commit -m "Initial commit"
    git push
    

Configuration

API Key

The FAL API key is entered directly in the web interface:

  • Enter your API key in the "API Configuration" section at the top of the page
  • The key is stored locally in your browser (localStorage)
  • Get your API key from fal.ai

Model Selection

Choose between two powerful models:

  • Image Edit Mode: fal-ai/bytedance/seedream/v4/edit - Edit existing images with prompts
  • Text-to-Image Mode: fal-ai/bytedance/seedream/v4/text-to-image - Generate new images from text

Environment Variables

  • PORT: Port number (default: 7860)
  • SPACE_ID: Automatically set by Hugging Face Spaces

Project Structure

fal_ui/
├── app.py                 # Flask application (main entry point)
├── api/
│   ├── routes.py          # API endpoints
│   └── fal_client.py      # FAL API client wrapper
├── monitoring.py          # Logging and monitoring
├── requirements.txt       # Python dependencies
├── Dockerfile            # Docker configuration
├── templates/
│   └── index.html        # Frontend interface
├── static/
│   ├── style.css         # Styling
│   └── script.js         # Frontend logic
└── README.md             # Documentation

Features Overview

Image Input

  • File Upload: Select multiple images from your device
  • URL Input: Paste image URLs directly
  • Preview: Visual preview of uploaded images

Generation Settings

  • Image Size: Preset sizes or custom dimensions (1024-4096px)
  • Number of Generations: Control output quantity
  • Seed: Optional seed for reproducible results
  • Safety Checker: Toggle content filtering

API Integration

  • Automatic API key management
  • Real-time progress logging
  • Error handling and status updates

Security Notes

  • Never expose your FAL API key in client-side code
  • The application uses server-side proxy for API calls
  • API keys can be stored in environment variables or Hugging Face secrets

Troubleshooting

Common Issues

  1. API Key Error

    • Ensure you've entered your FAL API key in the interface
    • Check if the key has proper permissions
    • Get a new key from fal.ai if needed
  2. Docker Build Fails

    • Verify all files are in the correct directories
    • Check Docker daemon is running
  3. Hugging Face Deployment Issues

    • Ensure Dockerfile is present
    • Check logs in the Space settings

Support

For issues related to:

License

This project is provided as-is for educational and development purposes.

Acknowledgments