https://github.com/vladmandic/sd-hdr
Generate HDR images using SD
https://github.com/vladmandic/sd-hdr
Last synced: about 1 month ago
JSON representation
Generate HDR images using SD
- Host: GitHub
- URL: https://github.com/vladmandic/sd-hdr
- Owner: vladmandic
- License: apache-2.0
- Created: 2024-09-10T20:59:33.000Z (7 months ago)
- Default Branch: main
- Last Pushed: 2024-09-19T13:12:01.000Z (7 months ago)
- Last Synced: 2025-03-17T07:07:43.373Z (about 1 month ago)
- Language: Python
- Size: 1.76 MB
- Stars: 3
- Watchers: 1
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# StableDiffusion HDR
*Generate HDR images using StableDiffusionXL*
How? By:
1. Running denoising loop for N-threshold steps
2. Store interim latents
3. Modifying latents to mimic exposure modifications
4. Finish running remaining steps
5. Repeat steps 3-5 for N-exposure steps
6. Merge N 8bit images into single 16bit HDR imageHow fast is it? For standard 20 steps and with threshold of 0.2, it would run 16 base steps and then 3 x 4 steps for each different exposure for total of 28 steps - so 20% overhead.
## Run CLI
Primary mode of operation for batch operations is via wrappers that
- create/activate `VENV`
- install `requirements`
- run main `hdr.py` scriptWrappers:
- Linux: `hdr.sh`
- Windows: `hdr.bat`...or do it manually and run `hdr.py` script
> python hdr.py --help
```log
--dtype DTYPE torch dtype
--device DEVICE torch device
--model MODEL sd model
--width WIDTH image width
--height HEIGHT image height
--steps STEPS sampling steps
--seed SEED noise seed
--cfg CFG cfg scale
--sampler SAMPLER sd sampler
--prompt PROMPT prompt or prompts file
--negative NEGATIVE negative prompt or prompts file
--image IMAGE init image(s)
--strength STRENGTH denoise strength
--output OUTPUT output folder
--format FORMAT hdr file format: png,hdr,dng,tiff,all
--exp EXP exposure correction
--gamma GAMMA gamma adjustment for dng/hdr
--timestep TIMESTEP correction timestep
--save save interim images
--ldr create 8bpc hdr png image
--json save params to json
--debug debug log
--offload offload model components
```## Run UI
Experimental mode for, well, *experiments*
Based on [streamlit](https://streamlit.io/) framework which is not installed by default as its not required for batch operations> source venv/bin/activate
> pip install streamlit
> streamlit run hdr.py> [!TIP]
> you can pass standard args to hdr.py by using additiona `--` separator
> *example*: streamlit run hdr.py -- --model sdxl/model.safetensors
## Note
- A lot of optimizations are possible, this is just a quick and dirty script to get started
- Notes: if input image(s) is present, it will run SDXL img2img pipeline, otherwise it will run text2img pipeline
- Prompt, negative, image can be a string value or point to file which contains one line per entry
- Created filename is simple epoch timestamp in output folder
- Output formats: PNG / HDR / TIFF / DNG