Add multi-mask extraction with count selector and navigation

- Add count selector (1-10) for generating multiple mask variations
- Each mask gets a unique random seed
- Add left/right arrow navigation in mask preview modal when multiple masks exist
- Batch storage system for tracking multiple concurrent extractions
- Webhook handler now uses batch_id:mask_index for routing responses
This commit is contained in:
2026-03-27 21:36:20 -07:00
parent fb812e57bc
commit c8932fdbf8
5 changed files with 306 additions and 142 deletions

View File

@@ -135,11 +135,14 @@ function oraEditor() {
// Mask extraction
maskSubject: '',
usePolygonHint: true,
maskCount: 3,
isExtracting: false,
maskViewMode: 'with-bg',
showMaskModal: false,
tempMaskPath: null,
tempMaskUrl: null,
tempMaskPaths: [],
currentMaskIndex: 0,
lastError: '',
// Settings
@@ -586,7 +589,7 @@ function oraEditor() {
async extractMask() {
if (!this.maskSubject.trim()) return;
console.log('[ORA EDITOR] Extracting mask for:', this.maskSubject);
console.log('[ORA EDITOR] Extracting', this.maskCount, 'masks for:', this.maskSubject);
this.isExtracting = true;
this.lastError = '';
@@ -598,7 +601,8 @@ function oraEditor() {
subject: this.maskSubject,
use_polygon: this.usePolygonHint && this.polygonPoints.length >= 3,
ora_path: this.oraPath,
comfy_url: this.comfyUrl
comfy_url: this.comfyUrl,
count: this.maskCount
})
});
@@ -608,8 +612,10 @@ function oraEditor() {
if (!data.success) throw new Error(data.error || 'Failed');
this.tempMaskPath = data.mask_path;
this.tempMaskUrl = data.mask_url || '/api/file/mask?path=' + encodeURIComponent(data.mask_path);
this.tempMaskPaths = data.mask_paths || [data.mask_path];
this.currentMaskIndex = 0;
this.tempMaskPath = this.tempMaskPaths[0];
this.tempMaskUrl = data.mask_urls?.[0] || '/api/file/mask?path=' + encodeURIComponent(this.tempMaskPath);
this.showMaskModal = true;
} catch (e) {
console.error('[ORA EDITOR] Error extracting mask:', e);
@@ -618,13 +624,31 @@ function oraEditor() {
this.isExtracting = false;
}
},
get currentMaskPath() {
return this.tempMaskPaths[this.currentMaskIndex] || null;
},
rerollMask() {
previousMask() {
if (this.currentMaskIndex > 0) {
this.currentMaskIndex--;
this.tempMaskPath = this.tempMaskPaths[this.currentMaskIndex];
}
},
nextMask() {
if (this.currentMaskIndex < this.tempMaskPaths.length - 1) {
this.currentMaskIndex++;
this.tempMaskPath = this.tempMaskPaths[this.currentMaskIndex];
}
},
rerollMasks() {
this.extractMask();
},
async useMask() {
if (!this.tempMaskPath) return;
async useCurrentMask() {
if (!this.currentMaskPath) return;
let finalEntityName = this.entityName || 'element';
const existingLayers = this.layers.filter(l => l.name.startsWith(finalEntityName + '_'));
@@ -634,7 +658,7 @@ function oraEditor() {
}
finalEntityName = `${finalEntityName}_${counter}`;
console.log('[ORA EDITOR] Adding layer:', finalEntityName);
console.log('[ORA EDITOR] Adding layer:', finalEntityName, 'with mask:', this.currentMaskPath);
await fetch('/api/layer/add', {
method: 'POST',
@@ -642,7 +666,7 @@ function oraEditor() {
body: JSON.stringify({
ora_path: this.oraPath,
entity_name: finalEntityName,
mask_path: this.tempMaskPath
mask_path: this.currentMaskPath
})
});
@@ -663,6 +687,8 @@ function oraEditor() {
this.showMaskModal = false;
this.tempMaskPath = null;
this.tempMaskUrl = null;
this.tempMaskPaths = [];
this.currentMaskIndex = 0;
},
// === Krita Integration ===