CodeFormer
CodeFormer copied to clipboard
About scripts/generate_latent_gt.py
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
I have the same issue
I also encountered the same problem. May I know how to solve it
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
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:
- set absolute path directly in "generate_latent_gt.py"
- 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)
i fix line 55 and it's ok:
x = vqgan.encoder(img)