|
|
|
# Filter Tiny Segments
|
|
|
|
|
|
|
|
*author: Chen Zhang*
|
|
|
|
|
|
|
|
|
|
|
|
<br />
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
## Description
|
|
|
|
|
|
|
|
This operator can filter tiny detected segments with format of list of `[start_second_1, start_second_2, end_second_1, end_second_2]`
|
|
|
|
<br />
|
|
|
|
|
|
|
|
|
|
|
|
## Code Example
|
|
|
|
|
|
|
|
|
|
|
|
```python
|
|
|
|
import towhee
|
|
|
|
towhee.dc['pred']([[[0, 0, 100, 100], [0, 0, 10, 10], [0, 0, 60, 10]]]) \
|
|
|
|
.video_copy_detection.filter_tiny_segments['pred', 'filtered_pred'](filter_s_thresh=20) \
|
|
|
|
.show()
|
|
|
|
```
|
|
|
|
|
|
|
|
![](result.png)
|
|
|
|
|
|
|
|
|
|
|
|
```python
|
|
|
|
import towhee
|
|
|
|
towhee.dc['pred', 'sim_hw']([[[[0, 0, 10, 10]], [11, 11]]]) \
|
|
|
|
.video_copy_detection.filter_tiny_segments[('pred', 'sim_hw'), 'filtered_pred'](filter_s_thresh=20) \
|
|
|
|
.show()
|
|
|
|
```
|
|
|
|
![](result2.png)
|
|
|
|
|
|
|
|
## Factory Constructor
|
|
|
|
|
|
|
|
Create the operator via the following factory method
|
|
|
|
|
|
|
|
***filter_tiny_segments(filter_s_thresh, segment_len_rate)***
|
|
|
|
|
|
|
|
|
|
|
|
**Parameters:**
|
|
|
|
|
|
|
|
***filter_s_thresh:*** *float*
|
|
|
|
|
|
|
|
Use a thresh to filter detected box which is smaller than it.
|
|
|
|
|
|
|
|
***segment_len_rate:*** *float*
|
|
|
|
|
|
|
|
Filter expect longer then segment_len_rate * video length. Only useful for filter expect near video length segments.
|
|
|
|
|
|
|
|
<br />
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
## Interface
|
|
|
|
|
|
|
|
|
|
|
|
**Parameters:**
|
|
|
|
|
|
|
|
***pred_value:*** *List*
|
|
|
|
|
|
|
|
List of predicted segment second infos of a video pair
|
|
|
|
|
|
|
|
***sim_hw:*** *Tuple*
|
|
|
|
|
|
|
|
Similarity matrix height and weight of a video pair. If sample rate is 1s, sim_hw is also the lengths of these videos.
|
|
|
|
|
|
|
|
|
|
|
|
**Returns:**
|
|
|
|
|
|
|
|
***res_pred_list:*** *List*
|
|
|
|
|
|
|
|
List of filtered predicted segment second infos
|