zyainfal / One-Shot-Face-Swapping-on-Megapixels

One Shot Face Swapping on Megapixels.
Other
317 stars 41 forks source link

in megafs.py, ModuleNotFoundError: No module named 'op'? #6

Closed Dian-Yi closed 3 years ago

Dian-Yi commented 3 years ago

We are all chinese people, i describe the problem using chinese for convenience. 非常感谢你的工作,我测试你的inference demo 发现缺少一些函数。希望你能够将inference的demo运行完整。 谢谢。

zyainfal commented 3 years ago

因为op是StyleGAN2的模块,要先按照stylegan2-pytorch配置StyleGAN2的环境,因为包含gcc,cuda版本兼容的问题,需要你在自己的服务器上配置。

As stated in README.md, you need to implement StyleGAN2 as a prerequisite, including gcc compiler. Please refer stylegan2-pytorch for details.

willyzw1221 commented 3 years ago

If possible, please write down how to run the code in detail, thank you.

zyainfal commented 3 years ago
  1. Implement stylegan2, see stylegan2-pytorch
  2. Download CelebA-HQ and CelebAMask-HQ
  3. Put two provided files under stylegan2-pytorch directory, then run:

python inference.py \

--swap_type [ftm/injection/lcr] \

--img_root [CelebAHQ-PATH] \

--mask_root [CelebAMaskHQ-PATH] \

--srcID [INT-NUMBER] \

--tgtID [INT-NUMBER]

where swap_type means which face transfer module you use, img_root is the CelebAHQ path, mask_root is the CelebAMaskHQ path, srcID and tgtID represent the image number of the CelebAHQ dataset.

zyainfal commented 3 years ago

And you need to download the pretrained weights:

Baidu Cloud (access code: 7nov)

Google Drive

willyzw1221 commented 3 years ago

And you need to download the pretrained weights:

Baidu Cloud (access code: 7nov)

Google Drive

I have downloaded these models.

zyainfal commented 3 years ago

If you have followed all steps above, you should be able to use the inference code.

If No module named 'op' is your problem, then you didn't follow the instructions of stylegan2-pytorch correctly.

Actually, step 1 is the most difficult step for users, as you need to compile .cu files by yourself.

lyumingzhi commented 3 years ago

Hi, would you like to explain more details of step one, especially compile .cu files?

zyainfal commented 3 years ago

Well, you can follow these steps:

  1. update your gcc version to 7.3.1
  2. install cuda 10.1
  3. install pytorch 1.5.1
  4. git clone https://github.com/zyainfal/stylegan2-pytorch.git
  5. cd stylegan2-pytorch and test if you can convert weight from official checkpoints or generate samples (if you can, then everything you need to do for stylegan2 environment is done)
zyainfal commented 3 years ago

For compile .cu files, stylegan2-pytorch has done for you (if you have right gcc and cuda version).

alessiabertugli commented 3 years ago

Sorry for bothering you again. I was able to make the procedure you mentioned in the bulleted list above (both converting the checkpoint and generate samples correctly) but it still gives the error "No module named 'op'". Nevertheless, when I run the command from stylegan2-pytorch python stylegan2-pytorch/convert_weight.py --repo stylegan2/ stylegan2-ffhq-config-f.pkl I can see the following output: Setting up TensorFlow plugin "fused_bias_act.cu": Preprocessing... Loading... Done. Setting up TensorFlow plugin "upfirdn_2d.cu": Preprocessing... Loading... Done.

Can you help me with this issue, please? Thanks.

zyainfal commented 3 years ago

Do you put my codes under stylegan2-pytorch directory?

alessiabertugli commented 3 years ago

Ok, now it works. Thanks.

zyainfal commented 3 years ago

Great!