How kevin-thu/storymem works
StoryMem turns a structured, shot-level story script into a coherent multi-shot video: it generates an initial shot or accepts reference memory, then generates later shots using accumulated visual memory and extracts keyframes between shots. The README documents the workflow and optional MI2V/MM2V continuity modes; the source index and excerpts show the orchestration entry points and Wan model dependencies. Several implementation details are unsampled, so edges for README-described stages cite the README rather than implying further source inspection.
Main entry points: memory2video.py Memory-to-video · pipeline.py Shot orchestrator · generate.py Generation entry · t5.py T5 encoder
Components 26
Story workflow
- Story scripts
story - Run interface
run_example.sh - Shot orchestrator
pipeline.py - Generation entry
generate.py - Shot memory
pipeline.py - Keyframe extraction
extract_keyframes.py - Output videos
pipeline.py
Generation modes
- Text-to-video
wan/text2video.py - Image-to-video
wan/image2video.py - Memory-to-video
wan/memory2video.py - Text-image video
wan/textimage2video.py - Prompt extension
wan/utils/prompt_extend.py - Extension prompts
wan/utils/system_prompt.py
Model components
- T5 encoder
wan/modules/t5.py - Tokenizers
wan/modules/tokenizers.py - Video diffusion model
wan/modules/model.py - Memory diffusion model
wan/modules/model_memory.py - Attention kernels
wan/modules/attention.py - Wan 2.1 VAE
wan/modules/vae2_1.py - Wan 2.2 VAE
wan/modules/vae2_2.py - Diffusion solvers
wan/utils/fm_solvers.py - UniPC solver
wan/utils/fm_solvers_unipc.py
Runtime support
- Model configs
wan/configs/shared_config.py - Distributed runtime
wan/distributed/sequence_parallel.py - FSDP sharding
wan/distributed/fsdp.py
Other components
- Story author
Connections 35
- Story author → Story scripts: writes
README.md - Story author → Run interface: starts
README.md - Run interface → Shot orchestrator: runs
- Shot orchestrator → Story scripts: reads
README.md - Shot orchestrator → Generation entry: dispatches
pipeline.py - Shot orchestrator → Shot memory: updates
README.md - Shot orchestrator → Keyframe extraction: extracts
pipeline.py - Shot orchestrator → Output videos: writes
README.md - Generation entry → Text-to-video: generates first shot
README.md - Generation entry → Memory-to-video: generates later shots
README.md - Generation entry → Image-to-video: supports image input
- Generation entry → Text-image video: supports joint conditioning
- Generation entry → Prompt extension: extends prompts
generate.py - Prompt extension → Extension prompts: uses prompts
wan/utils/prompt_extend.py - Memory-to-video → Memory diffusion model: loads
wan/memory2video.py - Memory-to-video → T5 encoder: uses
wan/memory2video.py - Memory-to-video → Wan 2.1 VAE: uses
wan/memory2video.py - Memory-to-video → Diffusion solvers: samples with
wan/memory2video.py - Memory-to-video → UniPC solver: samples with
wan/memory2video.py - Memory-to-video → Distributed runtime: configures parallelism
wan/memory2video.py - Memory-to-video → FSDP sharding: shards model
wan/memory2video.py - Text-to-video → Video diffusion model: loads
wan/text2video.py - Text-to-video → T5 encoder: uses
wan/text2video.py - Text-to-video → Wan 2.1 VAE: uses
wan/text2video.py - Image-to-video → Video diffusion model: loads
wan/image2video.py - Image-to-video → T5 encoder: uses
wan/image2video.py - Image-to-video → Wan 2.1 VAE: uses
wan/image2video.py - Text-image video → Video diffusion model: loads
wan/textimage2video.py - Text-image video → T5 encoder: uses
wan/textimage2video.py - Text-image video → Wan 2.2 VAE: uses
wan/textimage2video.py - T5 encoder → Tokenizers: tokenizes with
wan/modules/t5.py - Video diffusion model → Attention kernels: uses
wan/modules/model.py - Memory diffusion model → Attention kernels: uses
wan/modules/model_memory.py - Distributed runtime → Video diffusion model: parallelizes
wan/distributed/sequence_parallel.py - Memory-to-video → Model configs: loads settings