Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scene-to-Image Prompt Layering System #1179

Merged
merged 60 commits into from
Oct 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
9dd1a99
Perform masked image restoration when using GFPGAN or RealESRGAN, fix…
xaedes Sep 10, 2022
119fc26
fix indentation
xaedes Sep 10, 2022
3610aa9
fix indentation
xaedes Sep 10, 2022
ccbdc40
add new "Scene to Image" Tab and (barebones) scn2img function
xaedes Sep 10, 2022
9e28259
add scn2img markdown parser and first draft of scene rendering
xaedes Sep 11, 2022
517c758
implement image compositing in scn2img
xaedes Sep 11, 2022
796843d
implement img2img and txtimg calls in scn2img
xaedes Sep 11, 2022
08c23c0
Merge remote-tracking branch 'upstream/dev' into scn2img
xaedes Sep 11, 2022
ee49912
remove debug outputs in scn2img
xaedes Sep 11, 2022
70942a4
use seed in scn2img and add scn2img toggle to output intermediate images
xaedes Sep 11, 2022
bd7fb50
add depth bumping headers to scn2img syntax
xaedes Sep 11, 2022
c027d8e
fix scn2img bug when using render_img2img with color but no specified…
xaedes Sep 12, 2022
57ee924
improve scn2img multiline comments
xaedes Sep 12, 2022
4a5349d
add scn2img cache to allow faster iteration
xaedes Sep 12, 2022
54a64f8
add scn2img mask by selection depth range from estimated depth.
xaedes Sep 12, 2022
95a479b
add scn2img placeholder with nice result on initial seed 2
xaedes Sep 12, 2022
d806da0
add to scn2img syntax: bumpdown depth headings
xaedes Sep 12, 2022
7a037c1
scn2img update:
xaedes Sep 12, 2022
04ec89e
improve scn2img caching
xaedes Sep 12, 2022
d1a3ae5
add scoped seed generators in scn2img
xaedes Sep 12, 2022
2f55e55
add scn2img logger functions that log to comments and use them instea…
xaedes Sep 12, 2022
a12e771
add scn2img log levels and print logs depending on currently set log …
xaedes Sep 13, 2022
7142990
add scn2img mask selection by color, mask invert and directly setting…
xaedes Sep 13, 2022
6bfd72c
Merge remote-tracking branch 'upstream/dev' into scn2img-mask-by-esti…
xaedes Sep 16, 2022
38c3c7d
add scn2img mask selection by colors picked from pixels in image and …
xaedes Sep 16, 2022
973c0d3
fix scn2img bug when generating with empty prompt
xaedes Sep 16, 2022
dc4fcd0
add scn2img examples and a bit of documentation
xaedes Sep 16, 2022
4cd1e51
Merge branch 'dev-upstream' into scn2img-mask-by-estimated-depth
xaedes Sep 16, 2022
3171f2f
revert changes from commit 119fc26f "fix indentation" to make pull re…
xaedes Sep 16, 2022
955a07c
revert changes from commit 119fc26f "fix indentation" to make pull re…
xaedes Sep 16, 2022
bd9710a
fix text in error message of try_loading_monocular_depth_estimation
xaedes Sep 16, 2022
67fc70f
fix scn2img bug when monocular_depth_estimation is not loaded but use…
xaedes Sep 16, 2022
efa19c9
revert whitespace and indentation changes to make pull request easier
xaedes Sep 16, 2022
266baf2
add missing argument "crop" in scn2img
xaedes Sep 16, 2022
e09e691
add BilinearUpSampling2D layer to monocular depth estimation as seen …
xaedes Sep 16, 2022
2addba8
Merge branch 'dev-upstream' into scn2img-mask-by-estimated-depth
xaedes Sep 16, 2022
c051a44
Merge branch 'dev-upstream' into scn2img-mask-by-estimated-depth
xaedes Sep 19, 2022
79c0766
Merge branch 'dev-upstream' into scn2img-mask-by-estimated-depth
xaedes Sep 20, 2022
7120b0f
Merge branch 'dev-upstream' into scn2img-mask-by-estimated-depth
xaedes Sep 23, 2022
d78e0f3
use job manager in scn2img for job control & batch progress and fix d…
xaedes Sep 23, 2022
288eb29
save scn2img samples
xaedes Sep 23, 2022
f63b3a2
Merge remote-tracking branch 'upstream/dev' into scn2img-mask-by-esti…
xaedes Sep 23, 2022
3c366a9
use default values from txt2img_defaults and img2img_defaults
xaedes Sep 24, 2022
d6b856b
add scn2img output info from all generated images
xaedes Sep 24, 2022
142c28c
revert changes from 288eb29d to save_sample
xaedes Sep 24, 2022
242f9e0
Merge branch 'dev-upstream' into scn2img-mask-by-estimated-depth
xaedes Sep 24, 2022
13356f2
specify version of dependencies
xaedes Sep 24, 2022
8d765a7
Merge branch 'dev-upstream' into scn2img-mask-by-estimated-depth
xaedes Sep 24, 2022
40dccc1
scn2img parameter copy without string literals for js code.
xaedes Sep 24, 2022
d33b362
move scn2img related code into scn2img.py
xaedes Sep 24, 2022
77f5185
reverted unnecessary changes
xaedes Sep 24, 2022
afed6c3
add MiDaS depth estimation for scn2img
xaedes Sep 25, 2022
f1da61f
add 3d transformations in scn2img
xaedes Sep 26, 2022
c45e080
Merge branch 'dev-upstream' into scn2img-mask-by-estimated-depth
xaedes Sep 26, 2022
5ef0ade
add scn2img dependencies to requirements.txt
xaedes Sep 26, 2022
4c1777f
add scn2img blend modes
xaedes Sep 26, 2022
18afa3a
improve scn2img transform3d
xaedes Sep 26, 2022
1f06eb9
Merge branch 'dev' into scn2img-mask-by-estimated-depth
hlky Oct 2, 2022
5e4b43c
Update environment.yaml
hlky Oct 2, 2022
2fecb6a
Merge branch 'dev' into scn2img-mask-by-estimated-depth
hlky Oct 2, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions data/scn2img_examples/cat_at_beach.scn2img.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// blend it together and finish it with details
prompt: cute happy orange cat sitting at beach, beach in background, trending on artstation:1 cute happy cat:1
sampler_name:k_euler_a
ddim_steps: 35
denoising_strength: 0.55
variation: 3
initial_seed: 1

