Add decode phase to progress tracking and file handling

This commit is contained in:
2026-05-07 10:45:35 +02:00
parent cfbabc3462
commit 460e85202a

View File

@@ -1,8 +1,7 @@
import './style.css'; import './style.css';
import * as THREE from 'three'; import * as THREE from 'three';
import { OrbitControls } from 'three/examples/jsm/controls/OrbitControls.js'; import { OrbitControls } from 'three/examples/jsm/controls/OrbitControls.js';
import { invoke } from '@tauri-apps/api/tauri'; import { convertFileSrc, invoke } from '@tauri-apps/api/tauri';
import { readBinaryFile } from '@tauri-apps/api/fs';
import { listen } from '@tauri-apps/api/event'; import { listen } from '@tauri-apps/api/event';
const app = document.getElementById('app'); const app = document.getElementById('app');
@@ -137,6 +136,7 @@ let progressState = {
seamInpaint: null, seamInpaint: null,
phases: { phases: {
gen: null, gen: null,
decode: null,
inpaint: null, inpaint: null,
upscale: null, upscale: null,
}, },
@@ -355,9 +355,7 @@ function animate() {
} }
async function pathToObjectUrl(path) { async function pathToObjectUrl(path) {
const data = await readBinaryFile(path); return convertFileSrc(path);
const blob = new Blob([new Uint8Array(data)], { type: 'image/png' });
return URL.createObjectURL(blob);
} }
function resetProgressState() { function resetProgressState() {
@@ -366,6 +364,7 @@ function resetProgressState() {
seamInpaint: null, seamInpaint: null,
phases: { phases: {
gen: null, gen: null,
decode: null,
inpaint: null, inpaint: null,
upscale: null, upscale: null,
}, },
@@ -376,13 +375,16 @@ function computeProgress() {
const upscaleOn = progressState.upscale === true; const upscaleOn = progressState.upscale === true;
const seamOn = progressState.seamInpaint === true; const seamOn = progressState.seamInpaint === true;
const weights = { const weights = {
gen: seamOn || upscaleOn ? 0.5 : 1, gen: seamOn || upscaleOn ? 0.45 : 0.9,
decode: seamOn || upscaleOn ? 0.05 : 0.1,
inpaint: seamOn ? 0.5 : 0, inpaint: seamOn ? 0.5 : 0,
upscale: upscaleOn ? 0.5 : 0, upscale: upscaleOn ? 0.5 : 0,
}; };
if (seamOn && upscaleOn) { if (seamOn && upscaleOn) {
weights.gen = 0.25; weights.gen = 0.25;
weights.decode = 0.05;
weights.inpaint = 0.25; weights.inpaint = 0.25;
weights.upscale = 0.45;
} }
const frac = phase => { const frac = phase => {
if (!phase || !phase.total) return 0; if (!phase || !phase.total) return 0;
@@ -391,6 +393,7 @@ function computeProgress() {
}; };
return ( return (
frac(progressState.phases.gen) * weights.gen + frac(progressState.phases.gen) * weights.gen +
frac(progressState.phases.decode) * weights.decode +
frac(progressState.phases.inpaint) * weights.inpaint + frac(progressState.phases.inpaint) * weights.inpaint +
frac(progressState.phases.upscale) * weights.upscale frac(progressState.phases.upscale) * weights.upscale
); );