nikkar commited on
Commit
8d0855d
·
verified ·
1 Parent(s): 2e890e3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +1 -12
app.py CHANGED
@@ -42,38 +42,29 @@ def get_points_on_a_grid(
42
  device: Optional[torch.device] = torch.device("cpu"),
43
  ):
44
  r"""Get a grid of points covering a rectangular region
45
-
46
  `get_points_on_a_grid(size, extent)` generates a :attr:`size` by
47
  :attr:`size` grid fo points distributed to cover a rectangular area
48
  specified by `extent`.
49
-
50
  The `extent` is a pair of integer :math:`(H,W)` specifying the height
51
  and width of the rectangle.
52
-
53
  Optionally, the :attr:`center` can be specified as a pair :math:`(c_y,c_x)`
54
  specifying the vertical and horizontal center coordinates. The center
55
  defaults to the middle of the extent.
56
-
57
  Points are distributed uniformly within the rectangle leaving a margin
58
  :math:`m=W/64` from the border.
59
-
60
  It returns a :math:`(1, \text{size} \times \text{size}, 2)` tensor of
61
  points :math:`P_{ij}=(x_i, y_i)` where
62
-
63
  .. math::
64
  P_{ij} = \left(
65
  c_x + m -\frac{W}{2} + \frac{W - 2m}{\text{size} - 1}\, j,~
66
  c_y + m -\frac{H}{2} + \frac{H - 2m}{\text{size} - 1}\, i
67
  \right)
68
-
69
  Points are returned in row-major order.
70
-
71
  Args:
72
  size (int): grid size.
73
  extent (tuple): height and with of the grid extent.
74
  center (tuple, optional): grid center.
75
  device (str, optional): Defaults to `"cpu"`.
76
-
77
  Returns:
78
  Tensor: grid.
79
  """
@@ -100,13 +91,11 @@ def paint_point_track(
100
  colormap: Optional[List[Tuple[int, int, int]]] = None,
101
  ) -> np.ndarray:
102
  """Converts a sequence of points to color code video.
103
-
104
  Args:
105
  frames: [num_frames, height, width, 3], np.uint8, [0, 255]
106
  point_tracks: [num_points, num_frames, 2], np.float32, [0, width / height]
107
  visibles: [num_points, num_frames], bool
108
  colormap: colormap for points, each point has a different RGB color.
109
-
110
  Returns:
111
  video: [num_frames, height, width, 3], np.uint8, [0, 255]
112
  """
@@ -399,7 +388,7 @@ def track(
399
  # torch.cat([pred_tracks[:,:1],pred_tracks[:,1:]],dim=1)
400
  pred_tracks = (pred_tracks * torch.tensor([video_preview.shape[2], video_preview.shape[1]]).to(device) / torch.tensor([VIDEO_INPUT_RESO[1], VIDEO_INPUT_RESO[0]]).to(device))
401
 
402
- vis = Visualizer(save_dir="./saved_videos", pad_value=0, linewidth=3, tracks_leave_trace=0)
403
  # segm_mask = torch.zeros(queries.shape[1])
404
  # segm_mask[:num_tracks] = 1
405
  # print('segm_mask',segm_mask.shape, segm_mask)
 
42
  device: Optional[torch.device] = torch.device("cpu"),
43
  ):
44
  r"""Get a grid of points covering a rectangular region
 
45
  `get_points_on_a_grid(size, extent)` generates a :attr:`size` by
46
  :attr:`size` grid fo points distributed to cover a rectangular area
47
  specified by `extent`.
 
48
  The `extent` is a pair of integer :math:`(H,W)` specifying the height
49
  and width of the rectangle.
 
50
  Optionally, the :attr:`center` can be specified as a pair :math:`(c_y,c_x)`
51
  specifying the vertical and horizontal center coordinates. The center
52
  defaults to the middle of the extent.
 
53
  Points are distributed uniformly within the rectangle leaving a margin
54
  :math:`m=W/64` from the border.
 
55
  It returns a :math:`(1, \text{size} \times \text{size}, 2)` tensor of
56
  points :math:`P_{ij}=(x_i, y_i)` where
 
57
  .. math::
58
  P_{ij} = \left(
59
  c_x + m -\frac{W}{2} + \frac{W - 2m}{\text{size} - 1}\, j,~
60
  c_y + m -\frac{H}{2} + \frac{H - 2m}{\text{size} - 1}\, i
61
  \right)
 
62
  Points are returned in row-major order.
 
63
  Args:
64
  size (int): grid size.
65
  extent (tuple): height and with of the grid extent.
66
  center (tuple, optional): grid center.
67
  device (str, optional): Defaults to `"cpu"`.
 
68
  Returns:
69
  Tensor: grid.
70
  """
 
91
  colormap: Optional[List[Tuple[int, int, int]]] = None,
92
  ) -> np.ndarray:
93
  """Converts a sequence of points to color code video.
 
94
  Args:
95
  frames: [num_frames, height, width, 3], np.uint8, [0, 255]
96
  point_tracks: [num_points, num_frames, 2], np.float32, [0, width / height]
97
  visibles: [num_points, num_frames], bool
98
  colormap: colormap for points, each point has a different RGB color.
 
99
  Returns:
100
  video: [num_frames, height, width, 3], np.uint8, [0, 255]
101
  """
 
388
  # torch.cat([pred_tracks[:,:1],pred_tracks[:,1:]],dim=1)
389
  pred_tracks = (pred_tracks * torch.tensor([video_preview.shape[2], video_preview.shape[1]]).to(device) / torch.tensor([VIDEO_INPUT_RESO[1], VIDEO_INPUT_RESO[0]]).to(device))
390
 
391
+ vis = Visualizer(save_dir="./saved_videos", pad_value=0, linewidth=2, tracks_leave_trace=0)
392
  # segm_mask = torch.zeros(queries.shape[1])
393
  # segm_mask[:num_tracks] = 1
394
  # print('segm_mask',segm_mask.shape, segm_mask)