High Quality
Browse files- hugging_face/app.py +1 -12
hugging_face/app.py
CHANGED
|
@@ -140,16 +140,6 @@ def get_frames_from_video(video_input, video_state):
|
|
| 140 |
print("read_frame_source:{} error. {}\n".format(video_path, str(e)))
|
| 141 |
image_size = (frames[0].shape[0],frames[0].shape[1])
|
| 142 |
|
| 143 |
-
# resize if resolution too big
|
| 144 |
-
if image_size[0]>=1280 and image_size[0]>=1280:
|
| 145 |
-
scale = 1080 / min(image_size)
|
| 146 |
-
new_w = int(image_size[1] * scale)
|
| 147 |
-
new_h = int(image_size[0] * scale)
|
| 148 |
-
# update frames
|
| 149 |
-
frames = [cv2.resize(f, (new_w, new_h), interpolation=cv2.INTER_AREA) for f in frames]
|
| 150 |
-
# update image_size
|
| 151 |
-
image_size = (frames[0].shape[0],frames[0].shape[1])
|
| 152 |
-
|
| 153 |
# initialize video_state
|
| 154 |
video_state = {
|
| 155 |
"user_name": user_name,
|
|
@@ -363,7 +353,7 @@ def generate_video_from_frames(frames, output_path, fps=30, gray2rgb=False, audi
|
|
| 363 |
video_temp_path = output_path.replace(".mp4", "_temp.mp4")
|
| 364 |
|
| 365 |
# resize back to ensure input resolution
|
| 366 |
-
imageio.mimwrite(video_temp_path, frames, fps=fps, quality=
|
| 367 |
codec='libx264', ffmpeg_params=["-vf", f"scale={w}:{h}"])
|
| 368 |
|
| 369 |
# add audio to video if audio path exists
|
|
@@ -450,7 +440,6 @@ description = r"""
|
|
| 450 |
🔥 MatAnyone is a practical human video matting framework supporting target assignment 🎯.<br>
|
| 451 |
🎪 Try to drop your video/image, assign the target masks with a few clicks, and get the the matting results 🤡!<br>
|
| 452 |
|
| 453 |
-
*Note: Due to the online GPU memory constraints, any input with too big resolution will be resized to 1080p.<br>*
|
| 454 |
🚀 <b> If you encounter any issue (e.g., frozen video output) or wish to run on higher resolution inputs, please consider <u>duplicating this space</u> or
|
| 455 |
<u>launching the <a href='https://github.com/pq-yang/MatAnyone?tab=readme-ov-file#-interactive-demo' target='_blank'>demo</a> locally</u> following the GitHub instructions.</b>
|
| 456 |
"""
|
|
|
|
| 140 |
print("read_frame_source:{} error. {}\n".format(video_path, str(e)))
|
| 141 |
image_size = (frames[0].shape[0],frames[0].shape[1])
|
| 142 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 143 |
# initialize video_state
|
| 144 |
video_state = {
|
| 145 |
"user_name": user_name,
|
|
|
|
| 353 |
video_temp_path = output_path.replace(".mp4", "_temp.mp4")
|
| 354 |
|
| 355 |
# resize back to ensure input resolution
|
| 356 |
+
imageio.mimwrite(video_temp_path, frames, fps=fps, quality=10,
|
| 357 |
codec='libx264', ffmpeg_params=["-vf", f"scale={w}:{h}"])
|
| 358 |
|
| 359 |
# add audio to video if audio path exists
|
|
|
|
| 440 |
🔥 MatAnyone is a practical human video matting framework supporting target assignment 🎯.<br>
|
| 441 |
🎪 Try to drop your video/image, assign the target masks with a few clicks, and get the the matting results 🤡!<br>
|
| 442 |
|
|
|
|
| 443 |
🚀 <b> If you encounter any issue (e.g., frozen video output) or wish to run on higher resolution inputs, please consider <u>duplicating this space</u> or
|
| 444 |
<u>launching the <a href='https://github.com/pq-yang/MatAnyone?tab=readme-ov-file#-interactive-demo' target='_blank'>demo</a> locally</u> following the GitHub instructions.</b>
|
| 445 |
"""
|