topyaz is a powerful Python-based command-line interface (CLI) wrapper that brings Topaz Labs' acclaimed AI-powered image and video enhancement tools—Gigapixel AI, Photo AI, and Video AI—into a single, streamlined interface. It's designed for professionals, content creators, and developers who need to incorporate Topaz AI capabilities into batch processing workflows, automated scripts, or remote processing setups.
Current Status: This project is under active development. While core functionality for local processing is implemented, some advanced features like remote execution are planned for future releases.
- Why topyaz?
- Who is it for?
- Key Features
- Requirements
- Installation
- Usage
- Technical Deep Dive
- Coding and Contributing
- License
Topaz Labs' AI products offer exceptional quality but are primarily GUI-driven. topyaz unlocks their power for automated and high-volume tasks by:
- Unifying Access: Control Gigapixel AI, Photo AI, and Video AI from a single, consistent CLI.
- Enabling Automation: Easily integrate Topaz AI processing into scripts and larger workflows.
- Facilitating Batch Processing: Process large numbers of files efficiently.
- Preparing for Remote Execution: Designed with future support for processing on powerful remote servers (planned feature).
- Potentially Faster Operations: For batch tasks, CLI interaction can be significantly faster than manual GUI operations.
- Photo and Video Professionals: Streamline editing and enhancement pipelines.
- Content Creators: Batch-enhance images and videos for various platforms.
- Developers & System Integrators: Add Topaz AI capabilities to custom applications or automated systems.
- Power Users: Gain finer control and scripting capabilities over Topaz AI tools.
- Unified Interface: Single CLI for Gigapixel AI, Photo AI, and Video AI.
- Comprehensive Parameter Control: Access a wide range of processing parameters for each Topaz product.
- Local Execution: Leverages your existing Topaz Labs application installations.
- Configuration Management: Customize default settings and executable paths via a YAML configuration file or environment variables.
- Cross-Platform (Primarily macOS): While Topaz products are Mac-focused,
topyazaims for broader compatibility where possible. Current executable path configurations are primarily for macOS and Windows. - Informative Output: Verbose logging and system information commands.
- Operating System:
- macOS 11+ (Recommended, as Topaz products are primarily optimized for Mac)
- Windows (Supported, executable paths are configured)
- Linux (Potentially, with manual path configuration)
- Topaz Labs Applications: You must have the respective Topaz Labs applications installed:
- Topaz Gigapixel AI
- Topaz Photo AI
- Topaz Video AI
- Topaz Labs Licenses:
- Gigapixel AI CLI usage requires a Gigapixel AI Pro license. Standard licenses may not permit CLI operation.
- Ensure your Photo AI and Video AI licenses are active for full functionality.
- Python: Python 3.9 or newer.
- System Resources:
- RAM: 16GB+ recommended (32GB+ for heavy video processing).
- Storage: 80GB+ free space for applications, models, and temporary files.
- GPU: A dedicated GPU (NVIDIA, AMD, or Apple Silicon) is highly recommended for acceptable performance.
-
Install Topaz Labs Applications: Download and install Gigapixel AI, Photo AI, and Video AI from the Topaz Labs website. Ensure they are licensed and functioning correctly.
-
Install Python: If you don't have Python 3.9+ and
uv(a fast Python package installer), install them.- Python: python.org
- uv:
pip install uvor see uv installation guide.
-
Install
topyaz: Clone the repository and install usinguv:git clone https://github.com/your-username/topyaz.git # Replace with actual repo URL cd topyaz uv pip install .
Alternatively, if/when available on PyPI:
uv pip install topyaz
-
Verify Installation:
topyaz version topyaz info
These commands should report version information and details about your system and detected Topaz products. If executables are not found, you might need to configure their paths (see Configuration).
The basic structure of a topyaz command is:
topyaz [global_options] <product_command> [product_options] <input_path>
These options can be used before the product command (e.g., topyaz --verbose giga ...):
--output_dir <path>: Default directory for output files.--config_file <path>: Path to a customtopyazconfiguration YAML file.--parallel_jobs <int>: Number of parallel jobs (Note: current implementation might be limited for actual parallelism across Topaz CLIs).--timeout <seconds>: Command timeout in seconds (default: 3600).--backup_originals: Backup original files before processing.--preserve_structure: Preserve directory structure in the output directory.--dry_run: Show what commands would be run without actually processing files.--verbose: Enable verbose logging.
Processes images using Topaz Gigapixel AI.
topyaz giga <input_path> [options...]Common Gigapixel Options:
--model <name>: AI model (e.g.,std,hf,art,lowres). Default:std.--scale <int>: Upscale factor (1-6). Default: 2.--denoise <1-100>: Denoise strength.--sharpen <1-100>: Sharpen strength.--face_recovery <1-100>: Face recovery strength.--format_output <format>: Output format (e.g.,preserve,jpg,png,tiff). Default:preserve.--quality_output <1-100>: JPEG quality. Default: 95.--output <output_path>: Specific output file path.
Example:
topyaz giga ./input/image.jpg --scale 4 --model hf --output ./output/image_upscaled.jpgProcesses images using Topaz Photo AI.
topyaz photo <input_path> [options...]Common Photo AI Options:
--preset <name>: Autopilot preset (e.g.,auto,standard,strong). Default:auto.--override_autopilot: Allow manual overrides of autopilot settings.--upscale <bool>: Enable/disable upscaling.--noise <bool>: Enable/disable noise reduction.--sharpen <bool>: Enable/disable sharpening.--format_output <format>: Output format (e.g.,preserve,jpg,png,dng). Default:preserve.--output <output_path>: Specific output file path.- Many more fine-grained controls are available (e.g.,
--denoise_strength,--sharpen_model,--upscaling_factor). Usetopyaz photo -- --helpfor a full list.
Example:
topyaz photo ./input/raw_image.cr2 --override_autopilot --upscale True --sharpen True --noise False --format_output dngProcesses videos using Topaz Video AI.
topyaz video <input_path> [options...]Common Video AI Options:
--model <name>: AI model (e.g.,amq-13,prob-3). Default:amq-13.--scale <int>: Upscale factor (1-4). Default: 2.--fps <int>: Target frame rate for interpolation.--codec <name>: Video codec (e.g.,hevc_videotoolbox,av1_nvenc). Default:hevc_videotoolbox.--quality <value>: Video quality/CRF value (e.g., 18 for H.265). Default: 18.--stabilize: Enable stabilization.--interpolate: Enable frame interpolation.--output <output_path>: Specific output file path.
Example:
topyaz video ./input/clip.mp4 --model prob-3 --scale 2 --interpolate --fps 60 --codec hevc_nvenc --output ./output/clip_enhanced.mp4topyaz info: Displays system information, detected Topaz products, GPU status, and memory.topyaz version: Shows the version oftopyazand detected Topaz product versions.
You can use topyaz functionalities within your Python scripts.
1. Using TopyazCLI (recommended for simplicity):
from topyaz.cli import TopyazCLI
from topyaz.core.types import ProcessingOptions
# Configure global options if needed
cli_options = {
"output_dir": "./processed_media",
"verbose": True,
"dry_run": False
}
# Instantiate TopyazCLI. Global options are passed to the constructor.
# Product-specific options are passed to the respective methods.
cli = TopyazCLI(**cli_options)
# Process an image with Gigapixel AI
giga_success = cli.giga(
input_path="./my_images/photo.jpg",
model="hf",
scale=2,
denoise=50
)
if giga_success:
print("Gigapixel AI processing successful!")
# Process a video with Video AI
video_success = cli.video(
input_path="./my_videos/short.mov",
model="amq-13",
scale=2,
interpolate=True,
fps=60
)
if video_success:
print("Video AI processing successful!")
# Process a photo with Photo AI
photo_success = cli.photo(
input_path="./my_images/portrait.nef",
preset="auto",
override_autopilot=True,
sharpen=True
)
if photo_success:
print("Photo AI processing successful!")2. Using individual product classes (for more direct control):
from topyaz.execution.local import LocalExecutor
from topyaz.execution.base import ExecutorContext
from topyaz.core.types import ProcessingOptions
from topyaz.products.gigapixel.api import GigapixelAI
from pathlib import Path
# Common processing options
options = ProcessingOptions(
output_dir=Path("./api_output"),
verbose=True,
timeout=7200 # 2 hours
)
# Setup executor
executor_context = ExecutorContext(timeout=options.timeout, dry_run=options.dry_run)
executor = LocalExecutor(context=executor_context)
# Gigapixel AI example
gigapixel_processor = GigapixelAI(executor=executor, options=options)
result = gigapixel_processor.process(
input_path="./my_images/landscape.tiff",
output_path="./api_output/landscape_giga.tiff", # Optional, can be auto-generated
model="standard",
scale=2,
sharpen=30
)
if result.success:
print(f"Gigapixel processed: {result.output_path}")
print(f"Execution time: {result.execution_time:.2f}s")
else:
print(f"Gigapixel processing failed: {result.error_message}")
# Similar instantiation and usage for PhotoAI and VideoAI classes
# from topyaz.products.photo_ai.api import PhotoAI
# from topyaz.products.video_ai.api import VideoAIThe topyaz codebase is organized into several key directories under src/topyaz/:
core/: Contains core data types (types.py), configuration management (config.py), and error definitions (errors.py).cli.py: Defines the mainTopyazCLIclass, whichpython-fireuses to generate the command-line interface.execution/: Handles command execution.base.py: Abstract base class for executors.local.py: Implements local command execution usingsubprocess.
products/: Contains implementations for each Topaz Labs product.base.py: Abstract base classTopazProductfor all product integrations.gigapixel/,photo_ai/,video_ai/: Subdirectories for each product, typically containing:api.py: The main class for interacting with the product (e.g.,GigapixelAI).params.py: Parameter handling and validation logic.- Other product-specific modules (e.g.,
preferences.pyfor Photo AI).
system/: Modules for interacting with the system (environment validation, GPU info, memory status, path handling).utils/: Utility modules like logging.
TopyazCLI(cli.py): The main entry point for CLI operations. It instantiates product handlers and delegates commands.TopazProduct(products/base.py): An abstract base class defining the interface for all product integrations (finding executables, building commands, parsing output, etc.).MacOSTopazProductextends this with macOS-specific helpers.- Product API Classes (e.g.,
GigapixelAIinproducts/gigapixel/api.py): Implement theTopazProductinterface for a specific Topaz tool. They manage parameter validation, command construction using the tool's CLI syntax, and parsing its output. CommandExecutor(execution/base.py&local.py): Responsible for actually running the generated commands.LocalExecutoruses Python'ssubprocessmodule.Config(core/config.py): Loads and manages configuration settings from YAML files (default:~/.topyaz/config.yaml) and environment variables (e.g.,TOPYAZ_DEFAULTS__OUTPUT_DIR). This includes paths to Topaz product executables.- Data Classes (
core/types.py): Define structured data for options, parameters, results, and system information, promoting type safety and clarity.
topyaz uses a hierarchical configuration system:
- Default Values: Hardcoded in
core/config.py. - System Config File:
~/.topyaz/config.yaml(on Linux/macOS) or user profile equivalent on Windows. - User-Specified Config File: Passed via the
--config_fileglobal option. - Environment Variables: Prefixed with
TOPYAZ_(e.g.,TOPYAZ_VIDEO__DEFAULT_MODEL=amq-13). Double underscores (__) denote nesting.
The most important configuration items are the paths to the Topaz product executables. topyaz attempts to find these automatically, but they can be explicitly set in the config.yaml under the paths key if needed:
# Example ~/.topyaz/config.yaml
defaults:
output_dir: "~/topyaz_output"
verbose: true
paths:
gigapixel:
macos: ["/Applications/Topaz Gigapixel AI.app/Contents/Resources/bin/gigapixel"]
# windows: ["C:/Program Files/Topaz Labs LLC/Topaz Gigapixel AI/gigapixel.exe"]
photo_ai:
macos: ["/Applications/Topaz Photo AI.app/Contents/Resources/bin/tpai"]
video_ai:
macos: ["/Applications/Topaz Video AI.app/Contents/MacOS/ffmpeg"]- User runs a
topyazcommand (e.g.,topyaz giga input.jpg --scale 2). python-fireroutes this to the appropriate method inTopyazCLI(e.g.,TopyazCLI.giga()).TopyazCLIinitializes commonProcessingOptionsand the relevant product handler (e.g.,GigapixelAI).- The product handler (
GigapixelAI):- Finds the Gigapixel AI executable using configured/default paths.
- Validates the provided parameters (e.g., scale is within range).
- Builds the command-line string specific to Gigapixel AI's CLI syntax (e.g.,
gigapixel --cli -i input.jpg -o output_temp.jpg --scale 2 ...). - For Gigapixel/Photo AI, output is typically directed to a temporary directory. Video AI often writes directly.
- The
LocalExecutorruns this command usingsubprocess.run(). - After execution:
- The product handler parses the
stdoutandstderrfrom the Topaz tool for information or errors. - If a temporary directory was used, the output file is moved to its final destination.
- The product handler parses the
- A
ProcessingResultobject is returned, indicating success/failure and other details. TopyazCLIlogs the result and exits.
Contributions are welcome! Please adhere to the following guidelines.
(Summarized from CLAUDE.md)
- Iterate Gradually: Make small, incremental changes.
- Preserve Existing Code: Avoid unnecessary refactoring or removal of existing structure unless essential.
- Focus on MVP: Prioritize minimal viable increments and ship early.
- Clarity and Simplicity: Write clear, descriptive names and comments. Explain the "what" and "why."
- Robustness: Handle failures gracefully, validate inputs, and address edge cases.
- Modularity: Encapsulate repeated logic into concise, single-purpose functions.
- Maintain Overview: Keep a holistic understanding of the codebase and how components interact.
(Summarized from CLAUDE.md)
- Package Management: Use
uv pipfor managing dependencies. - Running Code: Use
python -mwhen applicable. - Formatting: Adhere to PEP 8 for consistent formatting and naming.
- Simplicity & Readability (PEP 20): Prioritize clean, explicit code over overly complex solutions.
- Type Hints: Use simple type hints (e.g.,
list,dict,|for unions). - Docstrings (PEP 257): Write clear, imperative docstrings for modules, classes, and functions.
- F-strings: Preferred for string formatting.
- Logging: Implement
loguru-based logging, including verbose/debug modes. - CLI Scripts: If adding new top-level scripts, consider using
python-fireandrichfor output. Start scripts with:#!/usr/bin/env -S uv run -s # /// script # dependencies = ["PKG1", "PKG2"] # /// # this_file: path/to/current_file.py
- File Path Records: Maintain an up-to-date
this_filecomment near the top of each source file, indicating its path relative to the project root.
(Summarized from CLAUDE.md)
- Planning: Use
PLAN.mdfor detailed flat plans andTODO.mdfor tracking items. - Changelog: Update
CHANGELOG.mdafter each significant round of changes. - README Updates: Keep
README.mdsynchronized with codebase changes. - Cleanup: After Python changes, run
./cleanup.shif it performs necessary actions like formatting or linting. - Testing: Write tests for new features and bug fixes. Ensure tests pass before submitting changes.
This project is licensed under the MIT License. Please note that the underlying Topaz Labs products have their own commercial licenses and terms of service.