Skip to content

Commit

Permalink
Add output filename to support concurrent work in FOM. (PaddlePaddle#204
Browse files Browse the repository at this point in the history
)


增加文件名的参数filename,以便可以多并发执行
first_order_predictor.py
  • Loading branch information
guojiahuiEmily authored Mar 3, 2021
1 parent 183ffd1 commit c11d914
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 2 additions & 0 deletions applications/tools/first-order-demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
parser.add_argument("--source_image", type=str, help="path to source image")
parser.add_argument("--driving_video", type=str, help="path to driving video")
parser.add_argument("--output", default='output', help="path to output")
parser.add_argument("--filename", default='result.mp4', help="filename to output")
parser.add_argument("--relative",
dest="relative",
action="store_true",
Expand Down Expand Up @@ -65,6 +66,7 @@
paddle.set_device('cpu')

predictor = FirstOrderPredictor(output=args.output,
filename=args.filename,
weight_path=args.weight_path,
config=args.config,
relative=args.relative,
Expand Down
6 changes: 4 additions & 2 deletions ppgan/apps/first_order_predictor.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ def __init__(self,
adapt_scale=False,
find_best_frame=False,
best_frame=None,
ratio=1.0):
ratio=1.0,
filename='result.mp4'):
if config is not None and isinstance(config, str):
self.cfg = yaml.load(config, Loader=yaml.SafeLoader)
elif isinstance(config, dict):
Expand Down Expand Up @@ -88,6 +89,7 @@ def __init__(self,
if not os.path.exists(output):
os.makedirs(output)
self.output = output
self.filename = filename
self.relative = relative
self.adapt_scale = adapt_scale
self.find_best_frame = find_best_frame
Expand Down Expand Up @@ -170,7 +172,7 @@ def run(self, source_image, driving_video):
frame = cv2.copyTo(patch, mask, frame)

out_frame.append(frame)
imageio.mimsave(os.path.join(self.output, 'result.mp4'),
imageio.mimsave(os.path.join(self.output, self.filename),
[frame for frame in out_frame],
fps=fps)

Expand Down

0 comments on commit c11d914

Please sign in to comment.