[BUG] `draw_labels` method cannot parse unicode characters
rusmux opened this issue · 2 comments
rusmux commented
Describe the problem
When using the draw_labels
method to draw dataset labels, unicode symbols are parsed as ?
.
Code to reproduce issue
import cv2
import fiftyone as fo
import numpy as np
cv2.imwrite("sample.png", np.full((1024, 1024, 3), 255))
sample = fo.Sample(
filepath="sample.png",
detections=fo.Detections(detections=[fo.Detection(label="Объект", bounding_box=[0.4, 0.4, 0.2, 0.2])]),
)
dataset = fo.Dataset()
dataset.add_sample(sample)
dataset.draw_labels("sample")
System information
- OS Platform and Distribution (e.g., Linux Ubuntu 22.04): macOS Sonoma
- Python version (
python --version
): 3.10.12 - FiftyOne version (
fiftyone --version
): FiftyOne v0.22.3, Voxel51, Inc. - FiftyOne installed from (pip or source): pip
Other info/logs
Willingness to contribute
- Yes. I can contribute a fix for this bug independently
- Yes. I would be willing to contribute a fix for this bug with guidance
from the FiftyOne community - No. I cannot contribute a bug fix at this time
brimoor commented
Hi @rusmux 👋
The issue is that the default font used is lato-regular.
You can manually specify a different font like this (works for me):
import cv2
import fiftyone as fo
import numpy as np
cv2.imwrite("/tmp/sample.png", np.full((1024, 1024, 3), 255))
sample = fo.Sample(
filepath="/tmp/sample.png",
detections=fo.Detections(detections=[fo.Detection(label="Объект", bounding_box=[0.4, 0.4, 0.2, 0.2])]),
)
dataset = fo.Dataset()
dataset.add_sample(sample)
dataset.draw_labels("/tmp/sample", font_path="Arial.ttf")
brimoor commented
update: you can just:
pip install --upgrade voxel51-eta
and then this will directly work without manually specifying a new font:
dataset.draw_labels("/tmp/sample")