PeiqingYang commited on
Commit
21df5b4
Β·
1 Parent(s): 228a5fd

add resolution constraints

Browse files
Files changed (1) hide show
  1. hugging_face/app.py +12 -0
hugging_face/app.py CHANGED
@@ -141,6 +141,16 @@ def get_frames_from_video(video_input, video_state):
141
  print("read_frame_source:{} error. {}\n".format(video_path, str(e)))
142
  image_size = (frames[0].shape[0],frames[0].shape[1])
143
 
 
 
 
 
 
 
 
 
 
 
144
  # initialize video_state
145
  video_state = {
146
  "user_name": user_name,
@@ -434,6 +444,8 @@ description = r"""
434
  <b>Official Gradio demo</b> for <a href='https://github.com/pq-yang/MatAnyone' target='_blank'><b>MatAnyone: Stable Video Matting with Consistent Memory Propagation</b></a>.<br>
435
  πŸ”₯ MatAnyone is a practical human video matting framework supporting target assignment 🎯.<br>
436
  πŸŽͺ Try to drop your video/image, assign the target masks with a few clicks, and get the the matting results 🀑!<br>
 
 
437
  """
438
  article = r"""
439
  <b>If MatAnyone is helpful, please help to 🌟 the <a href='https://github.com/pq-yang/MatAnyone' target='_blank'>Github Repo</a>. Thanks!</b>
 
141
  print("read_frame_source:{} error. {}\n".format(video_path, str(e)))
142
  image_size = (frames[0].shape[0],frames[0].shape[1])
143
 
144
+ # resize if resolution too big
145
+ if image_size[0]>=1280 and image_size[0]>=1280:
146
+ scale = 1080 / min(image_size)
147
+ new_w = int(image_size[1] * scale)
148
+ new_h = int(image_size[0] * scale)
149
+ # update frames
150
+ frames = [cv2.resize(f, (new_w, new_h), interpolation=cv2.INTER_AREA) for f in frames]
151
+ # update image_size
152
+ image_size = (frames[0].shape[0],frames[0].shape[1])
153
+
154
  # initialize video_state
155
  video_state = {
156
  "user_name": user_name,
 
444
  <b>Official Gradio demo</b> for <a href='https://github.com/pq-yang/MatAnyone' target='_blank'><b>MatAnyone: Stable Video Matting with Consistent Memory Propagation</b></a>.<br>
445
  πŸ”₯ MatAnyone is a practical human video matting framework supporting target assignment 🎯.<br>
446
  πŸŽͺ Try to drop your video/image, assign the target masks with a few clicks, and get the the matting results 🀑!<br>
447
+
448
+ *Note: Due to the GPU memory constraints, any input with too big resolution will be resized to 1080p.*
449
  """
450
  article = r"""
451
  <b>If MatAnyone is helpful, please help to 🌟 the <a href='https://github.com/pq-yang/MatAnyone' target='_blank'>Github Repo</a>. Thanks!</b>