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
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG_PENDING.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
### Bug Fixes 🐞

#### CLI
* New flag to enable content detection on Nvidia Transcoder: `-detectContent`. When set, Transcoder will initialize Tensorflow runtime on each Nvidia GPU, and will run an additional Detector profile, if requested by the transcoding job.

#### General

Expand Down
1 change: 1 addition & 0 deletions cmd/livepeer/livepeer.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ func parseLivepeerConfig() starter.LivepeerConfig {
cfg.Netint = flag.String("netint", *cfg.Netint, "Comma-separated list of NetInt device GUIDs (or \"all\" for all available devices)")
cfg.TestTranscoder = flag.Bool("testTranscoder", *cfg.TestTranscoder, "Test Nvidia GPU transcoding at startup")
cfg.SceneClassificationModelPath = flag.String("sceneClassificationModelPath", *cfg.SceneClassificationModelPath, "Path to scene classification model")
cfg.DetectContent = flag.Bool("detectContent", *cfg.DetectContent, "Set to true to enable content type detection")

// Onchain:
cfg.EthAcctAddr = flag.String("ethAcctAddr", *cfg.EthAcctAddr, "Existing Eth account address")
Expand Down
39 changes: 23 additions & 16 deletions cmd/livepeer/starter/starter.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ type LivepeerConfig struct {
Netint *string
TestTranscoder *bool
SceneClassificationModelPath *string
DetectContent *bool
EthAcctAddr *string
EthPassword *string
EthKeystorePath *string
Expand Down Expand Up @@ -146,7 +147,8 @@ func DefaultLivepeerConfig() LivepeerConfig {
defaultNvidia := ""
defaultNetint := ""
defaultTestTranscoder := true
defaultSceneClassificationModelPath := ""
defaultDetectContent := false
defaultSceneClassificationModelPath := "tasmodel.pb"

// Onchain:
defaultEthAcctAddr := ""
Expand Down Expand Up @@ -211,6 +213,7 @@ func DefaultLivepeerConfig() LivepeerConfig {
Netint: &defaultNetint,
TestTranscoder: &defaultTestTranscoder,
SceneClassificationModelPath: &defaultSceneClassificationModelPath,
DetectContent: &defaultDetectContent,

// Onchain:
EthAcctAddr: &defaultEthAcctAddr,
Expand Down Expand Up @@ -387,18 +390,27 @@ func StartLivepeer(ctx context.Context, cfg LivepeerConfig) {
glog.Fatal(err)
return
}
} else {
// no capability test was run, assume default capabilities
transcoderCaps = append(transcoderCaps, core.DefaultCapabilities()...)
}
// FIXME: Short-term hack to pre-load the detection models on every device
if accel == ffmpeg.Nvidia && *cfg.SceneClassificationModelPath != "" {
detectorProfile := ffmpeg.DSceneAdultSoccer
detectorProfile.ModelPath = *cfg.SceneClassificationModelPath
core.DetectorProfile = &detectorProfile
for _, d := range devices {
tc, err := core.NewNvidiaTranscoderWithDetector(&detectorProfile, d)
if err != nil {
glog.Fatalf("Could not initialize detector")
// initialize Tensorflow runtime on each device to reduce delay when creating new transcoding session
if accel == ffmpeg.Nvidia && *cfg.DetectContent {
if _, err := os.Stat(*cfg.SceneClassificationModelPath); err == nil {
detectorProfile := ffmpeg.DSceneAdultSoccer
detectorProfile.ModelPath = *cfg.SceneClassificationModelPath
core.DetectorProfile = &detectorProfile
for _, d := range devices {
tc, err := core.NewNvidiaTranscoderWithDetector(&detectorProfile, d)
if err != nil {
glog.Fatalf("Could not initialize content detector")
}
defer tc.Stop()
}
defer tc.Stop()
// add SceneClassification capability
transcoderCaps = append(transcoderCaps, core.Capability_SceneClassification)
} else {
glog.Fatalf("Content detection is enabled, but the model file '%s' does not exist", *cfg.SceneClassificationModelPath)
}
}
// Initialize LB transcoder
Expand Down Expand Up @@ -1008,11 +1020,6 @@ func StartLivepeer(ctx context.Context, cfg LivepeerConfig) {
// if http addr is not provided, listen to all ifaces
// take the port to listen to from the service URI
*cfg.HttpAddr = defaultAddr(*cfg.HttpAddr, "", n.GetServiceURI().Port())

if *cfg.SceneClassificationModelPath != "" {
// Only enable experimental capabilities if scene classification model is actually loaded
transcoderCaps = append(transcoderCaps, core.ExperimentalCapabilities()...)
}
if !*cfg.Transcoder && n.OrchSecret == "" {
glog.Fatal("Running an orchestrator requires an -orchSecret for standalone mode or -transcoder for orchestrator+transcoder mode")
}
Expand Down