Skip to content

Commit

Permalink
add image
Browse files Browse the repository at this point in the history
  • Loading branch information
inbarhub committed Apr 20, 2023
1 parent 09cc38b commit 4ed036a
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 13 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ results_100/
prompt_to_prompt/__pycache__/utils.cpython-38.pyc
prompt_to_prompt/__pycache__/*
*.pyc
results/
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,16 +59,18 @@ These three inputs are supplied through a YAML file (please use the provided 'te
Method's parameters are:

```
skip - controlling the adherence to the input image
cfg_tar - the strength of the classifier free guidance
skip - controlling the adherence to the input image; a list
cfg_tar - classifier free guidance strengths; a list
```
These two parameters have default values, as descibed in the paper.

## Usage Example
```
python3 main_run.py --mode="XXX" --dataset_yaml="test.yaml" --skip=36 --cfg_tar=15
python3 main_run.py --mode="our_inv" --dataset_yaml="test.yaml" --skip=[36] --cfg_tar=[15]
python3 main_run.py --mode="p2pinv" --dataset_yaml="test.yaml" --skip=[12] --cfg_tar=[9]
```
Where XXX can be ```our_inv```,```p2pinv``` ,```ddim``` or ```p2p```.
The mode argument can also be: ```ddim``` or ```p2p```.

In ```our_inv``` and ```p2pinv``` modes we suggest to play around with ```skip``` in the range [0,40] and ```cfg_tar``` in the range [7,18].

Expand Down
2 changes: 1 addition & 1 deletion ddm_inversion/ddim_inversion.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

from prompt_to_prompt.inversion_utils import encode_text
from ddm_inversion.inversion_utils import encode_text
from typing import Union
import torch
import numpy as np
Expand Down
2 changes: 1 addition & 1 deletion ddm_inversion/inversion_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from tqdm import tqdm

def load_real_image(folder = "data/", img_name = None, idx = 0, img_size=512, device='cuda'):
from prompt_to_prompt.utils import pil_to_tensor
from ddm_inversion.utils import pil_to_tensor
from PIL import Image
from glob import glob
if img_name is not None:
Expand Down
Binary file removed example_images/gnochi_mirror.jpeg
Binary file not shown.
Binary file added example_images/sketch_cat.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 7 additions & 4 deletions main_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@

if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument("--device_num", type=int, default=0)
parser.add_argument("--device_num", type=int, default=2)
parser.add_argument("--cfg_src", type=float, default=3.5)
parser.add_argument("--cfg_tar", type=float, default=[15])
parser.add_argument("--num_diffusion_steps", type=int, default=100)
parser.add_argument("--dataset_yaml", default="test.yaml")
parser.add_argument("--eta", type=float, default=1)
parser.add_argument("--mode", default="our_inv", help="modes: our_inv,p2pinv,p2pddim, ddim")
parser.add_argument("--skip", type=int, default=[0])
parser.add_argument("--mode", default="our_inv", help="modes: our_inv,p2pinv,p2pddim,ddim")
parser.add_argument("--skip", type=int, default=[36])
parser.add_argument("--xa", type=float, default=0.6)
parser.add_argument("--sa", type=float, default=0.2)

Expand Down Expand Up @@ -146,4 +146,7 @@
save_full_path = os.path.join(save_path, image_name_png)
img.save(save_full_path)


# TODO: Inbar:
# (1) fix Rene's bug
# (2) write more concisly the inversion_util
# (3) Comments
15 changes: 12 additions & 3 deletions test.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
# -
# init_img: /example_images/horse_mud.jpg
# source_prompt: a photo of a horse in the mud

# target_prompts:
# - a photo of a horse in the snow
# - a photo of a zebra in the snow
# - a photo of a zebra in the mud

-
init_img: /example_images/horse_mud.jpg
source_prompt: a photo of a horse in the mud
init_img: /example_images/sketch_cat.jpg
source_prompt: a sketch of a cat

target_prompts:
- a photo of a horse in the snow
- a sculpture of a cat

0 comments on commit 4ed036a

Please sign in to comment.