CodeFormer icon indicating copy to clipboard operation
CodeFormer copied to clipboard

About scripts/generate_latent_gt.py

Open Iceeteeea opened this issue 1 year ago • 5 comments

When I execute python scrtpts/generate_lateent_gt.py, following error happened. Traceback (most recent call last): File "scripts/generate_latent_gt.py", line 55, in <module> x, feat_dict = vqgan.encoder(img, True) File "/home/fzh/miniconda3/envs/codeformer/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1501, in _call_impl return forward_call(*args, **kwargs) TypeError: forward() takes 2 positional arguments but 3 were given

Iceeteeea avatar Jul 13 '23 06:07 Iceeteeea

I have the same issue

heorhiikalaichev avatar Sep 24 '23 08:09 heorhiikalaichev

I also encountered the same problem. May I know how to solve it

create-li avatar Nov 19 '23 09:11 create-li

Excuse me, have you found a solution to this problem

When I execute python scrtpts/generate_lateent_gt.py, following error happened. Traceback (most recent call last): File "scripts/generate_latent_gt.py", line 55, in <module> x, feat_dict = vqgan.encoder(img, True) File "/home/fzh/miniconda3/envs/codeformer/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1501, in _call_impl return forward_call(*args, **kwargs) TypeError: forward() takes 2 positional arguments but 3 were given

create-li avatar Nov 21 '23 03:11 create-li

I encountered the same question when I tried to use command to call this file as a script in jupyter cell like:

%cd CodeFormer
! python -m scripts.generate_latent_gt \
    -i D:\Project\project\datasets\test_data\overriden \
    -o D:\Project\project\outputs\VQGAN \
    --codebook_size 512 \
    --ckpt_path D:\Project\project\experiments\VQGAN-stage1\models\net_g_latest.pth

I solved it through the steps as following:

  1. set absolute path directly in "generate_latent_gt.py"
  2. modify the import package part as below:
import sys
import os
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))
from basicsr.utils import imwrite, img2tensor, tensor2img
from basicsr.utils.registry import ARCH_REGISTRY
sys.path.pop(0)

then it runs well. (I mean, run this .py file directly)

Heart-Sniper avatar Dec 31 '23 09:12 Heart-Sniper

i fix line 55 and it's ok: x = vqgan.encoder(img)

hongdthaui avatar Jan 30 '24 15:01 hongdthaui