MunchkinChen / FADING

20 stars 2 forks source link

(Resolved, 24-04-17) [KeyError] Inference (Age Editing) with pretrained weights #2

Closed gh-BumsooKim closed 1 day ago

gh-BumsooKim commented 7 months ago

Thank you for sharing this code and providing pretrained weights in the open source world with interesting research paper "FADING".

With your shared code, I'm trying to inference my custom facial image (actually from public dataset, such as FFHQ, VFHQ and CelebA, and so on) for age editing based on your released weights (specialized model) via google shared link in README.md.

But, I faced KeyError in p2p.py L36 during p2p_text2image. From FADING/p2p.py code, they said there was KeyError about 'down_cross' in attention_store. At that time, blend_word was ((18, 'woman'), (65, 'woman')) and prompt was ['photo of 18 year old woman', 'photo of 65 year old woman'] as inversion_prompt, new_prompt. Additonally, attention_store.items() was empty (actually dict_items([])) when I print attention_store dictionary.

Is this below bash correct usage? And could you share your environment file or requirement for dependency?

(bash file)
for [SOMETHING_LOOP]; do
CUDA_VISIBLE_DEVICES=0 python age_editing.py \
    --image_path=$data_dir \
    --age_init=$input_age \
    --gender=$gender \
    --specialized_path=finetune_double_prompt_150_random \ #it is unzip folder from ~.zip file
    --save_aged_dir=$output_dir \
    --target_ages="$target_age"
done

Environment : OS : 20.04.6 LTS (Focal Fossa) 64bits Python : 3.9.0 Pytorch : 1.12.1=py3.9_cuda11.3_cudnn8.3.2_0


Error Details :

  latents = latent.expand(batch_size, model.unet.in_channels, height // 8, width // 8).to(model.device)
 20%|█████████████▌                                                      | 10/50 [00:01<00:07,  5.16it/s]
Traceback (most recent call last):
  File "FADING/age_editing.py", line 94, in <module>
    images, _ = p2p_text2image(ldm_stable, prompts, controller, generator=g_cuda.manual_seed(0),
  File "/home/XX/anaconda3/envs/XX/lib/python3.9/site-packages/torch/autograd/grad_mode.py", line 27, in decorate_context
    return func(*args, **kwargs)
  File "FADING/p2p.py", line 361, in p2p_text2image
    latents = ptp_utils.diffusion_step(model, controller, latents, context, t, guidance_scale, low_resource=False)
  File "FADING/FADING_util/ptp_utils.py", line 74, in diffusion_step
    latents = controller.step_callback(latents)
  File "FADING/p2p.py", line 181, in step_callback
    x_t = self.local_blend(x_t, self.attention_store)
  File "FADING/p2p.py", line 36, in __call__
    maps = attention_store["down_cross"][2:4] + attention_store["up_cross"][:3]
KeyError: 'down_cross'

I faced some waring (which may not be important, but not sure) (about diffuser)

You have disabled the safety checker for <class 'diffusers.pipelines.stable_diffusion.pipeline_stable_diffusion.StableDiffusionPipeline'> by passing `safety_checker=None`. Ensure that you abide to the conditions of the Stable Diffusion license and do not expose unfiltered results in services or applications open to the public. Both the diffusers team and Hugging Face strongly recommend to keep the safety filter enabled in all public facing circumstances, disabling it only for use-cases that involve analyzing network behavior or auditing its results. For more information, please have a look at https://github.com/huggingface/diffusers/pull/254 .
1363033313 commented 7 months ago

I face the same problem. Can u provide the requirements file? Please

eayumi commented 7 months ago

I'm running into the same issue! It would be great if it would be solved !

cjnwekcwjec commented 7 months ago

Has anyone succeeded?

10406502403 commented 6 months ago

The same problem I faced, hope you can solve this problem.

junaidwahid commented 4 months ago

The problem raise due to different version of diffuser, this solution fix the problem.

https://github.com/google/prompt-to-prompt/issues/57#issuecomment-1613729431

codermckee commented 4 months ago

@junaidwahid thank you, bro. It works.

vodanhbk95 commented 2 months ago

I solved it by installing diffusers==0.10.0. My env is Cuda 12.1 and driver Cuda530

gh-BumsooKim commented 2 months ago

Thank you guys! @junaidwahid @vodanhbk95. I finally made no-error version without version downgrading following your comments.

For stable-version about diffusers library about FADING, please refer this: https://github.com/gh-BumsooKim/FADING_stable

Since this issue was resolved, I'll close it soon. Thanks.