Add Subseed/Variation Seed System for Enhanced Generation Control#994
Open
Gunther-Schulz wants to merge 81 commits intodeepbeepmeep:mainfrom
Open
Add Subseed/Variation Seed System for Enhanced Generation Control#994Gunther-Schulz wants to merge 81 commits intodeepbeepmeep:mainfrom
Gunther-Schulz wants to merge 81 commits intodeepbeepmeep:mainfrom
Conversation
…with InfiniteTalk
- Implement LCMScheduler with RectifiedFlow (LTX) dynamics - Combine Latent Consistency Model with rectified flow scheduling - Optimize for 2-8 step ultra-fast inference with Lightning LoRAs - Add proper flow matching dynamics with shift parameter support - Update UI to show 'lcm + ltx' option in sampler dropdown
Add LCM + LTX Sampler
- Add subseed and subseed_strength parameters to any2video.py generation - Implement noise mixing algorithm (blend main seed and subseed based on strength) - Add UI controls: Extra checkbox reveals subseed slider and strength slider - Add random (🎲) and reuse (♻️) buttons for both seed and subseed - Auto-randomize subseed when set to -1 (like main seed) - Full metadata support: save/load subseed parameters - Display variation seed info in video info panel when used - Works with all Wan models (2.2, i2v, t2v, etc.) This feature allows users to create controlled variations of a generation by mixing noise from two seeds, useful for exploring variations while maintaining overall structure and composition.
- Move 'Extra' checkbox to its own row below seed controls for cleaner layout - Fix subseed randomization to only occur when subseed_strength > 0 - Fix subseed to regenerate for each repeat generation when set to -1 (like main seed) - Prevent unnecessary subseed randomization when variation strength is 0
Extract all seed and subseed management logic from scattered locations into a new shared/utils/seed_management.py module for better maintainability and reusability. New module (shared/utils/seed_management.py): - set_seed(): Unified seed setting for Python, NumPy, PyTorch - initialize_subseed(): Handle initial subseed randomization - regenerate_subseed(): Generate new subseed for repeat generations - create_generator(): Create PyTorch Generator with seed - create_subseed_generator(): Create subseed Generator conditionally - apply_subseed_variation(): Apply subseed variation to latents Changes: - Eliminated duplicate set_seed() implementations (was in 2 files) - Consolidated subseed randomization logic (was scattered) - Unified Generator creation pattern - Reduced wgp.py by ~8 lines of seed logic - Reduced any2video.py by ~6 lines - Reduced radial_attention/utils.py by ~15 lines - Added comprehensive docstrings for all functions - Improved testability and reusability Benefits: - Single source of truth for seed management - Testable individual functions - Reusable across all models - Clear separation of concerns (UI vs business logic) - Follows existing refactoring pattern (like source_image_embedding.py)
UI improvements: - Group seed controls (slider, buttons, Extra checkbox) in visual container - Extra checkbox now visually part of Seed section with gr.Group() - Renamed to 'Extra Seed Options' for clarity - Buttons remain on same row as seed slider Bug fix: - Fix subseed not randomizing between queued tasks - Changed params = task['params'] to params = task['params'].copy() - Prevents param pollution when multiple tasks share same params dict - Now each queued task gets fresh subseed randomization This fixes the issue where variation seed would use same value across all queued generations even when set to -1 (random)
…ucibility This commit addresses all subseed-related issues with a comprehensive solution: 1. **Independent subseed randomization** - Subseed now generates BEFORE set_seed() to ensure independence from main seed - Each generation gets truly random subseed when set to -1 - Fixed deterministic subseed bug caused by random module seeding 2. **Metadata handling** - Saves both subseed=-1 (for randomization behavior) and subseed_used (actual value) - Only saves subseed_used when subseed_strength > 0 (variation actually applied) - Prevents showing variation info when checkbox unchecked/strength=0 3. **Reproducibility** - When loading from video/image file, uses subseed_used (actual value) not -1 - Allows exact reproduction of generated content - Applied to both use_video_settings and get_settings_from_file paths 4. **UI consistency** - Extra checkbox auto-checks only when subseed_strength > 0 - Display shows actual used subseed value (not 'random') - Simplified checkbox condition to match actual usage All subseed workflows now work correctly: ✓ Random subseed generates unique values each time ✓ Metadata displays actual used values ✓ Loading from file enables exact reproduction ✓ Checkbox only appears when variation was used
Critical bug fix: - Unchecking Extra checkbox now sets subseed_strength to 0.0 - This ensures no variation is applied when checkbox is unchecked - Previously, subseed was still being applied even with checkbox unchecked The checkbox now properly controls subseed behavior: - Checked: subseed_strength retains its value, variation applied - Unchecked: subseed_strength reset to 0, no variation applied
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
All code is AI generated.
I use this a lot in Forge and it is invaluable for me for image generation. I basically copied the functionality.
Overview
This PR introduces a comprehensive subseed (variation seed) system that enables fine-grained control over generation variations while maintaining reproducibility.
Features Added
1. Subseed/Variation Seed UI
2. Independent Subseed Randomization
3. Comprehensive Metadata System
subseed=-1(randomization flag) andsubseed_used(actual value)subseed_strength > 04. Full Reproducibility
5. Centralized Seed Management Module
shared/utils/seed_management.pyfor all seed operationsset_seed(),initialize_subseed(),regenerate_subseed()create_generator(),create_subseed_generator()apply_subseed_variation()Technical Implementation
Subseed Variation Algorithm
Files Modified
Wan2GP/wgp.py: UI, metadata handling, subseed integrationWan2GP/models/wan/any2video.py: PyTorch generator creation and latent variationWan2GP/shared/radial_attention/utils.py: Import centralized set_seedWan2GP/shared/utils/seed_management.py: New centralized moduleUse Cases
Testing
Compatibility
Architecture Improvements