Restore last used seed in comfyui

pull/369/head
Abdullah Alfaraj 2023-11-17 03:57:28 +03:00
parent f8b8dcd3e6
commit 011fd54e1f
2 changed files with 8 additions and 3 deletions

View File

@ -14,6 +14,7 @@ import util from './util'
import { store } from './util' import { store } from './util'
import { base64UrlToBase64, copyJson } from '../util/ts/general' import { base64UrlToBase64, copyJson } from '../util/ts/general'
import { session_store } from '../stores'
// Function to parse metadata from a title string // Function to parse metadata from a title string
function parseMetadata(title: string) { function parseMetadata(title: string) {
@ -265,6 +266,7 @@ async function addMissingSettings(plugin_settings: Record<string, any>) {
? random_seed.toString() ? random_seed.toString()
: plugin_settings['seed'] // use the same as the main seed : plugin_settings['seed'] // use the same as the main seed
session_store.data.last_seed = plugin_settings['seed']
plugin_settings['hr_seed'] = plugin_settings['seed'] plugin_settings['hr_seed'] = plugin_settings['seed']
return plugin_settings return plugin_settings

View File

@ -195,11 +195,14 @@ async function getSettings(session_data) {
function calculateSeed(init_seed, batch_index, batch_size) { function calculateSeed(init_seed, batch_index, batch_size) {
if (init_seed === -1) return -1 if (init_seed === -1) return -1
const seed = init_seed + batch_index * batch_size // const seed = init_seed + batch_index * batch_size
const seed = init_seed + BigInt(batch_index) * BigInt(batch_size)
return seed return seed
} }
const init_seed = parseInt(sd_tab_store.data.seed) // const init_seed = parseInt(sd_tab_store.data.seed)
const init_seed = BigInt(sd_tab_store.data.seed)
const seed = calculateSeed( const seed = calculateSeed(
init_seed, init_seed,
g_current_batch_index, g_current_batch_index,
@ -425,7 +428,7 @@ async function getSettings(session_data) {
denoising_strength: denoising_strength, denoising_strength: denoising_strength,
batch_size: numberOfBatchSize, batch_size: numberOfBatchSize,
cfg_scale: cfg_scale, cfg_scale: cfg_scale,
seed: seed, seed: seed.toString(),
mask_blur: 4, //mask_blur, // don't use auto1111 blur, instead use Auto-Photoshop-SD blur mask_blur: 4, //mask_blur, // don't use auto1111 blur, instead use Auto-Photoshop-SD blur
use_sharp_mask: use_sharp_mask, use_sharp_mask: use_sharp_mask,
use_prompt_shortcut: bUsePromptShortcut, use_prompt_shortcut: bUsePromptShortcut,