[feat] Add PyNvBatchAsyncStreamReader for 2D batched async stream dec…#20
[feat] Add PyNvBatchAsyncStreamReader for 2D batched async stream dec…#20xupinjie wants to merge 3 commits into
Conversation
RmSchaffert
left a comment
There was a problem hiding this comment.
Thank you!
I added some inline comments in the code. Please have a look.
| remains the right choice when you only need one frame per video per | ||
| iteration. | ||
|
|
||
| **Key Differences from 1D Async Stream Access** |
There was a problem hiding this comment.
It may be good to mention that the file list remains the same (i.e. a flat list with one file name per camera) for both methods. Although this is already implied by the description above, I think it may help with understanding.
|
|
||
| **File:** `packages/on_demand_video_decoder/samples/SampleBatchAsyncStreamAccess.py` | ||
|
|
||
| **When to Use** |
There was a problem hiding this comment.
Does this improve performance or is it "just" a convenience feature? It may be good to add a short note on that as especially the third point in the list below seems to indicate that this is a convenience feature.
| > views into the reader's internal aggregator pool. Submitting the next | ||
| > {py:meth}`~accvlab.on_demand_video_decoder.PyNvBatchAsyncStreamReader.Decode` | ||
| > reuses that memory. You **must** clone every frame you want to keep | ||
| > **before** the next ``Decode()`` call. Skipping the clone is silent data |
There was a problem hiding this comment.
Nitpick: I would say "Skipping the clone [leads to]" instead of "[is]"
| can be extracted (limited / MPEG range is assumed). | ||
|
|
||
| Returns: | ||
| PyNvBatchAsyncStreamReader instance. |
There was a problem hiding this comment.
Please consider making PyNvBatchAsyncStreamReader a reference (link) to allow for easy navigation when reading the docs.
| to a background C++ worker thread and returns the decoded frames as | ||
| ``List[List[RGBFrame]]`` indexed ``[v][f]``. It is async-only (no sync | ||
| ``Decode`` method) and 2D-only. The 1D ``PyNvSampleReader`` class is | ||
| unchanged and serves the 1-frame-per-video case. |
There was a problem hiding this comment.
Maybe remove the "is unchanged" formulation, as this refers to a prior version instead of describing the current state.
| Clear all underlying video readers. Waits for pending async task first. | ||
| )pbdoc") | ||
| .def( | ||
| "release_device_memory", |
There was a problem hiding this comment.
Should release_device_memory and release_decoder be in camel case? The other methods are in upper camel case. However, I see that other decoders have some methods in snake case. Are these methods special?
| # Stage detection: is Decode actually implemented? | ||
| # --------------------------------------------------------------------------- | ||
|
|
||
| def _probe_decode_implemented(): |
There was a problem hiding this comment.
Is this still needed? As the implementation is already available, it may be better to remove this to avoid unneeded complexity in the code.
| .. literalinclude:: ../examples/demo.py | ||
| ``` | ||
|
|
||
| Inside Python docstrings, paths are relative to the file that includes the docstring (the autodoc directive's location), so absolute paths are acceptable there. |
There was a problem hiding this comment.
Absolute paths (w.r.t. the local file system) would still break.
Maybe something like:
For directives inside Python docstrings rendered by autodoc:
1. Find the docs file that renders the docstring, usually `packages/<pkg>/docs/api*.rst`.
2. Resolve directive paths from that docs file, not from the Python source file.
3. Prefer files under `packages/<pkg>/docs/`, e.g. `.. image:: images/foo.png`.
4. For package-root sibling dirs listed in `docu_referenced_dirs.txt`, use paths from `docs/`, e.g. `.. literalinclude:: ../example/foo.py`.
5. Never use machine-local absolute filesystem paths such as `/home/user/...`.
|
|
||
| ### Rule 9 — Edit source, not mirror | ||
|
|
||
| Source-of-truth lives at `packages/<pkg>/docs/`. Files under `docs/contained_package_docs_mirror/<pkg>/docs/` are symlinks regenerated by `mirror_referenced_dirs.py` at build time. Editing the mirror is at best a no-op and at worst destructive (overwritten on next build). |
There was a problem hiding this comment.
Nitpick: In the best case, the edit would actually be done to the original file (as symlinks are used). Maybe say something like:
In the best case, this would work accidentally (due to symlink behavior), but in the worst case, ...
| python SampleStreamAsyncAccess.py | ||
| ``` | ||
|
|
||
| #### 3.2.4 Sample: Batch Async Stream Access (2D) |
There was a problem hiding this comment.
It may be good to mention in the description that for each V, the same number of frames must be used.
Description
Introduces a new async-only video decoder under accvlab.on_demand_video_decoder that decodes V videos × F frames per video in a single in-flight async submission, returning List[List[RGBFrame]] indexed [v][f]. Targeted at StreamPETR-like workloads consuming multi-sweep batches per training step.
Type of Change
Please select (at least one):
Testing
Checklist for testing:
scripts/run_tests.shOptionally, add a brief description.
Documentation, Examples, Tutorials, Demos
Checklist for documentation:
Optionally, add a brief description.
Code Quality
Checklist for dependencies:
pyproject.tomlif/as neededOptionally, add a brief description.
Related Issues / Context
If applicable, link related issues, discussions etc.
DCO / Sign-Off
Please refer to the section on Signing Your Work & Developer Certificate of Origin (DCO)
in the Contribution Guide before submitting your contribution.
References
For additional details, please refer to the Contribution Guide.
The following guides are available (referenced in the Contribution Guide for further details):
docs/guides/CONTRIBUTION_GUIDE.mddocs/guides/DEVELOPMENT_GUIDE.mddocs/guides/DOCUMENTATION_SETUP_GUIDE.mddocs/guides/FORMATTING_GUIDE.mdPlease also refer to the summary checklist in the Contribution Guide,
which is a guideline for what to consider when submitting your contribution and covers the same topics as the checklists above.