4
0
mirror of https://github.com/nerfstudio-project/nerfstudio.git synced 2026-11-10 18:17:31 +08:00

Fix a small issue in nerfstudio (#3769)

This commit is contained in:
bglglzd 2026-07-12 22:00:20 +03:00
parent 50e0e3c70c
commit eba2e794ee
6 changed files with 14 additions and 14 deletions

View File

@ -9,4 +9,4 @@ As we grow, we hope to provide more updated and extensive tooling support.
local_logger
profiling
benchmarking
benchmarking

View File

@ -30,7 +30,7 @@ You can customize the local writer by editing the attributes:
:class: info
If you want to create a new stat to track, simply add the stat name to the `EventName` enum.
- Remember to call some put event (e.g. `put_scalar` from `utils/writer.py` to place the value in the `EVENT_STORAGE`.
- Remember to call some put event (e.g. `put_scalar` from `utils/writer.py` to place the value in the `EVENT_STORAGE`.
- Remember to add the new enum to the `stats_to_track` list
:::
@ -45,4 +45,4 @@ A few common commands to use:
- Disable line wrapping
```bash
ns-train {METHOD_NAME} --logging.local-writer.max-log-size=0
```
```

View File

@ -78,9 +78,9 @@ To perform the profiling, you can either specify that you want to generate a fla
```bash
py-spy top $program
```
:::{admonition} Attention
:class: attention
In defining `program`, you will need to add an extra `--` before you specify your program's arguments.
:::
:::

View File

@ -141,7 +141,7 @@ Checkout these flowcharts for more customization on large datasets!
:width: 600
```
## Migrating Your DataManager to the new DataManager
## Migrating Your DataManager to the new DataManager
Many methods subclass a DataManager and add extra data to it. If you would like your custom datamanager to also support new parallel features, you can migrate any custom dataloading logic to the new `custom_ray_processor()` API. This function takes in a full training batch (either image or ray bundle) and allows the user to modify or add to it. Let's take a look at an example for the LERF method, which was built on Nerfstudio's VanillaDataManager. This API provides an interface to attach new information to the RayBundle (for ray based methods), Cameras object (for splatting based methods), or ground truth dictionary. It runs in a background process if disk caching is enabled, otherwise it runs in the main process.
Naively transfering code to `custom_ray_processor` may still OOM on very large datasets if initialization code requires computing something over the whole dataset. To fully take advantage of parallelization make sure your subclassed datamanager computes new information inside the `custom_ray_processor`, or caches a subset of the whole dataset. This can also still be slow if pre-computation requires GPU-heavy steps on the same GPU used for training.
@ -151,7 +151,7 @@ Naively transfering code to `custom_ray_processor` may still OOM on very large d
```python
class LERFDataManager(VanillaDataManager):
"""Subclass VanillaDataManager to add extra data processing
Args:
config: the DataManagerConfig used to instantiate class
"""
@ -197,7 +197,7 @@ class LERFDataManager(VanillaDataManager):
return ray_bundle, batch
```
To migrate this custom datamanager to the new datamanager, we'll subclass the new ParallelDataManager and shift the data customization process from `next_train()` to `custom_ray_processor()`.
To migrate this custom datamanager to the new datamanager, we'll subclass the new ParallelDataManager and shift the data customization process from `next_train()` to `custom_ray_processor()`.
The function `custom_ray_processor()` is called with a fully populated ray bundle and ground truth batch, just like the subclassed `next_train` in the above code. This code, however, is run in a background process.
```python

View File

@ -70,4 +70,4 @@ We also have a DynamicBatchPipeline that is used with InstantNGP to dynamically
:color: primary
:outline:
See the code!
```
```

View File

@ -63,13 +63,13 @@ class MyModel(nn.Module): # Must inherit from nn.Module
```
## Scene Pointer Callbacks
We forward user interactions with the viewer to the `ViewerControl` object, which you can use to interact with the scene.
We forward user interactions with the viewer to the `ViewerControl` object, which you can use to interact with the scene.
We currently support:
- `ViewerClick`: *single* clicks inside the viewer. The click is defined to be a ray that starts at the camera origin and passes through the click point on the screen, in world coordinates.
- `ViewerClick`: *single* clicks inside the viewer. The click is defined to be a ray that starts at the camera origin and passes through the click point on the screen, in world coordinates.
- `ViewerRectSelect`: drag to select a rectangle in the viewer screen. The rectangle is defined by two points (top-left and bottom-right corners) in normalized OpenCV screen coordinates.
To do this, register a callback using `register_pointer_cb()`.
To do this, register a callback using `register_pointer_cb()`.
You can also use `unregister_pointer_cb()` to remove callbacks that are no longer needed. A good example is a "Click on Scene" button, that when pressed, would register a callback that would wait for the next click, and then unregister itself.
@ -82,7 +82,7 @@ class MyModel(nn.Module): # must inherit from nn.Module
def __init__(self):
# Must be a class variable
self.viewer_control = ViewerControl() # no arguments
# Listen to clicks in the viewer...
def pointer_click_cb(click: ViewerClick):
print(f"Click at {click.origin} in direction {click.direction}, screen position {click.screen_pos}.")
@ -93,7 +93,7 @@ class MyModel(nn.Module): # must inherit from nn.Module
print(f"Rectangular selection from {rect.min_bounds} to {rect.max_bounds}.")
self.viewer_control.register_pointer_cb("click", pointer_rect_cb)
...
...
# Or make a button that, once pressed, listens to clicks in the viewer.
def button_cb(button: ViewerButton):
def pointer_click_cb(click: ViewerClick):