undo docs change

This commit is contained in:
terrance committed 2023-05-12 18:47:13 +00:00
1 parent a0c38e8430
commit c9151d4a90
21 files changed
+7547 -7568

No files matched your search

+7 -6
View File
@@ -33,15 +33,16 @@ current_value = self.custom_value.value
**Callbacks**
You can register a callback that will be called whenever a new value for your GUI element is available. For example, one can use a callback to update config parameters when elements are changed:
```python
def on_change_callback(handle: ViewerCheckbox) -> None:
self.config.example_parameter = handle.value
def on_change_callback(handle: GuiHandle):
self.config.example_parameter = handle.get_value()
self.custom_checkbox = ViewerCheckbox(
name="Checkbox",
default_value=False,
cb_hook=on_change_callback,
default_value = False,
cb_hook = on_change_callback
)
```
The GuiHandle value is a viser object which you can use to get the new value.
**Thread safety**
Note that `ViewerElement` values can change asynchronously to model execution. So, it's best practice to store the value of a viewer element once at the beginning
@@ -62,13 +63,13 @@ class MyModel(Model):
You can write to a viewer element in Python, which provides a convenient way to track values in your code without the need for wandb/tensorboard or relying on `print` statements.
```python
self.custom_value.value = x
self.custom_value = x
```
:::{admonition} Warning
:class: warning
Updating module state while training can have unexpected side effects. It is up to the user to ensure that GUI actions are safe. Conditioning on `self.training` can help determine whether effects are applied during forward passes for training or rendering.
Note that updating module state while training can have unexpected side effects. It is up to the user to ensure that GUI actions are safe. In most cases, we recommend wrapping GUI related logic in `if self.training:` to ensure that the effects are only applied during inference.
:::
## Example Elements