Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bugfix] integer class name caused tensorboard writer crash #26

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion det-yolov4-training/src/detector.c
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ void train_detector(char *datacfg, char *cfgfile, char *weightfile, int *gpus, i
if (names_size > 0) {
fprintf(file_ptr, "aps:\n");
for (int idx = 0; idx < names_size; ++idx) {
fprintf(file_ptr, " %s: %f\n", names[idx], aps[idx]);
fprintf(file_ptr, " \'%s\': %f\n", names[idx], aps[idx]);
}
}
fclose(file_ptr);
Expand Down
5 changes: 3 additions & 2 deletions det-yolov4-training/train_watcher.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import logging
import os
import re
from typing import Callable, Tuple
from typing import Callable, List, Tuple

from tensorboardX import SummaryWriter
import yaml
Expand All @@ -21,7 +21,7 @@ def __init__(self, width: int, height: int, class_num: int) -> None:
self._class_numbers = class_num
self._tensorboard_writer = SummaryWriter(log_dir='/out/tensorboard')

self._pattern_and_handlers: Tuple[str, Callable] = [
self._pattern_and_handlers: List[Tuple[str, Callable]] = [
('^.*best.weights$', _DarknetTrainingHandler._on_best_weights_modified),
('^.*train-log.yaml$', _DarknetTrainingHandler._on_train_log_yaml_modified)
]
Expand Down Expand Up @@ -75,6 +75,7 @@ def _on_train_log_yaml_modified(self, src_path: str) -> None:
if isinstance(mean_ap, float):
self._tensorboard_writer.add_scalar(tag="train/mAP", scalar_value=mean_ap, global_step=iteration)
if class_aps and isinstance(class_aps, dict):
class_aps = {str(k): v for k, v in class_aps.items()}
self._tensorboard_writer.add_scalars(main_tag='train/aps', tag_scalar_dict=class_aps, global_step=iteration)
self._tensorboard_writer.flush()

Expand Down