尝试利用generate.py 和训练好的encoder,来恢复图像 创建generate_encoder.py 来做代码调整
文章目录
本地conda环境运行的命令
project_name=StyleNeRF-main1
workdir=/host/home/joselyn/workspace/0419-course
outdir=$workdir/logs/$project_name
network=$workdir/stylenerf_pkl/ffhq_256.pkl
testIma_dir=$workdir/my_images/test_img.png
ffhq=$workdir/images256x256
encoder=$workdir/logs/StyleNeRF-main1/train_encoder1/checkpoints/network-snapshot-000240.pkl
python generate_encoder.py --outdir=$outdir/generate_encoder --trunc=0.7 --seeds=5 --network=$network --encoder=$encoder --render-program="rotation_camera"
debug时配置参数如下: --outdir=/home/joselyn/workspace/0419-course/logs/StyleNeRF-main/generate_encoder --encoder=/home/joselyn/workspace/0419-course/logs/StyleNeRF-main1/train_encoder1/checkpoints/network-snapshot-000240.pkl --trunc=0.7 --seeds=5 --network=/home/joselyn/workspace/0419-course/stylenerf_pkl/ffhq_256.pkl --render-program="rotation_camera:/home/joselyn/workspace/0419-course/my_images"
renderer.py line96 ws, _ = self.generator.encoder(kwargs['img']) 报错:RuntimeError: shape '[1, 17, 512]' is invalid for input of size 1470976
尝试调整输入原图像的分别率为256 修改debug参数配置: --outdir=/home/joselyn/workspace/0419-course/logs/StyleNeRF-main/generate_encoder --encoder=/home/joselyn/workspace/0419-course/logs/StyleNeRF-main1/train_encoder1/checkpoints/network-snapshot-000240.pkl --trunc=0.7 --seeds=5 --network=/home/joselyn/workspace/0419-course/stylenerf_pkl/ffhq_256.pkl --render-program="rotation_camera:/home/joselyn/workspace/0419-course/my_images/aframes_256" 成功。 运行结果如下:
尝试换一种螺旋方式。 --outdir=/home/joselyn/workspace/0419-course/logs/StyleNeRF-main/generate_encoder_rc3 --encoder=/home/joselyn/workspace/0419-course/logs/StyleNeRF-main1/train_encoder1/checkpoints/network-snapshot-000240.pkl --trunc=0.7 --seeds=5 --network=/home/joselyn/workspace/0419-course/stylenerf_pkl/ffhq_256.pkl --render-program="rotation_camera3:/home/joselyn/workspace/0419-course/my_images/aframes_256"
报错: File "/home/joselyn/workspace/0419-course/StyleNeRF-main1/renderer.py", line 145, in render_rotation_camera3 kwargs["latent_codes"] = gen.get_latent_codes(batch_size, tmp=self.sample_tmp, device=ws.device) AttributeError: 'tuple' object has no attribute 'device' 调整代码 renderer.py lin134 将ws = self.generator.encoder(kwargs['img'])['ws'] 改为ws, _ = self.generator.encoder(kwargs['img']) 从字面意思上看,两句话应该是一样的。 成功。
|