-
Notifications
You must be signed in to change notification settings - Fork 10
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
Add detection filter #1
Conversation
Is the blob at 62164c7 a compile time or a run time requirement? Rather than checking a 25+ MB binary blob into the tree (git does not handle such blobs well), can we make it a temporary requirement to have that blob locally available? Then later on we can explore alternative solutions, perhaps using git-lfs or even downloading a default model from somewhere if necessary. |
Not need in compile time. This blob is run time requirement and can't replace it with a temporary. |
If it's runtime, then just make a note that the user needs to be sure to download the blob prior to running the filter. Checking into the ffmpeg tree doesn't seem to be a strict requirement either, since it'd have to be shipped over to the user (LPMS) somehow. For now, we can store the model in a GCS storage bucket and add a link to that somewhere in the documentation. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM after fixing/answering minor comments.
Needs to be rebased on top of latest livepeer branch before merge.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mostly small nit comments and a few clarifying questions.
I think it would be helpful to describe in a comment what the additional steps in the filter that currently involve sws_scale are doing and why they are necessary (as already mentioned in another comment).
@oscar-davids I see that 3be1a59 sets the |
As we know there were many changes in the original FFmpeg DNN module in 2~3 months, I reviewed the code and thought that have to update a lot of parts of our codebase now It may cause safety issues. The method they are using is to create a sess_config(i.e 0x10022805320e09cdccccccccccec3f20012a01303801) with an external python code(tf_sess_config.py) and use it as an argument. Overall, our goal is to use multiple GPUs. |
The go-livepeer install_ffmpeg.sh script currently disables the majority of features and then selectively enables only the features that are currently required. I believe the motivation for this is to avoid unnecessarily increasing the size of the resulting binary by including code for additional features that are not used. When I tried compiling go-livepeer using the code from this branch, I ran into compilation errors indicating missing references for ff_get_dnn_module. I was able to workaround this compilation error by also enabling the SR filter. My best guess as to why enabling the SR filter addressed the compilation error is that enabling the SR filter pulled in the required DNN dependencies required by the lvpdnn filter. In the configure file, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM for merge after adding the dnn
dependency in configure
script as mentioned by Yondon.
@oscar-davids Saw that I was tagged for a follow up review, but I can't seem to find the changes relevant to this comment. Could you point to the changes that address that comment? |
I think that there is nothing to change in the code because it is ffmpeg build and config options. |
We can add a line within this PR Line 3483 in b34f2e1
lvpdnn_filter_select="dnn"
|
Confirmed that after changes in a10074d we no longer need to enable sr-filter in go-livepeer livepeer/go-livepeer@a121c1e 👍 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
LGTM for merge after -
|
7dfce00
to
447450a
Compare
Merged ✔️ 🚢 |
CID 1460603 (#1 of 1): Improper use of negative value (NEGATIVE_RETURNS)
In close_output(), a dummy frame is created with format NONE passed to enc_open(), which isn't prepared for it. The NULL pointer dereference happened at av_pix_fmt_desc_get(enc_ctx->pix_fmt)->comp[0].depth. When fgt.graph is NULL, skip fg_output_frame() since there is nothing to output. frame #0: 0x0000005555bc34a4 ffmpeg_g`enc_open(opaque=0xb400007efe2db690, frame=0xb400007efe2d9f70) at ffmpeg_enc.c:235:44 frame livepeer#1: 0x0000005555bef250 ffmpeg_g`enc_open(sch=0xb400007dde2d4090, enc=0xb400007e4e2daad0, frame=0xb400007efe2d9f70) at ffmpeg_sched.c:1462:11 frame livepeer#2: 0x0000005555bee094 ffmpeg_g`send_to_enc(sch=0xb400007dde2d4090, enc=0xb400007e4e2daad0, frame=0xb400007efe2d9f70) at ffmpeg_sched.c:1571:19 frame livepeer#3: 0x0000005555bee01c ffmpeg_g`sch_filter_send(sch=0xb400007dde2d4090, fg_idx=0, out_idx=0, frame=0xb400007efe2d9f70) at ffmpeg_sched.c:2154:12 frame livepeer#4: 0x0000005555bcf124 ffmpeg_g`close_output(ofp=0xb400007e4e2d85b0, fgt=0x0000007d1790eb08) at ffmpeg_filter.c:2225:15 frame livepeer#5: 0x0000005555bcb000 ffmpeg_g`fg_output_frame(ofp=0xb400007e4e2d85b0, fgt=0x0000007d1790eb08, frame=0x0000000000000000) at ffmpeg_filter.c:2317:16 frame livepeer#6: 0x0000005555bc7e48 ffmpeg_g`filter_thread(arg=0xb400007eae2ce7a0) at ffmpeg_filter.c:2836:15 frame livepeer#7: 0x0000005555bee568 ffmpeg_g`task_wrapper(arg=0xb400007d8e2db478) at ffmpeg_sched.c:2200:21 Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
Add dnn filter for detection(livepeer/lpms#181).
To use this filter, need to install the TensorFlow for C library.
See https://www.tensorflow.org/install/install_c and configure FFmpeg with --enable-libtensorflow.
We can write the result of the detection filter in a file.
Added "lavfi.lvpdnn.text" metadata.
filter name
lvpdnn
parameter
model: trained tensorflow model path.(file extention is .pb)
input: tensorflow input layer name(in our model is input_1)
output: tensorflow output layer name(in our model is reshape_3/Reshape)
sample: detect every sample frames.
threshold: threshold for inference confidence.
log: path for save inference results.
Benchmark and example
ffmpeg -i input.mp4 -vf lvpdnn=model=tmodel.pb:input=input:output=outshape:sample=1:threshold=0.5:log=outlog.txt out.mp4
ffmpeg -vsync 0 -hwaccel cuvid -c:v h264_cuvid -i input.mp4 -c:a copy -vf lvpdnn=model=tmodel.pb:input=input:output=outshape:sample=1:threshold=0.5:log=outlog.txt -c:v h264_nvenc -b:v 5M out.mp4
ffmpeg -vsync 0 -c:v h264_cuvid -i input.mp4 -vf lvpdnn=model=tmodel.pb:input=input:output=outshape:sample=1:threshold=0.5:log=outlog.txt -c:v h264_nvenc out.mp4
ffprobe -show_entries frame_tags=lavfi.lvpdnn.text -f lavfi -i "movie=input.mp4,lvpdnn=model=tmodel.pb:input=input:output=outshape:sample=1:threshold=5.0" > lvptext.txt