diff --git a/README.md b/README.md index ccbc074..d05c6f6 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,113 @@ -# select-video +# Select video + +*author: Chen Zhang* + + +
+ + + +## Description + +This operator select input list by simply aggregating, sorting and then filtering it. +
+ + +## Code Example + +For two input lists: video urls and scores, aggregate url by reduce_function, then sort aggregated scores, then select top k results. + +```python +import towhee + +towhee.dc['video_urls', 'scores']([[['a', 'a', 'c', 'a', 'b', 'b', 'c', 'c'], [2, 8, 9.3, 5, 2, 1, 0, -1]]])\ +.video_copy_detection.select_video[('video_urls','scores'), 'res'](top_k=2, reduce_function='mean', reverse=True)\ +.show() +``` + +![](mean.png) + +```python +import towhee + +towhee.dc['video_urls', 'scores']([[['a', 'a', 'c', 'a', 'b', 'b', 'c', 'c'], [2, 8, 9.3, 5, 2, 1, 0, -1]]])\ +.video_copy_detection.select_video[('video_urls','scores'), 'res'](top_k=2, reduce_function='sum', reverse=True)\ +.show() +``` +![](mean.png) + +```python +import towhee + +towhee.dc['video_urls', 'scores']([[['a', 'a', 'c', 'a', 'b', 'b', 'c', 'c'], [2, 8, 9.3, 5, 2, 1, 0, -1]]])\ +.video_copy_detection.select_video[('video_urls','scores'), 'res'](top_k=2, reduce_function='max', reverse=True)\ +.show() +``` + +![](max.png) + + +```python +import towhee + +towhee.dc['video_urls', 'scores']([[['a', 'a', 'c', 'a', 'b', 'b', 'c', 'c'], [2, 8, 9.3, 5, 2, 1, 0, -1]]])\ +.video_copy_detection.select_video[('video_urls','scores'), 'res'](top_k=2, reduce_function='min', reverse=True)\ +.show() +``` + +![](min.png) + + +
+ + + +## Factory Constructor + +Create the operator via the following factory method + +***select_video(top_k: int, reduce_function: str, reverse: bool)*** + +**Parameters:** + +​ ***top_k:*** *int* + +​ Select top k result. + + +​ ***reduce_function:*** *str* + +​ Aggregate function name, support name: +- sum +- mean +- max +- min + +​ ***reverse:*** *bool* + +​ Whether sorted result is reversed. + +
+ + + +## Interface + + +**Parameters:** + +​ ***video_urls:*** *List[str]* + +​ Video urls. + +​ ***scores:*** *List[float]* + +​ Every video scores. + + +**Returns:** *List[str]* + +​ Selected video url results. + + diff --git a/max.png b/max.png new file mode 100644 index 0000000..1bdc2dd Binary files /dev/null and b/max.png differ diff --git a/mean.png b/mean.png new file mode 100644 index 0000000..8ef1aac Binary files /dev/null and b/mean.png differ diff --git a/min.png b/min.png new file mode 100644 index 0000000..b71c6dd Binary files /dev/null and b/min.png differ