goryhon commited on
Commit
61a603e
·
verified ·
1 Parent(s): 88237d7

Update web-demos/hugging_face/app.py

Browse files
Files changed (1) hide show
  1. web-demos/hugging_face/app.py +2 -44
web-demos/hugging_face/app.py CHANGED
@@ -233,51 +233,9 @@ def show_mask(video_state, interactive_state, mask_dropdown):
233
  # tracking vos
234
  def vos_tracking_video(video_state, interactive_state, mask_dropdown):
235
  operation_log = [("",""), ("Tracking finished! Try to click the Inpainting button to get the inpainting result.","Normal")]
 
236
  model.cutie.clear_memory()
237
- if interactive_state["track_end_number"]:
238
- following_frames = video_state["origin_images"][video_state["select_frame_number"]:interactive_state["track_end_number"]]
239
- else:
240
- following_frames = video_state["origin_images"][video_state["select_frame_number"]:]
241
-
242
- if interactive_state["multi_mask"]["masks"]:
243
- if len(mask_dropdown) == 0:
244
- mask_dropdown = ["mask_001"]
245
- mask_dropdown.sort()
246
- template_mask = interactive_state["multi_mask"]["masks"][int(mask_dropdown[0].split("_")[1]) - 1] * (int(mask_dropdown[0].split("_")[1]))
247
- for i in range(1,len(mask_dropdown)):
248
- mask_number = int(mask_dropdown[i].split("_")[1]) - 1
249
- template_mask = np.clip(template_mask+interactive_state["multi_mask"]["masks"][mask_number]*(mask_number+1), 0, mask_number+1)
250
- video_state["masks"][video_state["select_frame_number"]]= template_mask
251
- else:
252
- template_mask = video_state["masks"][video_state["select_frame_number"]]
253
- fps = video_state["fps"]
254
-
255
- # operation error
256
- if len(np.unique(template_mask))==1:
257
- template_mask[0][0]=1
258
- operation_log = [("Please add at least one mask to track by clicking the image in step2.","Error"), ("","")]
259
- # return video_output, video_state, interactive_state, operation_error
260
- chunk_size = 5
261
- masks = []
262
- logits = []
263
- painted_images = []
264
-
265
- for start in range(0, len(following_frames), chunk_size):
266
- end = min(start + chunk_size, len(following_frames))
267
- chunk_frames = following_frames[start:end]
268
-
269
- # всегда используем одну и ту же template_mask
270
- chunk_masks, chunk_logits, chunk_painted = model.generator(
271
- images=chunk_frames,
272
- template_mask=template_mask
273
- )
274
-
275
- masks.extend(chunk_masks)
276
- logits.extend(chunk_logits)
277
- painted_images.extend(chunk_painted)
278
-
279
-
280
- model.cutie.clear_memory()
281
 
282
  if interactive_state["track_end_number"]:
283
  video_state["masks"][video_state["select_frame_number"]:interactive_state["track_end_number"]] = masks
 
233
  # tracking vos
234
  def vos_tracking_video(video_state, interactive_state, mask_dropdown):
235
  operation_log = [("",""), ("Tracking finished! Try to click the Inpainting button to get the inpainting result.","Normal")]
236
+ masks, logits, painted_images = model.generator(images=following_frames, template_mask=template_mask)
237
  model.cutie.clear_memory()
238
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
239
 
240
  if interactive_state["track_end_number"]:
241
  video_state["masks"][video_state["select_frame_number"]:interactive_state["track_end_number"]] = masks