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