Skip to content

Commit

Permalink
use PathManager and PIL to load sem_seg_file
Browse files Browse the repository at this point in the history
Reviewed By: ppwwyyxx

Differential Revision: D21090513

fbshipit-source-id: 41ddc682deaa5966372fbe0746a13310e5dc1e53
  • Loading branch information
wat3rBro authored and facebook-github-bot committed Apr 17, 2020
1 parent 83c96d9 commit e6b95f3
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion detectron2/utils/visualizer.py
Expand Up @@ -10,7 +10,9 @@
import matplotlib.figure as mplfigure
import pycocotools.mask as mask_util
import torch
from fvcore.common.file_io import PathManager
from matplotlib.backends.backend_agg import FigureCanvasAgg
from PIL import Image

from detectron2.structures import BitMasks, Boxes, BoxMode, Keypoints, PolygonMasks, RotatedBoxes

Expand Down Expand Up @@ -508,7 +510,9 @@ def draw_dataset_dict(self, dic):

sem_seg = dic.get("sem_seg", None)
if sem_seg is None and "sem_seg_file_name" in dic:
sem_seg = cv2.imread(dic["sem_seg_file_name"], cv2.IMREAD_GRAYSCALE)
with PathManager.open(dic["sem_seg_file_name"], "rb") as f:
sem_seg = Image.open(f)
sem_seg = np.asarray(sem_seg, dtype="uint8")
if sem_seg is not None:
self.draw_sem_seg(sem_seg, area_threshold=0, alpha=0.5)
return self.output
Expand Down

0 comments on commit e6b95f3

Please sign in to comment.