Spaces:
Running
on
L4
Running
on
L4
Commit
Β·
21df5b4
1
Parent(s):
228a5fd
add resolution constraints
Browse files- 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>
|