Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleGAN
提交
a1e739e7
P
PaddleGAN
项目概览
PaddlePaddle
/
PaddleGAN
大约 1 年 前同步成功
通知
97
Star
7254
Fork
1210
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
4
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
PaddleGAN
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
4
Issue
4
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
a1e739e7
编写于
9月 18, 2020
作者:
L
LielinJiang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
rm unused code
上级
bbe1f14d
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
0 addition
and
72 deletion
+0
-72
ppgan/utils/animate.py
ppgan/utils/animate.py
+0
-72
未找到文件。
ppgan/utils/animate.py
浏览文件 @
a1e739e7
...
...
@@ -2,16 +2,11 @@ import os
from
tqdm
import
tqdm
import
paddle
# from paddle.utils.data import DataLoader
# from frames_dataset import PairedDataset
# from logger import Logger, Visualizer
import
imageio
from
scipy.spatial
import
ConvexHull
import
numpy
as
np
# from sync_batchnorm import DataParallelWithCallback
def
normalize_kp
(
kp_source
,
kp_driving
,
...
...
@@ -20,8 +15,6 @@ def normalize_kp(kp_source,
use_relative_movement
=
False
,
use_relative_jacobian
=
False
):
if
adapt_movement_scale
:
# source_area = ConvexHull(kp_source['value'][0].data.cpu().numpy()).volume
# driving_area = ConvexHull(kp_driving_initial['value'][0].data.cpu().numpy()).volume
source_area
=
ConvexHull
(
kp_source
[
'value'
][
0
].
numpy
()).
volume
driving_area
=
ConvexHull
(
kp_driving_initial
[
'value'
][
0
].
numpy
()).
volume
adapt_movement_scale
=
np
.
sqrt
(
source_area
)
/
np
.
sqrt
(
driving_area
)
...
...
@@ -43,68 +36,3 @@ def normalize_kp(kp_source,
kp_source
[
'jacobian'
])
return
kp_new
# def animate(config, generator, kp_detector, checkpoint, log_dir, dataset):
# log_dir = os.path.join(log_dir, 'animation')
# png_dir = os.path.join(log_dir, 'png')
# animate_params = config['animate_params']
# dataset = PairedDataset(initial_dataset=dataset, number_of_pairs=animate_params['num_pairs'])
# dataloader = DataLoader(dataset, batch_size=1, shuffle=False, num_workers=1)
# if checkpoint is not None:
# Logger.load_cpk(checkpoint, generator=generator, kp_detector=kp_detector)
# else:
# raise AttributeError("Checkpoint should be specified for mode='animate'.")
# if not os.path.exists(log_dir):
# os.makedirs(log_dir)
# if not os.path.exists(png_dir):
# os.makedirs(png_dir)
# if torch.cuda.is_available():
# generator = DataParallelWithCallback(generator)
# kp_detector = DataParallelWithCallback(kp_detector)
# generator.eval()
# kp_detector.eval()
# for it, x in tqdm(enumerate(dataloader)):
# with torch.no_grad():
# predictions = []
# visualizations = []
# driving_video = x['driving_video']
# source_frame = x['source_video'][:, :, 0, :, :]
# kp_source = kp_detector(source_frame)
# kp_driving_initial = kp_detector(driving_video[:, :, 0])
# for frame_idx in range(driving_video.shape[2]):
# driving_frame = driving_video[:, :, frame_idx]
# kp_driving = kp_detector(driving_frame)
# kp_norm = normalize_kp(kp_source=kp_source, kp_driving=kp_driving,
# kp_driving_initial=kp_driving_initial, **animate_params['normalization_params'])
# out = generator(source_frame, kp_source=kp_source, kp_driving=kp_norm)
# out['kp_driving'] = kp_driving
# out['kp_source'] = kp_source
# out['kp_norm'] = kp_norm
# del out['sparse_deformed']
# predictions.append(np.transpose(out['prediction'].data.cpu().numpy(), [0, 2, 3, 1])[0])
# visualization = Visualizer(**config['visualizer_params']).visualize(source=source_frame,
# driving=driving_frame, out=out)
# visualization = visualization
# visualizations.append(visualization)
# predictions = np.concatenate(predictions, axis=1)
# result_name = "-".join([x['driving_name'][0], x['source_name'][0]])
# imageio.imsave(os.path.join(png_dir, result_name + '.png'), (255 * predictions).astype(np.uint8))
# image_name = result_name + animate_params['format']
# imageio.mimsave(os.path.join(log_dir, image_name), visualizations)
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录