Spaces:
Paused
Paused
Update web-demos/hugging_face/inpainter/base_inpainter.py
Browse files
web-demos/hugging_face/inpainter/base_inpainter.py
CHANGED
@@ -197,30 +197,31 @@ class ProInpainter:
|
|
197 |
"""
|
198 |
|
199 |
frames = []
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
|
|
224 |
|
225 |
##############################################
|
226 |
# ProPainter inference
|
|
|
197 |
"""
|
198 |
|
199 |
frames = []
|
200 |
+
for i in range(len(npframes)):
|
201 |
+
frames.append(Image.fromarray(npframes[i].astype('uint8'), mode="RGB"))
|
202 |
+
del npframes
|
203 |
+
|
204 |
+
size = frames[0].size
|
205 |
+
# Применяем ratio, если не 1.0
|
206 |
+
if ratio != 1.0:
|
207 |
+
size = (int(ratio * size[0]) // 2 * 2, int(ratio * size[1]) // 2 * 2)
|
208 |
+
else:
|
209 |
+
size = (size[0] // 2 * 2, size[1] // 2 * 2) # просто округление до чётного
|
210 |
+
|
211 |
+
# ⚠️ УБРАНО авто-уменьшение до 720p
|
212 |
+
# frames останутся оригинального (или заданного ratio) размера
|
213 |
+
|
214 |
+
frames_len = len(frames)
|
215 |
+
frames, size, out_size = resize_frames(frames, size)
|
216 |
+
flow_masks, masks_dilated = read_mask_demo(masks, frames_len, size, dilate_radius, dilate_radius)
|
217 |
+
w, h = size
|
218 |
+
|
219 |
+
frames_inp = [np.array(f).astype(np.uint8) for f in frames]
|
220 |
+
frames = to_tensors()(frames).unsqueeze(0) * 2 - 1
|
221 |
+
flow_masks = to_tensors()(flow_masks).unsqueeze(0)
|
222 |
+
masks_dilated = to_tensors()(masks_dilated).unsqueeze(0)
|
223 |
+
frames, flow_masks, masks_dilated = frames.to(self.device), flow_masks.to(self.device), masks_dilated.to(self.device)
|
224 |
+
|
225 |
|
226 |
##############################################
|
227 |
# ProPainter inference
|