Spaces:
Runtime error
Runtime error
File size: 630 Bytes
3094730 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# Copyright (c) OpenMMLab. All rights reserved.
from mmengine.hooks import Hook
from mmengine.runner import Runner
from mmyolo.registry import HOOKS
from mmyolo.utils import switch_to_deploy
@HOOKS.register_module()
class SwitchToDeployHook(Hook):
"""Switch to deploy mode before testing.
This hook converts the multi-channel structure of the training network
(high performance) to the one-way structure of the testing network (fast
speed and memory saving).
"""
def before_test_epoch(self, runner: Runner):
"""Switch to deploy mode before testing."""
switch_to_deploy(runner.model)
|