# put foreground onto background
size: 512, 512
color: 0,0,0

## create foreground
size:512,512
color:0,0,0,0
resize: 300, 300
pos: 256, 350

// select mask by probing some pixels from the image
mask_by_color_at: 15, 15, 15, 256, 85, 465, 100, 480
mask_by_color_threshold:80
mask_by_color_space: HLS

// some pixels inside the cat may be selected, remove them with mask_open
mask_open: 15

// there is still some background pixels left at the edge between cat and background
// grow the mask to get them as well
mask_grow: 15

// we want to remove whatever is masked:
mask_invert: True

####
prompt: cute happy orange cat, white background
ddim_steps: 25
variation: 1

## create background
prompt:beach landscape, beach with ocean in background, photographic, beautiful:1 red:-0.4
50 changes: 50 additions & 0 deletions data/scn2img_examples/corgi_3d_transformation.scn2img.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
initial_seed: 2

// select background and img2img over it
mask_by_color_at: 64, 64
mask_invert: True

prompt: corgi
ddim_steps: 50
seed: 242886303

mask_mode: 0
denoising_strength: 0.8
//cfg_scale: 15
mask_restore: True
image_editor_mode:Mask

# estimate depth and transform the corgi in 3d
transform3d: True
transform3d_depth_near: 0.5
transform3d_depth_scale: 10
transform3d_from_hfov: 45
transform3d_to_hfov: 45
transform3d_from_pose: 0,0,0, 0,0,0
transform3d_to_pose: 0.5,0,0, 0,-5,0
transform3d_min_mask: 0
transform3d_max_mask: 255
transform3d_inpaint_radius: 1
transform3d_inpaint_method: 0

