zzl commited on
Commit
4fa279e
1 Parent(s): 2bbc3ee
Files changed (2) hide show
  1. demo_img.py +7 -6
  2. demo_vid.py +6 -6
demo_img.py CHANGED
@@ -28,17 +28,18 @@ def img2vid(model_type, img0, img1, frame_ratio, iters):
28
  img1_t = img2tensor(img1).to(device)
29
  inputs = [img0_t, img1_t]
30
 
31
- if device == 'cpu':
 
 
 
 
 
 
32
  # Do not resize in cpu mode
33
  anchor_resolution = 8192*8192
34
  anchor_memory = 1
35
  anchor_memory_bias = 0
36
  vram_avail = 1
37
- elif device == 'cuda':
38
- anchor_resolution = 1024 * 512
39
- anchor_memory = 1500 * 1024**2
40
- anchor_memory_bias = 2500 * 1024**2
41
- vram_avail = torch.cuda.get_device_properties(device).total_memory
42
  embt = torch.tensor(1/2).float().view(1, 1, 1, 1).to(device)
43
 
44
  inputs = check_dim_and_resize(inputs)
 
28
  img1_t = img2tensor(img1).to(device)
29
  inputs = [img0_t, img1_t]
30
 
31
+
32
+ if device == 'cuda':
33
+ anchor_resolution = 1024 * 512
34
+ anchor_memory = 1500 * 1024**2
35
+ anchor_memory_bias = 2500 * 1024**2
36
+ vram_avail = torch.cuda.get_device_properties(device).total_memory
37
+ else':
38
  # Do not resize in cpu mode
39
  anchor_resolution = 8192*8192
40
  anchor_memory = 1
41
  anchor_memory_bias = 0
42
  vram_avail = 1
 
 
 
 
 
43
  embt = torch.tensor(1/2).float().view(1, 1, 1, 1).to(device)
44
 
45
  inputs = check_dim_and_resize(inputs)
demo_vid.py CHANGED
@@ -27,17 +27,17 @@ def vid2vid(model_type, video, iters):
27
  inputs = []
28
  h = int(vcap.get(cv2.CAP_PROP_FRAME_WIDTH))
29
  w = int(vcap.get(cv2.CAP_PROP_FRAME_HEIGHT))
30
- if device == 'cpu':
 
 
 
 
 
31
  # Do not resize in cpu mode
32
  anchor_resolution = 8192*8192
33
  anchor_memory = 1
34
  anchor_memory_bias = 0
35
  vram_avail = 1
36
- elif device == 'cuda':
37
- anchor_resolution = 1024 * 512
38
- anchor_memory = 1500 * 1024**2
39
- anchor_memory_bias = 2500 * 1024**2
40
- vram_avail = torch.cuda.get_device_properties(device).total_memory
41
 
42
  scale = anchor_resolution / (h * w) * np.sqrt((vram_avail - anchor_memory_bias) / anchor_memory)
43
  scale = 1 if scale > 1 else scale
 
27
  inputs = []
28
  h = int(vcap.get(cv2.CAP_PROP_FRAME_WIDTH))
29
  w = int(vcap.get(cv2.CAP_PROP_FRAME_HEIGHT))
30
+ if device == 'cuda':
31
+ anchor_resolution = 1024 * 512
32
+ anchor_memory = 1500 * 1024**2
33
+ anchor_memory_bias = 2500 * 1024**2
34
+ vram_avail = torch.cuda.get_device_properties(device).total_memory
35
+ else':
36
  # Do not resize in cpu mode
37
  anchor_resolution = 8192*8192
38
  anchor_memory = 1
39
  anchor_memory_bias = 0
40
  vram_avail = 1
 
 
 
 
 
41
 
42
  scale = anchor_resolution / (h * w) * np.sqrt((vram_avail - anchor_memory_bias) / anchor_memory)
43
  scale = 1 if scale > 1 else scale