Skip to content

Commit 2736c1c

Browse files
committed
minor debug tweaks
1 parent a7929d0 commit 2736c1c

4 files changed

Lines changed: 17 additions & 7 deletions

File tree

train_kwcoco_demo.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ TRAIN_DPATH="$BUNDLE_DPATH/kwcoco-demo-train-dir"
8585
# This might only work in development mode, otherwise we will get site packages
8686
# That still might be fine, but we do want to fix this to run anywhere.
8787
cd "$REPO_DPATH"
88+
export CUDA_VISIBLE_DEVICES="1,"
8889
LOG_BATCH_VIZ_TO_DISK=1 python -m yolo.lazy \
8990
task=train \
9091
dataset=kwcoco-demo \

yolo/model/yolo.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,11 +233,13 @@ def create_model(model_cfg: ModelConfig, weight_path: Union[bool, Path] = True,
233233
Returns:
234234
YOLO: An instance of the model defined by the given configuration.
235235
"""
236+
logger.info = print
237+
logger.info('CREATE MODEL')
236238
OmegaConf.set_struct(model_cfg, False)
237239
model = YOLO(model_cfg, class_num)
238240
if weight_path:
239241
logger.info('🏋 Initializing weights')
240-
if weight_path == True:
242+
if weight_path is True:
241243
weight_path = Path("weights") / f"{model_cfg.name}.pt"
242244
elif isinstance(weight_path, str):
243245
weight_path = Path(weight_path)
@@ -251,4 +253,5 @@ def create_model(model_cfg: ModelConfig, weight_path: Union[bool, Path] = True,
251253
logger.info(":white_check_mark: Success load model & weight")
252254
else:
253255
logger.info(":white_check_mark: Success load model without weights")
256+
logger.info('CREATED MODEL')
254257
return model

yolo/tools/data_loader.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def load_data(self, dataset_path: Path, phase_name: str):
5151
Returns:
5252
dict: The loaded data from the cache for the specified phase.
5353
"""
54-
cache_path = dataset_path / f"{phase_name}.cache"
54+
cache_path = dataset_path / f"{phase_name}-v1.cache"
5555

5656
if not cache_path.exists():
5757
logger.info(f":factory: Generating {phase_name} cache")
@@ -232,6 +232,7 @@ def get_data(self, idx):
232232
img_path, bboxes = self.img_paths[idx], self.bboxes[idx]
233233
valid_mask = bboxes[:, 0] != -1
234234

235+
# TODO: we can load an overview here to make this much more efficent
235236
USE_OVERVIEW_HACK = 0
236237
if USE_OVERVIEW_HACK:
237238
# Can leverage overviews to load images faster if they exist.
@@ -252,8 +253,9 @@ def get_data(self, idx):
252253
with Image.open(img_path) as img:
253254
img = img.convert("RGB")
254255

255-
# TODO: we can load an overview here to make this much more efficent
256-
return img, torch.from_numpy(bboxes[valid_mask]), img_path
256+
valid_boxes = bboxes[valid_mask]
257+
valid_boxes = torch.from_numpy(valid_boxes)
258+
return img, valid_boxes, img_path
257259

258260
def get_more_data(self, num: int = 1):
259261
indices = torch.randint(0, len(self), (num,))

yolo/utils/logging_utils.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,9 @@ def on_validation_batch_end(self, trainer: Trainer, pl_module, outputs, batch, b
253253
true_dets = tensor_to_kwimage(gt_boxes).numpy()
254254
pred_dets = tensor_to_kwimage(pred_boxes).numpy()
255255
pred_dets = pred_dets.non_max_supress(thresh=0.3)
256-
# pred_dets = pred_dets.compress(pred_dets.scores > 0.1)
256+
pred_dets_2 = pred_dets.compress(pred_dets.scores > 0.01)
257+
if len(pred_dets_2) > 0:
258+
pred_dets = pred_dets_2
257259

258260
raw_canvas = image_hwc.copy()
259261
true_canvas = true_dets.draw_on(raw_canvas.copy(), color='green')
@@ -266,7 +268,7 @@ def on_validation_batch_end(self, trainer: Trainer, pl_module, outputs, batch, b
266268
raw_canvas, true_canvas, pred_canvas
267269
], axis=1, pad=3)
268270

269-
fname = f'img_{epoch:04d}_{batch_idx:04d}.jpg'
271+
fname = f'img_{epoch:04d}_{bx:04d}.jpg'
270272
fpath = out_dpath / fname
271273
kwimage.imwrite(fpath, canvas)
272274

@@ -357,7 +359,9 @@ def custom_wandb_log(string="", level=int, newline=True, repeat=True, prefix=Tru
357359

358360
print(f'cfg.use_tensorboard={cfg.use_tensorboard}')
359361
if cfg.use_tensorboard:
360-
loggers.append(TensorBoardLogger(log_graph="all", save_dir=save_path))
362+
print(f'save_path={save_path}')
363+
# loggers.append(TensorBoardLogger(log_graph="all", save_dir=save_path))
364+
loggers.append(TensorBoardLogger(save_path))
361365
from yolo.utils.callbacks.tensorboard_plotter import TensorboardPlotter
362366
callbacks.append(TensorboardPlotter())
363367
if cfg.use_wandb:

0 commit comments

Comments
 (0)