henry000 commited on
Commit
47093ac
·
1 Parent(s): 9c191b9

🦺 [Fix] draw image bbox bugs, make it robust

Browse files
yolo/tools/drawer.py CHANGED
@@ -32,7 +32,10 @@ def draw_bboxes(
32
  img = img[0]
33
  img = to_pil_image(img)
34
 
35
- img, bboxes = img.copy(), bboxes[0]
 
 
 
36
  label_size = img.size[1] / 30
37
  draw = ImageDraw.Draw(img, "RGBA")
38
 
@@ -43,6 +46,8 @@ def draw_bboxes(
43
 
44
  for bbox in bboxes:
45
  class_id, x_min, y_min, x_max, y_max, *conf = [float(val) for val in bbox]
 
 
46
  bbox = [(x_min, y_min), (x_max, y_max)]
47
 
48
  random.seed(int(class_id))
 
32
  img = img[0]
33
  img = to_pil_image(img)
34
 
35
+ if bboxes.ndim == 3:
36
+ bboxes = bboxes[0]
37
+
38
+ img = img.copy()
39
  label_size = img.size[1] / 30
40
  draw = ImageDraw.Draw(img, "RGBA")
41
 
 
46
 
47
  for bbox in bboxes:
48
  class_id, x_min, y_min, x_max, y_max, *conf = [float(val) for val in bbox]
49
+ x_min, x_max = min(x_min, x_max), max(x_min, x_max)
50
+ y_min, y_max = min(y_min, y_max), max(y_min, y_max)
51
  bbox = [(x_min, y_min), (x_max, y_max)]
52
 
53
  random.seed(int(class_id))
yolo/utils/logging_utils.py CHANGED
@@ -100,6 +100,7 @@ class ProgressLogger(Progress):
100
  from torch.utils.tensorboard import SummaryWriter
101
 
102
  self.tb_writer = SummaryWriter(log_dir=self.save_path / "tensorboard")
 
103
 
104
  def get_renderable(self):
105
  renderable = Group(*self.get_renderables(), self.ap_table)
 
100
  from torch.utils.tensorboard import SummaryWriter
101
 
102
  self.tb_writer = SummaryWriter(log_dir=self.save_path / "tensorboard")
103
+ logger.opt(colors=True).info(f"📍 Enable TensorBoard locally at <blue><u>http://localhost:6006</></>")
104
 
105
  def get_renderable(self):
106
  renderable = Group(*self.get_renderables(), self.ap_table)