mirror of
https://github.com/gaomingqi/Track-Anything.git
synced 2025-12-16 08:27:49 +01:00
fix painter
This commit is contained in:
@@ -129,9 +129,9 @@ def point_painter(input_image, input_points, point_color=5, point_alpha=0.9, poi
|
|||||||
contour_mask[contour_mask>0.5] = 1.
|
contour_mask[contour_mask>0.5] = 1.
|
||||||
|
|
||||||
# paint mask
|
# paint mask
|
||||||
painted_image = vis_add_mask(input_image, point_mask, point_color, point_alpha)
|
painted_image = vis_add_mask(input_image.copy(), point_mask, point_color, point_alpha)
|
||||||
# paint contour
|
# paint contour
|
||||||
painted_image = vis_add_mask(painted_image, 1-contour_mask, contour_color, 1)
|
painted_image = vis_add_mask(painted_image.copy(), 1-contour_mask, contour_color, 1)
|
||||||
return painted_image
|
return painted_image
|
||||||
|
|
||||||
def mask_painter(input_image, input_mask, mask_color=5, mask_alpha=0.7, contour_color=1, contour_width=3):
|
def mask_painter(input_image, input_mask, mask_color=5, mask_alpha=0.7, contour_color=1, contour_width=3):
|
||||||
|
|||||||
29
tracker/xmem.py
Normal file
29
tracker/xmem.py
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
# input: frame list, first frame mask
|
||||||
|
# output: segmentation results on all frames
|
||||||
|
import os
|
||||||
|
import glob
|
||||||
|
import numpy as np
|
||||||
|
from PIL import Image
|
||||||
|
|
||||||
|
|
||||||
|
class XMem:
|
||||||
|
# based on https://github.com/hkchengrex/XMem
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
# video frames
|
||||||
|
video_path_list = glob.glob(os.path.join('/ssd1/gaomingqi/datasets/davis/JPEGImages/480p/dance-twirl', '*.jpg'))
|
||||||
|
video_path_list.sort()
|
||||||
|
# first frame
|
||||||
|
first_frame_path = '/ssd1/gaomingqi/datasets/davis/Annotations/480p/dance-twirl/00000.png'
|
||||||
|
|
||||||
|
# load frames
|
||||||
|
frames = []
|
||||||
|
for video_path in video_path_list:
|
||||||
|
frames.append(np.array(Image.open(video_path).convert('RGB')))
|
||||||
|
frames = np.stack(frames, 0) # N, H, W, C
|
||||||
|
|
||||||
|
# load first frame annotation
|
||||||
|
first_frame_annotation = np.array(Image.open(first_frame_path).convert('P')) # H, W, C
|
||||||
|
|
||||||
Reference in New Issue
Block a user