跳到主要内容
WebUI LiuMo Batch:AIGC 工作流批量生成平台解析 | 极客日志
JavaScript AI 大前端
WebUI LiuMo Batch:AIGC 工作流批量生成平台解析 综述由AI生成 WebUI LiuMo Batch 是一款基于纯前端技术栈构建的 Stable Diffusion 批量生成工具。它通过配置即代码的理念,利用 JSON 配置文件管理提示词和参数,解决了传统单张生成效率低、参数管理混乱的问题。核心功能包括多标签页并行管理、智能队列调度、浮动控制面板及图片参数逆向提取。项目采用单例模式管理状态,支持本地存储持久化,并具备插件扩展架构。适用于角色设计批量产出、参数对比研究及电商内容创作等场景,显著提升了 AIGC 工作流的生产效率。
moshang 发布于 2026/4/10 更新于 2026/6/8 24 浏览WebUI LiuMo Batch:AIGC 工作流批量生成平台解析
引言:AIGC 工作流优化的新范式
在当今人工智能生成内容(AIGC)快速发展的时代,Stable Diffusion 等文生图模型已成为创意工作者和研究人员的重要工具。然而,随着应用场景的不断扩展,传统 WebUI 的单张图像生成模式已难以满足批量生产 、参数对比 和工作流管理 的复杂需求。正是在这样的背景下,WebUI LiuMo Batch 应运而生,它将工作流思维 与批量处理能力 深度融合,为 AIGC 创作提供了全新的解决方案。
WebUI LiuMo Batch 是一款基于现代 Web 技术栈构建的创新型批量生成平台,充分利用了 Stable Diffusion WebUI 的 API 接口,通过多标签页管理 、JSON 配置驱动 和智能队列系统 三大核心机制,彻底改变了用户与 AI 图像生成模型的交互方式。本文将从项目架构、核心代码、功能特性、应用场景等多个维度对这一开源项目进行剖析。
一、项目概述与核心价值
1.1 项目定位与特色
WebUI LiuMo Batch 并非简单的界面封装,而是一个完整的AIGC 工作流管理系统 。它解决了传统使用方式中的多个痛点:
批量处理效率低下 :传统方式需手动逐张调整参数并生成
参数管理混乱 :难以系统化管理大量提示词组合和参数配置
工作流不可复用 :成功的生成配置无法轻松保存和重复使用
进度监控缺失 :缺乏对长时间批量任务的实时监控机制
该项目以 '配置即代码' 为核心理念,将复杂的生成参数封装为结构化的 JSON 配置文件,通过可视化界面进行管理,同时保留了代码级配置的灵活性和可复用性。
1.2 技术架构概览
WebUI LiuMo Batch 采用纯前端技术栈实现,主要包含以下层次:
呈现层 :基于 HTML5、CSS3 和 SVG 图标系统,采用深色主题设计
交互层 :使用原生 JavaScript 实现,无第三方框架依赖
通信层 :通过 Fetch API 与 Stable Diffusion WebUI 的 REST API 交互
状态管理层 :自定义的 AppState 全局状态管理机制
数据持久层 :基于浏览器 LocalStorage 的配置保存和恢复
下表展示了项目的核心功能模块及其相互关系:
模块名称 主要功能 技术实现 依赖关系 侧边栏管理 文件浏览、队列管理、API 配置 CSS 变量主题、折叠动画 独立模块 标签页系统 多配置并行编辑、快速切换 动态 DOM 操作、事件委托 状态管理 队列引擎 任务调度、进度监控、错误处理
浮动控制面板 实时控制、进度显示、拖拽交互 绝对定位、拖拽事件 队列引擎
配置管理器 JSON 导入导出、参数解析 JSON 序列化、文件 API 标签页系统
图片画廊 生成结果预览、元数据显示 栅格布局、模态框 状态管理
二、核心架构深度解析
2.1 全局状态管理设计 项目的核心是精心设计的全局状态管理对象 AppState,它采用单例模式 管理整个应用的状态:
const AppState = {
sidebarCollapsed : false ,
jsonFiles : [],
selectedJsonPath : null ,
executionQueue : [],
isQueueRunning : false ,
tabs : [],
activeTabId : null ,
nextTabId : 1 ,
commonGallery : [],
apiUrl : 'http://127.0.0.1:7860' ,
currentFolderPath : null ,
sdModels : [],
vaeModels : [],
modelsLoaded : false ,
nextTaskId : 1 ,
progressTimer : null ,
originalTitle : null ,
isExecutionRunning : false ,
isContinuousMode : false ,
currentExecutionStartTime : null ,
currentExecutionType : null ,
currentProgress : {
current : 0 ,
total : 0 ,
currentTaskName : '' ,
startTime : null
},
currentImageProgress : 0 ,
currentImageIndex : 0 ,
floatingPanelState : {
isVisible : true ,
position : {x : null , y : null },
isDragging : false ,
dragOffset : {x : 0 , y : 0 }
}
};
状态集中管理 :所有应用状态集中在一个对象中,便于调试和持久化
响应式更新 :状态变化后通过专门函数更新 UI,保持一致性
序列化友好 :便于保存到 LocalStorage 或导出为备份
类型清晰 :通过详细的注释说明每个字段的用途和结构
2.2 响应式 UI 更新机制 项目采用手动 DOM 更新 而非虚拟 DOM 方案,通过精心设计的更新函数实现高效 UI 同步:
function updateJsonList ( ) {
dom.jsonList .innerHTML = '' ;
dom.jsonCount .textContent = AppState .jsonFiles .length ;
AppState .jsonFiles .forEach ((jsonFile, index ) => {
const li = document .createElement ('li' );
li.className = `json-item ${AppState.sidebarCollapsed ? 'collapsed' : '' } ` ;
if (jsonFile.path === AppState .selectedJsonPath ) {
li.classList .add ('active' );
}
li.innerHTML = AppState .sidebarCollapsed ?
`<svg>...</svg>` :
`<div title="${jsonFile.name} ">${jsonFile.name} </div> <div> <button title="添加到队列"> <svg>...</svg> </button> <div>${jsonFile.content.version || 'v1.0' } </div> </div>` ;
li.addEventListener ('click' , () => openJsonInTab (jsonFile));
if (!AppState .sidebarCollapsed ) {
const addQueueBtn = li.querySelector ('.add-queue' );
addQueueBtn.addEventListener ('click' , (e ) => {
e.stopPropagation ();
addToQueue (jsonFile);
});
}
dom.jsonList .appendChild (li);
});
}
精确控制 :只更新必要的 DOM 元素,避免不必要的重绘
条件渲染 :根据应用状态(如侧边栏折叠状态)动态调整显示内容
事件委托优化 :在元素创建时直接绑定事件,避免全局事件委托的开销
内存管理 :每次更新前清空容器,避免内存泄漏
2.3 API 通信与错误处理 与 Stable Diffusion WebUI 的通信通过统一的 API 层实现:
async function generateImageWithConfig (config, prompt, taskName ) {
const apiUrl = config.apiUrl || AppState .apiUrl ;
const params = {
prompt : prompt,
negative_prompt : config.globalParams .negativePrompt || '' ,
seed : config.globalParams .seed === -1 ? -1 : parseInt (config.globalParams .seed ),
steps : parseInt (config.globalParams .steps ),
width : parseInt (config.globalParams .width ),
height : parseInt (config.globalParams .height ),
cfg_scale : parseFloat (config.globalParams .cfgScale ),
sampler_name : config.globalParams .sampler || 'DPM++ 2M Karras' ,
batch_size : 1 ,
n_iter : 1 ,
save_images : config.globalParams .autoSave !== false
};
if (config.globalParams .sdModel ) {
params.override_settings = {sd_model_checkpoint : config.globalParams .sdModel };
}
const controller = new AbortController ();
const timeoutId = setTimeout (() => controller.abort (), 300000 );
try {
const response = await fetch (`${apiUrl} /sdapi/v1/txt2img` , {
method : 'POST' ,
headers : {'Content-Type' : 'application/json' },
body : JSON .stringify (params),
signal : controller.signal
});
clearTimeout (timeoutId);
if (!response.ok ) {
throw new Error (`API 请求失败:${response.status} ${response.statusText} ` );
}
const result = await response.json ();
if (!result.images || result.images .length === 0 ) {
throw new Error ('API 返回的图片为空' );
}
let imageData = result.images [0 ];
if (!imageData.startsWith ('data:' )) {
imageData = `data:image/png;base64,${imageData} ` ;
}
return {
image : imageData,
seed : result.seed || config.globalParams .seed ,
info : result.info || {}
};
} catch (error) {
clearTimeout (timeoutId);
throw new Error (`生图失败:${error.message} ` );
}
}
参数标准化 :将前端配置转换为 WebUI API 要求的格式
超时控制 :防止长时间挂起的请求阻塞系统
错误恢复 :详细的错误分类和处理策略
数据验证 :确保 API 响应符合预期格式
三、关键模块实现详解
3.1 标签页系统:多工作流并行管理 标签页系统是 WebUI LiuMo Batch 的核心创新之一,它允许用户同时管理多个生成配置:
function createNewTab (name, jsonFile = null ) {
const tabId = `tab-${AppState.nextTabId++} ` ;
const tab = {
id : tabId,
name : name,
jsonPath : jsonFile?.path || null ,
jsonName : jsonFile?.name || null ,
state : createTabState ()
};
AppState .tabs .push (tab);
AppState .activeTabId = tabId;
createTabHeader (tab);
createTabContent (tab);
updateTabDisplay ();
return tabId;
}
function createTabState ( ) {
return {
prompts : [{id : 1 , label : '示例提示词' , text : 'masterpiece, best quality, 1girl, beautiful detailed eyes, in a garden, sunlight' }],
nextId : 2 ,
isGenerating : false ,
currentQueue : [],
results : [],
autoSaveEnabled : true ,
maxHistoryImages : 10 ,
commonPrompt : ''
};
}
独立状态隔离 :每个标签页拥有完全独立的状态对象
资源标识系统 :使用 tab-{id} 格式确保 DOM 元素 ID 唯一性
懒加载设计 :标签页内容仅在激活时渲染,优化性能
状态快照 :支持将标签页状态保存为 JSON 配置
3.2 队列引擎:智能任务调度 队列引擎负责管理批量生成任务的执行顺序、状态跟踪和错误处理:
async function startQueueExecution ( ) {
if (AppState .executionQueue .length === 0 ) {
showNotification ('队列为空' , 'warning' );
return ;
}
if (AppState .isQueueRunning ) {
showNotification ('队列正在执行中' , 'info' );
return ;
}
AppState .isQueueRunning = true ;
AppState .currentExecutionType = 'queue' ;
AppState .currentExecutionStartTime = new Date ();
let totalPrompts = 0 ;
AppState .executionQueue .forEach (queueItem => {
if (queueItem.config && queueItem.config .prompts ) {
totalPrompts += queueItem.config .prompts .length ;
}
});
AppState .currentProgress = {
current : 0 ,
total : totalPrompts,
currentTaskName : '' ,
currentTaskIndex : 0
};
do {
for (let i = 0 ; i < AppState .executionQueue .length ; i++) {
if (!AppState .isQueueRunning ) break ;
const queueItem = AppState .executionQueue [i];
queueItem.status = 'running' ;
updateQueueList ();
AppState .currentProgress .currentTaskName = queueItem.jsonName ;
AppState .currentProgress .currentTaskIndex = i + 1 ;
updateProgressDisplay ();
try {
await executeJsonGeneration (queueItem, AppState .currentProgress );
queueItem.status = 'completed' ;
showNotification (`完成:${queueItem.jsonName} ` , 'success' );
} catch (error) {
queueItem.status = 'failed' ;
showNotification (`失败:${queueItem.jsonName} : ${error.message} ` , 'danger' );
}
updateQueueList ();
}
if (AppState .isContinuousMode && AppState .isQueueRunning ) {
showNotification ('开始新一轮队列执行' , 'info' );
AppState .executionQueue .forEach (item => {
item.status = 'pending' ;
});
AppState .currentProgress .current = 0 ;
}
} while (AppState .isContinuousMode && AppState .isQueueRunning );
AppState .isQueueRunning = false ;
AppState .currentExecutionType = null ;
stopProgressPolling ();
updateExecutionButtons (false );
showNotification ('队列执行完成' , 'success' );
}
特性 实现机制 优势 任务状态跟踪 pending/running/completed/failed 四状态模型 清晰的执行进度可视化 错误隔离 单任务错误不影响队列继续执行 提高批量任务成功率 连续执行模式 循环执行队列直到手动停止 适合长期稳定运行场景 进度实时更新 浏览器标题 + 浮动面板双重显示 多任务监控便捷 资源释放 执行完成自动清理定时器和状态 避免内存泄漏
3.3 浮动控制面板:交互设计创新 浮动控制面板是项目的 UI 设计亮点,实现了可拖拽、可最小化的控制中心:
function setupDragAndDrop ( ) {
const panel = dom.floatingControlPanel ;
const header = panel.querySelector ('.floating-control-panel-header' );
let isDragging = false ;
let startX, startY;
let initialLeft, initialTop;
header.addEventListener ('mousedown' , startDrag);
function startDrag (e ) {
isDragging = true ;
startX = e.clientX ;
startY = e.clientY ;
const rect = panel.getBoundingClientRect ();
initialLeft = rect.left ;
initialTop = rect.top ;
panel.classList .add ('dragging' );
document .addEventListener ('mousemove' , drag);
document .addEventListener ('mouseup' , stopDrag);
}
function drag (e ) {
if (!isDragging) return ;
const dx = e.clientX - startX;
const dy = e.clientY - startY;
let newLeft = initialLeft + dx;
let newTop = initialTop + dy;
const maxX = window .innerWidth - panel.offsetWidth ;
const maxY = window .innerHeight - panel.offsetHeight ;
newLeft = Math .max (0 , Math .min (newLeft, maxX));
newTop = Math .max (0 , Math .min (newTop, maxY));
panel.style .left = `${newLeft} px` ;
panel.style .top = `${newTop} px` ;
panel.style .transform = 'none' ;
AppState .floatingPanelState .position .x = newLeft;
AppState .floatingPanelState .position .y = newTop;
}
function stopDrag ( ) {
if (!isDragging) return ;
isDragging = false ;
panel.classList .remove ('dragging' );
savePanelState ();
document .removeEventListener ('mousemove' , drag);
document .removeEventListener ('mouseup' , stopDrag);
}
}
不打扰原则 :可拖拽到屏幕任何位置,避免遮挡工作区
状态持久化 :位置和可见性状态自动保存
最小化模式 :不需要时可缩为小图标,节省屏幕空间
实时反馈 :执行状态通过颜色和动画直观显示
3.4 图片参数导入:逆向工程创新 async function extractImageInfo (file ) {
try {
const imageBase64 = await new Promise ((resolve, reject ) => {
const reader = new FileReader ();
reader.onload = () => resolve (reader.result .split (',' )[1 ]);
reader.onerror = reject;
reader.readAsDataURL (file);
});
const response = await fetch (`${AppState.apiUrl} /sdapi/v1/png-info` , {
method : 'POST' ,
headers : {'Content-Type' : 'application/json' },
body : JSON .stringify ({image : `data:image/png;base64,${imageBase64} ` })
});
if (!response.ok ) throw new Error (`API 请求失败:${response.status} ` );
const data = await response.json ();
if (!data.info ) throw new Error ('图片中未找到生成信息' );
return parseGenerationInfo (data.info );
} catch (error) {
return await extractPNGInfoManually (file);
}
}
function parseGenerationInfo (infoString ) {
const result = {
prompt : '' ,
negativePrompt : '' ,
sampler : '' ,
steps : 20 ,
cfgScale : 7 ,
seed : -1 ,
width : 512 ,
height : 512 ,
model : '' ,
hires : {enable : false , scale : 2 , denoiseStrength : 0.7 , upscaler : 'Latent' }
};
if (infoString.trim ().startsWith ('{' )) {
try {
const jsonInfo = JSON .parse (infoString);
} catch (e) {
}
}
const lines = infoString.split ('\n' );
return result;
}
工作流逆向 :从结果反推参数,实现"效果复用"
多格式支持 :兼容 JSON 和文本两种常见参数格式
错误恢复 :主 API 失败时自动使用备用解析方案
智能匹配 :尝试匹配当前可用的模型和采样器
四、配置文件系统与数据流
4.1 JSON 配置规范 WebUI LiuMo Batch 定义了一套完整的 JSON 配置规范:
{
"version" : "2.0" ,
"exportDate" : "2025-01-04T10:30:00.000Z" ,
"globalParams" : {
"sdModel" : "dreamshaper_8.safetensors" ,
"vaeModel" : "Automatic" ,
"negativePrompt" : "lowres, bad anatomy, worst quality, low quality" ,
"sampler" : "DPM++ 2M Karras" ,
"steps" : 25 ,
"width" : 512 ,
"height" : 768 ,
"cfgScale" : 7 ,
"seed" : -1 ,
"batchCount" : 1 ,
"clipSkip" : 1 ,
"enableHr" : false ,
"hrScale" : 2 ,
"denoiseStrength" : 0.7 ,
"hrUpscaler" : "Latent" ,
"hrSecondPassSteps" : 0 ,
"autoSave" : true
} ,
"commonPrompt" : "masterpiece, best quality, 1girl, beautiful detailed eyes" ,
"prompts" : [
{ "label" : "花园场景" , "text" : "in a garden, sunlight, cherry blossoms" } ,
{ "label" : "室内场景" , "text" : "indoors, cozy room, window light, reading book" }
] ,
"apiUrl" : "http://127.0.0.1:7860"
}
语义化字段 :字段名直观反映功能
版本控制 :包含 version 字段便于未来格式升级
完整上下文 :包含生成所需的所有参数
可读性优先 :合理的缩进和结构便于手动编辑
4.2 数据流架构 用户操作 → 事件处理器 → 状态更新 → UI 渲染 → API 调用 → 结果处理 → 状态更新 → UI 反馈
↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
点击按钮 → 解析参数 → 更新 AppState → 重绘 DOM → 调用 SD API → 保存图片 → 更新画廊 → 显示通知
UI 到配置 :表单输入转换为 JSON 配置对象
配置到 API 参数 :前端配置转换为 WebUI API 参数
API 响应到状态 :生成结果转换为应用状态
状态到持久化 :应用状态保存为 LocalStorage 或文件
五、项目中的关键技术栈应用
5.1 现代 CSS 特性应用 :root {
--bg-primary : #0d1117 ;
--bg-secondary : #161b22 ;
--bg-tertiary : #21262d ;
--border-color : #30363d ;
--text-primary : #f0f6fc ;
--text-secondary : #8b949e ;
--accent-color : #238636 ;
--accent-hover : #2ea043 ;
--sidebar-width : 300px ;
--sidebar-collapsed-width : 60px ;
}
.common-gallery-content {
display : grid;
grid-template-columns : repeat (auto-fill, minmax (150px , 1 fr));
gap : 0.5rem ;
}
.app-container {
display : flex;
min-height : 100vh ;
}
.image-thumb :hover .image-info {
opacity : 1 ;
transition : opacity 0.2s ;
}
@media (max-width: 768px ) {
.floating-control-panel {
min-width : 90% ;
left : 5% ;
transform : none;
}
}
设计令牌系统 :通过 CSS 变量统一设计规范
响应式断点 :针对不同屏幕尺寸优化布局
性能优化 :使用 transform 和 opacity 实现高效动画
可维护性 :模块化的 CSS 结构便于扩展
5.2 JavaScript 设计模式应用 设计模式 应用场景 代码示例 单例模式 全局状态管理 AppState 全局对象观察者模式 事件通知系统 showNotification 函数工厂模式 标签页创建 createNewTab 函数策略模式 图片解析器 parseGenerationInfo 支持多种格式命令模式 队列任务 executionQueue 中的任务对象备忘录模式 状态持久化 saveToLocalStorage 函数
结构清晰 :各模块职责明确,耦合度低
易于测试 :独立的功能单元便于单元测试
可扩展性强 :新功能可通过添加新策略实现
维护成本低 :标准化的模式降低理解成本
六、API 接口封装与通信机制
6.1 WebUI API 封装层 项目实现了对 Stable Diffusion WebUI API 的完整封装:
const API_ENDPOINTS = {
SD_MODELS : '/sdapi/v1/sd-models' ,
SD_VAE : '/sdapi/v1/sd-vae' ,
TXT2IMG : '/sdapi/v1/txt2img' ,
PNG_INFO : '/sdapi/v1/png-info' ,
PROGRESS : '/sdapi/v1/progress' ,
OPTIONS : '/sdapi/v1/options'
};
async function callWebUIApi (endpoint, method = 'GET' , data = null ) {
const url = `${AppState.apiUrl} ${endpoint} ` ;
const options = { method, headers : {'Content-Type' : 'application/json' }};
if (data && (method === 'POST' || method === 'PUT' )) {
options.body = JSON .stringify (data);
}
try {
const response = await fetch (url, options);
if (!response.ok ) {
throw new Error (`API 请求失败 (${response.status} ): ${await response.text()} ` );
}
return await response.json ();
} catch (error) {
console .error (`API 调用失败 [${endpoint} ]:` , error);
throw error;
}
}
6.2 进度监控与实时反馈 function startProgressPolling ( ) {
if (AppState .progressTimer ) {
clearInterval (AppState .progressTimer );
}
AppState .progressTimer = setInterval (async () => {
try {
const progressData = await callWebUIApi (API_ENDPOINTS .PROGRESS );
if (progressData.progress !== undefined ) {
AppState .currentImageProgress = progressData.progress ;
updateSingleImageProgress ();
}
updateTitleProgress ();
updateProgressDisplay ();
} catch (error) {
console .warn ('进度查询失败:' , error);
}
}, 500 );
}
双级进度 :同时跟踪总任务进度和单图生成进度
实时反馈 :500ms 更新频率确保及时反馈
多位置显示 :标题栏、控制面板、任务栏多重显示
错误容忍 :进度查询失败不影响主任务
七、性能优化与内存管理
7.1 图片数据的内存管理 批量生成可能产生大量图片数据,项目实现了有效的内存管理:
function addToGallery (imageData ) {
AppState .commonGallery .unshift (imageData);
const MAX_GALLERY_SIZE = 50 ;
if (AppState .commonGallery .length > MAX_GALLERY_SIZE ) {
const removed = AppState .commonGallery .splice (MAX_GALLERY_SIZE );
if (removed.length > 0 ) {
console .log (`清理了 ${removed.length} 张旧图片以释放内存` );
}
}
updateCommonGallery ();
}
function optimizeImageStorage (imageBase64 ) {
if (imageBase64.length > 1024 * 1024 ) {
console .warn ('大图片数据,考虑优化存储策略' );
}
return imageBase64;
}
7.2 DOM 性能优化
function batchUpdatePrompts (tabId ) {
const fragment = document .createDocumentFragment ();
const tab = AppState .tabs .find (t => t.id === tabId);
tab.state .prompts .forEach (prompt => {
const item = createPromptElement (prompt);
fragment.appendChild (item);
});
const container = document .querySelector (`#prompts-container-${tabId} ` );
container.innerHTML = '' ;
container.appendChild (fragment);
}
function setupGlobalEventDelegation ( ) {
document .addEventListener ('click' , (e ) => {
if (e.target .classList .contains ('delete-prompt-btn' )) {
const id = e.target .closest ('.prompt-item' ).dataset .id ;
removePromptItem (getCurrentTabId (), parseInt (id));
}
if (e.target .closest ('.queue-btn' )) {
const index = e.target .closest ('.queue-item' ).dataset .index ;
handleQueueButtonClick (e.target , parseInt (index));
}
});
}
八、安全性与错误处理
8.1 输入验证与清理 function validateAndSanitizeInput (input, type ) {
switch (type) {
case 'prompt' :
return input.replace (/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi , '' );
case 'apiUrl' :
const urlPattern = /^(http|https):\/\/[^ "]+$/ ;
if (!urlPattern.test (input)) {
throw new Error ('无效的 API URL 格式' );
}
return input;
case 'jsonContent' :
try {
const parsed = JSON .parse (input);
if (!parsed.version || !parsed.globalParams ) {
throw new Error ('无效的 JSON 配置格式' );
}
return parsed;
} catch (e) {
throw new Error (`JSON 解析失败:${e.message} ` );
}
default :
return input;
}
}
8.2 全面的错误处理策略 async function executeWithErrorHandling (operation, context = {} ) {
try {
showNotification (`开始:${context.name || '操作' } ` , 'info' );
const result = await operation ();
showNotification (`完成:${context.name || '操作' } ` , 'success' );
return result;
} catch (error) {
console .error (`操作失败 [${context.name || '未知' } ]:` , error);
if (error.message .includes ('网络' ) || error.message .includes ('Network' )) {
showNotification ('网络错误,请检查连接' , 'danger' );
} else if (error.message .includes ('API' ) || error.message .includes ('请求' )) {
showNotification ('API 服务异常,请检查 WebUI 状态' , 'danger' );
} else if (error.message .includes ('JSON' ) || error.message .includes ('解析' )) {
showNotification ('数据格式错误' , 'danger' );
} else {
showNotification (`操作失败:${error.message} ` , 'danger' );
}
if (context.recoverable ) {
await attemptRecovery (context);
}
throw error;
}
}
九、扩展性与插件架构
9.1 模块化的扩展接口
const EXTENSION_POINTS = {
BEFORE_GENERATION : 'beforeGeneration' ,
AFTER_GENERATION : 'afterGeneration' ,
CONFIG_LOAD : 'configLoad' ,
CONFIG_SAVE : 'configSave' ,
UI_RENDER : 'uiRender'
};
class PluginManager {
constructor ( ) {
this .plugins = new Map ();
this .hooks = new Map ();
Object .values (EXTENSION_POINTS ).forEach (point => {
this .hooks .set (point, []);
});
}
registerPlugin (plugin ) {
this .plugins .set (plugin.name , plugin);
if (plugin.hooks ) {
Object .entries (plugin.hooks ).forEach (([point, callback] ) => {
if (this .hooks .has (point)) {
this .hooks .get (point).push (callback);
}
});
}
}
async triggerHook (point, data ) {
const hooks = this .hooks .get (point) || [];
for (const hook of hooks) {
try {
data = await hook (data) || data;
} catch (error) {
console .error (`插件钩子执行失败 [${point} ]:` , error);
}
}
return data;
}
}
async function generateImageWithPlugins (config, prompt ) {
const pluginManager = AppState .pluginManager ;
let processedConfig = await pluginManager.triggerHook (EXTENSION_POINTS .BEFORE_GENERATION , { config, prompt });
const result = await generateImageWithConfig (processedConfig.config , processedConfig.prompt );
const finalResult = await pluginManager.triggerHook (EXTENSION_POINTS .AFTER_GENERATION , result);
return finalResult;
}
十、实际应用场景与案例
10.1 角色设计批量生成 假设游戏角色设计师需要生成同一角色在不同场景中的表现:
{
"commonPrompt" : "masterpiece, best quality, 1girl, silver hair, blue eyes, fantasy armor" ,
"prompts" : [
{ "label" : "战斗姿态" , "text" : "in battle stance, holding sword, dramatic lighting" } ,
{ "label" : "休闲场景" , "text" : "resting at campfire, night sky, stars" } ,
{ "label" : "城镇中" , "text" : "in medieval town, marketplace, daylight" } ,
{ "label" : "魔法释放" , "text" : "casting spell, magical energy, glowing runes" }
]
}
一次性导入所有场景配置
批量生成所有变体
通过公共画廊对比效果
导出成功配置供团队复用
10.2 参数对比研究
const paramMatrix = {
samplers : ['Euler a' , 'DPM++ 2M Karras' , 'DDIM' ],
cfgScales : [5 , 7 , 9 , 11 ],
steps : [20 , 30 , 40 , 50 ]
};
const allCombinations = generateParamCombinations (paramMatrix);
allCombinations.forEach ((params, index ) => {
addToQueue ({
name : `实验_${index + 1 } ` ,
config : {
globalParams : {...baseConfig, ...params},
prompts : [{text : "standard test prompt for comparison" }]
}
});
});
10.3 商业应用工作流 阶段 传统方式 使用 LiuMo Batch 需求分析 手动记录需求 创建需求配置模板 参数配置 每张图单独调整 批量应用参数模板 批量生成 手动逐张生成 自动队列执行 效果审核 文件夹中查找对比 画廊中并排对比 选定优化 重新调整参数重试 修改配置后重新队列 交付存档 文件散落各处 完整配置 + 结果打包
十一、项目部署与使用指南
11.1 本地部署步骤
配置连接 :
在侧边栏 API 配置中输入 WebUI 地址(默认 http://127.0.0.1:7860)
点击"测试连接"验证
点击"刷新模型"加载可用模型
open liumo-base/index.html
python -m http.server 8000
./webui.sh --api
git clone https://github.com/Liudef06/liumo-base.git
11.2 高级配置选项
const customConfig = {
ui : {
theme : 'dark' ,
language : 'zh-CN' ,
defaultTabCount : 3 ,
autoSaveInterval : 300000
},
generation : {
defaultSteps : 25 ,
defaultWidth : 512 ,
defaultHeight : 768 ,
defaultSampler : 'DPM++ 2M Karras' ,
maxQueueSize : 100 ,
retryFailed : true ,
retryCount : 3
},
storage : {
maxHistoryImages : 50 ,
enableLocalStorage : true ,
exportFormat : 'json' ,
backupInterval : 3600000
}
};
十二、未来发展方向与社区贡献
12.1 技术演进路线
插件生态系统 :
官方插件市场
第三方插件审核机制
插件沙盒安全环境
云原生支持 :
分布式任务队列
多 WebUI 实例负载均衡
云端配置同步
AI 增强功能 :
12.2 社区贡献指南 贡献类型 技能要求 入门任务 代码贡献 JavaScript/CSS 修复已知 issue、添加测试用例 文档改进 技术写作 完善使用文档、添加教程 插件开发 前端开发 开发实用插件、工具集成 问题反馈 产品使用 提交 bug 报告、功能建议 社区支持 沟通能力 回答用户问题、社区管理
结论:重新定义 AIGC 工作流程 WebUI LiuMo Batch 代表了 AIGC 工具发展的一个重要方向:从单点工具到工作流平台 的演进。通过将复杂的批量生成任务抽象为可管理的配置和工作流,它显著降低了 Stable Diffusion 等 AI 绘画工具的使用门槛,同时提高了专业用户的工作效率。
项目的技术实现展示了现代 Web 技术的强大能力:纯前端实现、完整的本地运行、丰富的交互体验,所有这些都不需要复杂的后端架构。其代码质量、架构设计和用户体验都达到了生产级应用的标准。
随着 AIGC 技术的普及和深化,类似 WebUI LiuMo Batch 的工作流工具将变得越来越重要。它们不仅是效率工具,更是创意工作者的思维延伸 ,帮助人们更好地驾驭 AI 的创造力,将更多精力聚焦于创意本身而非技术细节。
无论你是 AI 绘画的爱好者、专业的内容创作者,还是研究 AI 生成技术的研究者,WebUI LiuMo Batch 都值得你深入了解和使用。它可能就是你寻找的那个能够将 AI 创造力与人类工作流程完美结合的关键工具。
相关免费在线工具 RSA密钥对生成器 生成新的随机RSA私钥和公钥pem证书。 在线工具,RSA密钥对生成器在线工具,online
Mermaid 预览与可视化编辑 基于 Mermaid.js 实时预览流程图、时序图等图表,支持源码编辑与即时渲染。 在线工具,Mermaid 预览与可视化编辑在线工具,online
随机西班牙地址生成器 随机生成西班牙地址(支持马德里、加泰罗尼亚、安达卢西亚、瓦伦西亚筛选),支持数量快捷选择、显示全部与下载。 在线工具,随机西班牙地址生成器在线工具,online
Keycode 信息 查找任何按下的键的javascript键代码、代码、位置和修饰符。 在线工具,Keycode 信息在线工具,online
Escape 与 Native 编解码 JavaScript 字符串转义/反转义;Java 风格 \uXXXX(Native2Ascii)编码与解码。 在线工具,Escape 与 Native 编解码在线工具,online
JavaScript / HTML 格式化 使用 Prettier 在浏览器内格式化 JavaScript 或 HTML 片段。 在线工具,JavaScript / HTML 格式化在线工具,online