Datasets:
Download extensions/smart_batch_presets.py from AnosVoldigoad1/PAI-AI-Image-Studio-Extensions: direct link, hf CLI and curl.
- Browser
- Download file 1.7 kB
-
https://huggingface.co/datasets/AnosVoldigoad1/PAI-AI-Image-Studio-Extensions/resolve/main/extensions/smart_batch_presets.py
- Command line
-
hf download hf://datasets/AnosVoldigoad1/PAI-AI-Image-Studio-Extensions/extensions/smart_batch_presets.py
-
curl -L -o smart_batch_presets.py https://huggingface.co/datasets/AnosVoldigoad1/PAI-AI-Image-Studio-Extensions/resolve/main/extensions/smart_batch_presets.py
1.7 kB
| # -*- coding: utf-8 -*- | |
| """P.AI Extension: Smart Batch Workflow Presets (Plain Python, MIT License).""" | |
| from dataclasses import dataclass | |
| from typing import Any | |
| EXTENSION_META = { | |
| "id": "smart_batch_presets", | |
| "name": "Smart Batch Workflow Presets", | |
| "version": "1.0.0", | |
| "category": "Automation", | |
| } | |
| class BatchPipelinePreset: | |
| id: str | |
| title: str | |
| steps: tuple[str, ...] | |
| description: str | |
| BUILTIN_PRESETS: tuple[BatchPipelinePreset, ...] = ( | |
| BatchPipelinePreset( | |
| id="ecommerce_clean_pack", | |
| title="E-Commerce Pack (Remove BG -> Smart Outpaint 1:1 -> Enhance)", | |
| steps=("bg_remove", "square_1_1", "enhance"), | |
| description="Cuts out the product background, expands to 1:1 canvas, and enhances fine surface detail.", | |
| ), | |
| BatchPipelinePreset( | |
| id="portrait_studio_pack", | |
| title="Portrait Studio Pack (Smart Outpaint 4:5 -> Enhance)", | |
| steps=("square_1_1", "enhance"), | |
| description="Expands short sides to 4:5 portrait ratio and runs faithful photographic restoration.", | |
| ), | |
| ) | |
| def expand_preset_jobs(preset_id: str, input_paths: list[str]) -> list[dict[str, Any]]: | |
| """Expand a batch preset into an ordered list of workflow step descriptors for each input image.""" | |
| preset = next((p for p in BUILTIN_PRESETS if p.id == preset_id), None) | |
| if preset is None: | |
| raise KeyError(f"Unknown batch preset: {preset_id}") | |
| plan: list[dict[str, Any]] = [] | |
| for path in input_paths: | |
| for step_idx, wf in enumerate(preset.steps, start=1): | |
| plan.append({"input_path": path, "step": step_idx, "workflow": wf, "preset": preset.id}) | |
| return plan | |