Spaces:
Running
on
T4
Running
on
T4
PKUWilliamYang
commited on
Commit
·
998a434
1
Parent(s):
e059e75
Update vtoonify_model.py
Browse files- vtoonify_model.py +4 -4
vtoonify_model.py
CHANGED
@@ -162,7 +162,7 @@ class Model():
|
|
162 |
fourcc = cv2.VideoWriter_fourcc(*'mp4v')
|
163 |
videoWriter = cv2.VideoWriter('input.mp4', fourcc, video_cap.get(5), (int(right-left), int(bottom-top)))
|
164 |
kernel_1d = np.array([[0.125],[0.375],[0.375],[0.125]])
|
165 |
-
for i in range(num-1):
|
166 |
success, frame = video_cap.read()
|
167 |
frame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
|
168 |
if scale <= 0.75:
|
@@ -208,9 +208,9 @@ class Model():
|
|
208 |
|
209 |
batch_frames = []
|
210 |
if video_cap.get(3) != 0:
|
211 |
-
batch_size =
|
212 |
else:
|
213 |
-
batch_size =
|
214 |
print('Using batch size of %d on %d frames'%(batch_size, num))
|
215 |
with torch.no_grad():
|
216 |
if self.color_transfer:
|
@@ -218,7 +218,7 @@ class Model():
|
|
218 |
else:
|
219 |
s_w = instyle.clone()
|
220 |
s_w[:,:7] = exstyle[:,:7]
|
221 |
-
for i in
|
222 |
success, frame = video_cap.read()
|
223 |
frame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
|
224 |
batch_frames += [self.transform(frame).unsqueeze(dim=0).to(self.device)]
|
|
|
162 |
fourcc = cv2.VideoWriter_fourcc(*'mp4v')
|
163 |
videoWriter = cv2.VideoWriter('input.mp4', fourcc, video_cap.get(5), (int(right-left), int(bottom-top)))
|
164 |
kernel_1d = np.array([[0.125],[0.375],[0.375],[0.125]])
|
165 |
+
for i in tqdm(range(num-1)):
|
166 |
success, frame = video_cap.read()
|
167 |
frame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
|
168 |
if scale <= 0.75:
|
|
|
208 |
|
209 |
batch_frames = []
|
210 |
if video_cap.get(3) != 0:
|
211 |
+
batch_size = max(1, int(round(4 * 256* 256/ video_cap.get(3) / video_cap.get(4))))
|
212 |
else:
|
213 |
+
batch_size = 1
|
214 |
print('Using batch size of %d on %d frames'%(batch_size, num))
|
215 |
with torch.no_grad():
|
216 |
if self.color_transfer:
|
|
|
218 |
else:
|
219 |
s_w = instyle.clone()
|
220 |
s_w[:,:7] = exstyle[:,:7]
|
221 |
+
for i in range(num):
|
222 |
success, frame = video_cap.read()
|
223 |
frame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
|
224 |
batch_frames += [self.transform(frame).unsqueeze(dim=0).to(self.device)]
|