Skip to content

Commit

Permalink
Restore last used seed in comfyui
Browse files Browse the repository at this point in the history
  • Loading branch information
AbdullahAlfaraj committed Nov 17, 2023
1 parent f8b8dcd commit 011fd54
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
2 changes: 2 additions & 0 deletions typescripts/comfyui/main_ui.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import util from './util'
import { store } from './util'

import { base64UrlToBase64, copyJson } from '../util/ts/general'
import { session_store } from '../stores'

// Function to parse metadata from a title string
function parseMetadata(title: string) {
Expand Down Expand Up @@ -265,6 +266,7 @@ async function addMissingSettings(plugin_settings: Record<string, any>) {
? random_seed.toString()
: 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']

return plugin_settings
Expand Down
9 changes: 6 additions & 3 deletions utility/session.js
Original file line number Diff line number Diff line change
Expand Up @@ -195,11 +195,14 @@ async function getSettings(session_data) {

function calculateSeed(init_seed, batch_index, batch_size) {
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
}

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(
init_seed,
g_current_batch_index,
Expand Down Expand Up @@ -425,7 +428,7 @@ async function getSettings(session_data) {
denoising_strength: denoising_strength,
batch_size: numberOfBatchSize,
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
use_sharp_mask: use_sharp_mask,
use_prompt_shortcut: bUsePromptShortcut,
Expand Down

0 comments on commit 011fd54

Please sign in to comment.