Skip to content

🎨 A modern AI image generator Desktop App built with Flet with Material Design. Features prompt enhancement with microsoft/phi-4, and high-quality image generation using black-forest-labs/flux-dev.

Notifications You must be signed in to change notification settings

nasoma/ai-imagegen-flet

Repository files navigation

AI Image Generator

A modern AI image generation application built with Flet and Material Design 3, featuring a beautiful dark green forest theme.

AI Image Generator Demo

Screenshot showing the AI Image Generator application with its Material Design 3 forest theme

Project Structure

The application is organized into multiple modules for better maintainability and clean separation of concerns:

📁 Files Overview

  • main.py - Main application entry point and core app logic
  • config.py - Configuration constants and Material Design 3 colors
  • ui_components.py - Reusable UI component factories and utilities
  • api_client.py - API client for handling Nebius AI interactions
  • material-theme.json - Material Design 3 theme configuration

🎨 Key Features

  • Material Design 3 Theme: Custom dark green forest theme with proper color tokens
  • Responsive UI: Clean, modern interface with shadows and proper spacing
  • API Integration: Seamless integration with Nebius AI for image generation
  • Secure Storage: API keys stored securely using keyring
  • Error Handling: Comprehensive error handling with user-friendly messages
  • Modular Architecture: Clean separation of concerns for maintainability

Installation

  1. Install required dependencies using uv:
uv add flet requests keyring openai pillow
  1. Run the application:
uv run python main.py

Alternatively, if you don't have uv installed:

pip install uv
uv sync
uv run python main.py

Usage

  1. Configure API Key: Click the settings button and enter your Nebius AI API key
  2. Enter Prompt: Describe the image you want to generate
  3. Enhance Prompt (Optional): Use AI to improve your prompt
  4. Select Size: Choose from predefined sizes or enter custom dimensions
  5. Generate Image: Click generate and wait for your AI-created image
  6. Download: Save the generated image to your Downloads folder

AI Models

The application uses two AI models from Nebius AI:

  • Prompt Enhancement: microsoft/phi-4 - Enhances and improves user prompts for better image generation
  • Image Generation: black-forest-labs/flux-dev - Generates high-quality images from text prompts

Theme Customization

You can customize the app's appearance using Material Design 3 themes:

  1. Create Custom Theme: Visit Material Theme Builder
  2. Design Your Theme: Choose your preferred colors and generate a custom theme
  3. Download: Export and download the material-theme.json file
  4. Replace: Replace the existing material-theme.json in the project directory
  5. Update Colors: Modify the MD3Colors class in config.py to use your new theme colors

The theme builder allows you to:

  • Choose custom seed colors
  • Preview light and dark modes
  • Generate complete Material Design 3 color schemes
  • Export ready-to-use color tokens

Module Details

config.py

  • Material Design 3 color tokens
  • Application constants and configuration
  • Image size mappings and constraints
  • API endpoints and model configurations

ui_components.py

  • UIFactory: Factory for creating consistent UI components
  • MainViewComponents: Components specific to the main view
  • SettingsViewComponents: Components for the settings page
  • Reusable component creation with proper styling

api_client.py

  • APIClient: Handles all API interactions with Nebius AI
  • MockAPIClient: Mock client for testing purposes
  • Async operations with proper error handling
  • Error categorization for user-friendly messages

main.py

  • ImageGeneratorApp: Main application class
  • UI creation and management
  • Event handling and navigation
  • Integration of all modules

Development

To test the module structure:

uv run python test_imports.py

This will verify all imports work correctly and test basic functionality.

Theme

The application uses a custom Material Design 3 theme with:

  • Primary: Forest Green (#4A662D)
  • Secondary: Muted Olive (#57624A)
  • Tertiary: Teal Accent (#386664)
  • Surface: Light Green-White (#F9FAEF)
  • Error: Standard MD3 Red (#BA1A1A)

License

This project is licensed under the MIT License.

About

🎨 A modern AI image generator Desktop App built with Flet with Material Design. Features prompt enhancement with microsoft/phi-4, and high-quality image generation using black-forest-labs/flux-dev.

Topics

Resources

Stars

Watchers

Forks

Languages