logo
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Readme
Files and versions

Updated 1 year ago

video-copy-detection

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.

from towhee import pipe, ops, DataCollection

p = (
    pipe.input('video_urls', 'scores') \
        .map(('video_urls', 'scores'), 'res', ops.video_copy_detection.select_video(top_k=2, reduce_function='mean', reverse=True)) \
        .output('video_urls', 'scores', 'res')
)

DataCollection(p(['a', 'a', 'c', 'a', 'b', 'b', 'c', 'c'], [2, 8, 9.3, 5, 2, 1, 0, -1])).show()

from towhee import pipe, ops, DataCollection

p = (
    pipe.input('video_urls', 'scores') \
        .map(('video_urls', 'scores'), 'res', ops.video_copy_detection.select_video(top_k=2, reduce_function='sum', reverse=True)) \
        .output('video_urls', 'scores', 'res')
)

DataCollection(p(['a', 'a', 'c', 'a', 'b', 'b', 'c', 'c'], [2, 8, 9.3, 5, 2, 1, 0, -1])).show()

from towhee import pipe, ops, DataCollection

p = (
    pipe.input('video_urls', 'scores') \
        .map(('video_urls', 'scores'), 'res', ops.video_copy_detection.select_video(top_k=2, reduce_function='max', reverse=True)) \
        .output('video_urls', 'scores', 'res')
)

DataCollection(p(['a', 'a', 'c', 'a', 'b', 'b', 'c', 'c'], [2, 8, 9.3, 5, 2, 1, 0, -1])).show()

from towhee import pipe, ops, DataCollection

p = (
    pipe.input('video_urls', 'scores') \
        .map(('video_urls', 'scores'), 'res', ops.video_copy_detection.select_video(top_k=2, reduce_function='min', reverse=True)) \
        .output('video_urls', 'scores', 'res')
)

DataCollection(p(['a', 'a', 'c', 'a', 'b', 'b', 'c', 'c'], [2, 8, 9.3, 5, 2, 1, 0, -1])).show()


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.

ChengZi 9b81a441cf rm dc2 in readme 7 Commits
file-icon .gitattributes
1.1 KiB
download-icon
Initial commit 2 years ago
file-icon README.md
2.5 KiB
download-icon
rm dc2 in readme 1 year ago
file-icon __init__.py
756 B
download-icon
select video 2 years ago
file-icon max.png
16 KiB
download-icon
README.md 2 years ago
file-icon mean.png
16 KiB
download-icon
README.md 2 years ago
file-icon min.png
16 KiB
download-icon
README.md 2 years ago
file-icon select_video.py
2.8 KiB
download-icon
Add PyOperator 1 year ago