Open FirokOtaku opened 1 year ago
Try try this:
from mmdet.visualization.local_visualizer import DetLocalVisualizer as BaseVisualizer
from mmdet.visualization.local_visualizer import VISUALIZERS
@VISUALIZERS.register_module(name='DetLocalVisualizer', force=True)
class DetLocalVisualizer(BaseVisualizer):
def __init__(
self,
name='visualizer',
*args,
font_families='SimHei',
**kwargs,
):
super().__init__(name=name, *args, **kwargs)
self.font_families = font_families
def draw_texts(self, *args, **kwargs):
kwargs['font_families'] = self.font_families
return super().draw_texts(*args, **kwargs)
Before:
After:
@ypwhs you truly made my day!
(feature request)
Describe the feature
Add a property or setter method to allow user adjust
font_families
used by Visualizer.Motivation
As this issue mentioned, an inference result has Chinese category names (or any other characters which are not included in default font
sans-serif
), could not be rendered properly.Related resources
Modifying underlying code of Visualizer is a temporary solution, but not a good one.
Additional context