Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Productionize Soccer Stream Detection #2431

Merged
merged 8 commits into from
Jun 9, 2022
Merged

Conversation

cyberj0g
Copy link
Contributor

What does this pull request do? Explain your changes. (required)
Make content detection functionality production-ready.

Limitations
Current implementation de facto uses a separate ad-hoc data stream to output results - the webhook. Detection results are not included with the renditions, because the DNN filter is run in a separate output, which doesn't produce any renditions. Model output is included into AVFrame metadata only for the purpose of transferring data back to LPMS. This would work for internal process of unwanted content detection, but the process needs to be re-worked to produce 'output stream' to end user, if required in the future for ML capabilities.

Specific updates (required)

  • Add -detectContent command line flag to enable content detection for transcoder
  • Fix list of T capabilities to include SceneDetection capability, if enabled
  • Create correct list of T capabilities in case capabilities testing is disabled

How did you test each of these updates (required)

  • Stdout echo web server for content detection webhook
while true; do {   echo -ne "HTTP/1.0 200 OK\r\nContent-Length: 0"; } | nc -l -p 8081 -q 1 ; done
  • B
livepeer -broadcaster -rtmpAddr :1936 -cliAddr 127.0.0.1:7937 -nvidia all -httpAddr 127.0.0.1:8936 -orchAddr 127.0.0.1:8935 -orchSecret 11111111111 -v 6 -detectionWebhookUrl http://localhost:8081/
  • OT
livepeer -transcoder -orchestrator -serviceAddr 127.0.0.1:8935 -nvidia all -v 7 -detectContent
  • Stream
ffmpeg -re -i bbb.mp4 -c:a copy -c:v copy -f hls -hls_time 2 -headers 'Livepeer-Transcode-Configuration:
                                                                    {"detection": {"freq": 2, "sampleRate": 10, "sceneClassification": [{"name": "soccer"}]}}' http://localhost:8936/live/movie3/
  • Webhook output
{"manifestID":"movie3","seqNo":10,"sceneClassification":[{"name":"soccer","probability":0.00676799938082695}]}

Does this pull request close any open issues?

#2394

Checklist:

TBD: more tests for standalone T

@cyberj0g cyberj0g requested a review from thomshutt May 25, 2022 09:49
@codecov
Copy link

codecov bot commented May 25, 2022

Codecov Report

Merging #2431 (ddc9c1e) into master (d360781) will decrease coverage by 0.11113%.
The diff coverage is 11.36364%.

Impacted file tree graph

@@                 Coverage Diff                 @@
##              master       #2431         +/-   ##
===================================================
- Coverage   55.02775%   54.91662%   -0.11113%     
===================================================
  Files             94          94                 
  Lines          19641       19668         +27     
===================================================
- Hits           10808       10801          -7     
- Misses          8236        8271         +35     
+ Partials         597         596          -1     
Impacted Files Coverage Δ
cmd/livepeer/starter/starter.go 2.36220% <0.00000%> (-0.01405%) ⬇️
server/ot_rpc.go 25.21994% <17.39130%> (-0.63676%) ⬇️
cmd/livepeer/livepeer.go 46.62921% <100.00000%> (+0.30152%) ⬆️
common/util.go 61.58537% <0.00000%> (-2.43902%) ⬇️
discovery/db_discovery.go 67.01389% <0.00000%> (-1.04167%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d360781...ddc9c1e. Read the comment docs.

@cyberj0g cyberj0g marked this pull request as draft May 30, 2022 11:35
@cyberj0g
Copy link
Contributor Author

Converting this to draft, because discovered the following while testing:

  1. Doesn't work in a separate O-T configuration, because detection results are not transmitted between T and O by HTTP
  2. Detection webhook, which I expect to be the primary way of detecting unwanted content, not get called when verification is enabled.

Copy link
Contributor

@thomshutt thomshutt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, do we have any metrics around this at the moment? It'd be good when we begin testing to be able to see how many detections we're getting

@thomshutt thomshutt self-requested a review May 30, 2022 12:48
@cyberj0g cyberj0g marked this pull request as ready for review June 7, 2022 08:28
@cyberj0g
Copy link
Contributor Author

cyberj0g commented Jun 7, 2022

Looks good, do we have any metrics around this at the moment? It'd be good when we begin testing to be able to see how many detections we're getting

No, there are no metrics there. I expect that classification results will be reported through webhook, and metrics probably should be logged on that end.

@@ -458,15 +458,6 @@ func TestParseAccelDevices_WrongDriver(t *testing.T) {
getPCI = originGetPCI
}

func TestParseAccelDevices_FailedDetection(t *testing.T) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@red-0ne what is the purpose of this test? It always fails, if Nvidia GPU is present.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right. I think it should setup its GetGPU/GetCPU
The idea was to fail when no GPUs or appropriate PCI devices are detected (it fails now if you have a real one)
A minimal resolution would be

	getGPU = func() ([]*gpu.GraphicsCard, error) {
		return []*gpu.GraphicsCard{}, nil
	}
	getPCI = func() ([]*pci.Device, error) {
		return []*pci.Device{}, nil
	}

@cyberj0g cyberj0g merged commit d7b7626 into master Jun 9, 2022
@hjpotter92 hjpotter92 deleted the ip/scene-detect-prod branch September 26, 2022 17:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants