Files changed (1) hide show
  1. app.py +20 -11
app.py CHANGED
@@ -1,30 +1,39 @@
1
  import os
 
2
  import gradio as gr
3
  import subprocess
 
 
4
 
5
- title = "DaGAN Demo"
6
- description = "Reconstruction and Animation demos for DaGAN. The videos will be cropped to 5 seconds because of limitations of computing resources (inference is being run on CPU, unfortunately)."
7
 
8
- def inference(mode, img, video):
9
- os.makedirs('tmp', exist_ok=True)
10
 
11
- cmd = f"ffmpeg -y -ss 00:00:00 -i {video} -to 00:00:05 -c copy cut_vid.mp4"
12
- subprocess.run(cmd.split())
 
13
 
14
- video = "cut_vid.mp4"
15
- os.system(f"python run.py --source_image {img} --driving_video {video} --result_video tmp/result.mp4 --mode {mode}")
 
 
 
 
 
 
 
16
  return "tmp/result.mp4"
17
 
 
18
  gr.Interface(
19
  inference,
20
  [
21
- gr.Dropdown(["reconstruction", "animation"]),
22
  gr.inputs.Image(type="filepath", label="Source (only used if mode is animation)"),
23
  gr.inputs.Video(type="mp4", label="Driving Video")
24
  ],
25
  outputs=gr.outputs.Video(type="mp4", label="Output Video"),
26
  title=title,
27
  description=description,
 
28
  theme="huggingface",
29
- allow_flagging=False).launch(debug=False,enable_queue=True)
30
-
 
1
  import os
2
+ import sys
3
  import gradio as gr
4
  import subprocess
5
+ from fastai.vision.all import *
6
+ import torch
7
 
8
+ # set device to GPU
9
+ device = torch.device('cpu')
10
 
 
 
11
 
12
+ os.system('git clone https://github.com/iPERDance/iPERCore.git')
13
+ os.system('curl -o ./iPERCore/assets/checkpoints.zip http://101.32.75.151:10086/checkpoints.zip')
14
+ os.system('curl -o ./iPERCore/assets/samples.zip http://101.32.75.151:12345/iper_plus_plus_latest_samples.zip')
15
 
16
+ title = "full-body-animation"
17
+ description = "A demo for full-body-animation Official Repo"
18
+ article = "Official Repo: https://github.com/iPERDance/iPERCore"
19
+
20
+ def inference(img, video):
21
+ if not os.path.exists('temp'):
22
+ os.system('mkdir temp')
23
+
24
+ os.system(f"python iPERCore.services.run_imitator --gpu_ids 0 --num_source 2 --src_path {img} --ref_path {video} --output_dir tmp/result.mp4")
25
  return "tmp/result.mp4"
26
 
27
+
28
  gr.Interface(
29
  inference,
30
  [
 
31
  gr.inputs.Image(type="filepath", label="Source (only used if mode is animation)"),
32
  gr.inputs.Video(type="mp4", label="Driving Video")
33
  ],
34
  outputs=gr.outputs.Video(type="mp4", label="Output Video"),
35
  title=title,
36
  description=description,
37
+ article=article,
38
  theme="huggingface",
39
+ allow_flagging=False).launch(debug=True,enable_queue=True