## put foreground onto background
size: 512, 512


### create foreground
size: 512, 512

mask_depth: True
mask_depth_model: 1
mask_depth_min: -0.05
mask_depth_max: 0.5
mask_depth_invert:False

####
prompt: corgi
ddim_steps: 25
seed: 242886303

### background
size: 512,512
color: #9F978D
25 changes: 25 additions & 0 deletions data/scn2img_examples/corgi_at_beach.scn2img.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// blend it together and finish it with some details
prompt: cute corgi at beach, trending on artstation
ddim_steps: 50
denoising_strength: 0.5
initial_seed: 2

# put foreground onto background
size: 512, 512

## create foreground
size: 512, 512

// estimate depth from image and select mask by depth
// https://huggingface.co/spaces/atsantiago/Monocular_Depth_Filter
mask_depth: True
mask_depth_min: -0.05
mask_depth_max: 0.4
mask_depth_invert:False

###
prompt: corgi
ddim_steps: 25

## create background
prompt:beach landscape, beach with ocean in background, photographic, beautiful:1 red:-0.4
34 changes: 34 additions & 0 deletions data/scn2img_examples/corgi_at_beach_2.scn2img.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// give it some polish and details
size: 512, 512
prompt: cute corgi at beach, intricate details, photorealistic, trending on artstation
variation: 0
seed: 1360051694
initial_seed: 5

# blend it together
prompt: beautiful corgi:1.5 cute corgi at beach, trending on artstation:1 photorealistic:1.5
ddim_steps: 50
denoising_strength: 0.5
variation: 0

## put foreground in front of background
size: 512, 512

### select foreground
size: 512, 512

// estimate depth from image and select mask by depth
// https://huggingface.co/spaces/atsantiago/Monocular_Depth_Filter
mask_depth: True
mask_depth_min: -0.05
mask_depth_max: 0.4
mask_depth_invert:False

#### create foreground
prompt: corgi
ddim_steps: 25
seed: 242886303

### create background
prompt:beach landscape, beach with ocean in background, photographic, beautiful:1 red:-0.4
variation: 3
37 changes: 37 additions & 0 deletions data/scn2img_examples/landscape_3d.scn2img.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
size: 512,512
mask_blur: 6

prompt: fantasy landscape with castle and forest and waterfalls, trending on artstation
denoising_strength: 0.6
seed: 1
image_editor_mode: Mask
mask_mode: 0
mask_restore: True

# mask the left which contains artifacts
color: 255,255,255,0
blend:multiply
size: 100,512
pos: 50,256

# mask the top-left which contains lots of artifacts
color: 255,255,255,0
blend:multiply
size: 280,128
pos: 128,64

# go forward and turn head left to look at the left waterfalls
transform3d: True
transform3d_depth_scale: 10000
transform3d_from_hfov: 60
transform3d_to_hfov: 60
transform3d_from_pose: 0,0,0, 0,0,0
transform3d_to_pose: 4000,0,2000, 0,-50,0
transform3d_min_mask: 0
transform3d_max_mask: 255
transform3d_inpaint_radius: 5
transform3d_inpaint_method: 1

##
prompt: fantasy landscape with castle and forest and waterfalls, trending on artstation
seed: 1
7 changes: 4 additions & 3 deletions environment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ dependencies:
- albumentations==0.4.3
- basicsr>=1.3.4.0
- diffusers==0.3.0
- einops==0.3.0
- einops==0.3.1
- facexlib>=0.2.3
- ftfy==6.1.1
- fairscale==0.4.4
Expand Down Expand Up @@ -72,9 +72,10 @@ dependencies:
- streamlit-tensorboard==0.0.2
- test-tube>=0.7.5
- tensorboard==2.10.1
- timm==0.4.12
- timm==0.6.7
- torch-fidelity==0.3.0
- torchmetrics==0.6.0
- transformers==4.19.2
- tensorflow==2.10.0
- tqdm==4.64.0

Loading