GithubHelp home page GithubHelp logo

hila-chefer / targetclip Goto Github PK

View Code? Open in Web Editor NEW
233.0 233.0 27.0 44.57 MB

[ECCV 2022] Official PyTorch implementation of the paper Image-Based CLIP-Guided Essence Transfer.

Python 7.33% Jupyter Notebook 92.43% C++ 0.03% Cuda 0.21%
clip computer-graphics eccv2022 image-editing image-generation image-manipulation stylegan2

targetclip's People

Contributors

hila-chefer avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

targetclip's Issues

amazing work

amazing work

let me congratulate you on this incredible job, unfortunately I don't have the computing power to train targets, I'd like you to add some celebrity targets like megan fox and emilia clacke, and other celebrities.
and add new ones, for people who don't have a gpu, every week if they have free time and no work is busy.

Problem about finding direction

I ran this command to reproduce your results:
python3 optimization/find_dirs.py --target_path dirs/targets/avatar.jpg --dir_name results_folder_avatar --weight_decay 3e-3 --lambda_consistency 0.6 --step 1000 --lr 0.2 --num_directions 8 --num_images 8
But I got strange result as bellow: here is some results. Anything wrong with me?
image

encoding method

I wonder how to encode target or source image in latent space. I usually use e4e, image2styleGAN, which one did you use?

Role of coefficients

Hello again,

in these marked lines you initialize a set of coefficients to optimize over. As far as I can see, these are not mentioned in the paper. The coefficients are multiplied by the direction per source image, so I get that you want to optimize for a different scale of the direction vector per source vector. I have some questions on this:

  1. Did you try it without these coefficients?
  2. To what values do the coefficients converge to? Do they stay close to 1?
  3. You re-initialize the Adam optimizer for the coefficients for every step within the optimization, hence drastically changing the behavior of the optimizer. Is this intended or a misplacement? If it is intended, what is it used for?

Thanks again for your work! I hope I am not too picky on this - I'm just curious about the topic of semantics in these latent spaces :-)

coefficients = [None] * NUM_IMAGES
for n in range(NUM_IMAGES):
coefficient = torch.ones(1).to("cuda")
coefficient.requires_grad = True
coefficients[n] = coefficient
opt_loss = torch.Tensor([float("Inf")]).to("cuda")
pbar = tqdm(range(args.step))
for i in pbar:
# calculate learning rate
t = i / args.step
lr = get_lr(t, args.lr)
optimizer.param_groups[0]["lr"] = lr
optimizer_coeffs = optim.Adam(coefficients, lr=args.lr, weight_decay=0.01)
loss = torch.zeros(1).cuda()
target_semantic = torch.zeros(1).cuda()

ModuleNotFoundError bug colab

steps to reproduce

!git clone  https://github.com/hila-chefer/TargetCLIP.git

%cd /content/TargetCLIP

!python /content/TargetCLIP/optimization/find_dirs.py

Traceback (most recent call last):
  File "/content/TargetCLIP/optimization/find_dirs.py", line 9, in <module>
    from criteria.clip_loss import CLIPLoss
ModuleNotFoundError: No module named 'criteria'

but criteria is in the root directory

Efficiency: no recalculation of original latents needed

with torch.no_grad():
img_gen, _ = g_ema([latents], input_is_latent=True, randomize_noise=False)
image_gen_clip = clip_loss.module.encode(img_gen)

In these lines the latents are recalculated in the nested loop in every inner loop. The latents themselves stay constant though, so it can be done once outside of these loops. Only the augmented latents (latents + direction) need to be recalculated here.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.