Skip to content

Commit 4fc3f59

Browse files
authored
Release/v1.0 (MultimediaTechLab#225)
* [Fix] typo of quiet (from quite) * πŸ› [Add] Gradient acc for stable single gpu * πŸ› [Fix] for setting multigpu, enable pick cuda id * πŸ’š [Fix] bug for pytest for inference * πŸ“ [Update] Docs, remove broken badge
1 parent a730d1c commit 4fc3f59

File tree

11 files changed

+69
-20
lines changed

11 files changed

+69
-20
lines changed

β€Ž.github/workflows/deploy.yamlβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ jobs:
6161
run: |
6262
python yolo/lazy.py task=inference use_wandb=False
6363
python yolo/lazy.py task=inference use_wandb=False model=v7
64-
python yolo/lazy.py task=inference use_wandb=False +quite=True
64+
python yolo/lazy.py task=inference use_wandb=False +quiet=True
6565
python yolo/lazy.py task=inference use_wandb=False name=AnyNameYouWant
6666
python yolo/lazy.py task=inference use_wandb=False image_size=\[480,640]
6767
python yolo/lazy.py task=inference use_wandb=False task.nms.min_confidence=0.1

β€ŽREADME.mdβ€Ž

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,10 @@
22

33
[![Documentation Status](https://readthedocs.org/projects/yolo-docs/badge/?version=latest)](https://yolo-docs.readthedocs.io/en/latest/?badge=latest)
44
![GitHub License](https://img.shields.io/github/license/WongKinYiu/YOLO)
5-
![WIP](https://img.shields.io/badge/status-WIP-orange)
65

76
[![Developer Mode Build & Test](https://github.com/WongKinYiu/YOLO/actions/workflows/develop.yaml/badge.svg)](https://github.com/WongKinYiu/YOLO/actions/workflows/develop.yaml)
87
[![Deploy Mode Validation & Inference](https://github.com/WongKinYiu/YOLO/actions/workflows/deploy.yaml/badge.svg)](https://github.com/WongKinYiu/YOLO/actions/workflows/deploy.yaml)
98

10-
[![PWC](https://img.shields.io/endpoint.svg?url=https://paperswithcode.com/badge/yolov9-learning-what-you-want-to-learn-using/real-time-object-detection-on-coco)](https://paperswithcode.com/sota/real-time-object-detection-on-coco)
119

1210
[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)]()
1311
[![Hugging Face Spaces](https://img.shields.io/badge/%F0%9F%A4%97%20Hugging%20Face-Spaces-green)](https://huggingface.co/spaces/henry000/YOLO)
@@ -87,7 +85,7 @@ python yolo/lazy.py task=inference \ # default is inference
8785
task.nms.min_confidence=0.1 \ # nms config
8886
task.fast_inference=onnx \ # onnx, trt, deploy
8987
task.data.source=data/toy/images/train \ # file, dir, webcam
90-
+quite=True \ # Quite Output
88+
+quiet=True \ # Quiet Output
9189
yolo task.data.source={Any Source} # if pip installed
9290
yolo task=inference task.data.source={Any}
9391
```

β€Ždocs/HOWTO.mdβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ python yolo/lazy.py task=validation dataset=toy name=validation
1717
# Inference
1818
python yolo/lazy.py task=inference
1919
python yolo/lazy.py task=inference device=cpu
20-
python yolo/lazy.py task=inference +quite=True
20+
python yolo/lazy.py task=inference +quiet=True
2121
python yolo/lazy.py task=inference name=AnyNameYouWant
2222
python yolo/lazy.py task=inference image_size=\[480,640]
2323
python yolo/lazy.py task=inference task.nms.min_confidence=0.1

β€Žtests/conftest.pyβ€Ž

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ def model_v7(inference_v7_cfg: Config, device) -> YOLO:
6868
@pytest.fixture(scope="session")
6969
def solver(train_cfg: Config) -> Trainer:
7070
train_cfg.use_wandb = False
71+
del train_cfg.task.data.equivalent_batch_size
7172
callbacks, loggers, save_path = setup(train_cfg)
7273
trainer = Trainer(
7374
accelerator="auto",

β€Žtests/test_utils/test_bounding_box_utils.pyβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ def test_vec2box_autoanchor():
118118
with initialize(config_path="../../yolo/config", version_base=None):
119119
cfg: Config = compose(config_name="config", overrides=["model=v9-m"])
120120
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
121-
model = create_model(cfg.model, weight_path=None).to(device)
121+
model = create_model(cfg.model, weight_path=None)
122122
vec2box = Vec2Box(model, cfg.model.anchor, cfg.image_size, device)
123123
assert vec2box.strides == [8, 16, 32]
124124

β€Žyolo/config/config.pyβ€Ž

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ class DataConfig:
6060
data_augment: Dict[str, int]
6161
source: Optional[Union[str, int]]
6262
dynamic_shape: Optional[bool]
63+
equivalent_batch_size: Optional[int] = 64
6364

6465

6566
@dataclass
@@ -144,6 +145,7 @@ class Config:
144145
model: ModelConfig
145146
name: str
146147

148+
accelerator: Optional[str]
147149
device: Union[str, int, List[int]]
148150
cpu_num: int
149151

β€Žyolo/config/general.yamlβ€Ž

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
device: 0
1+
accelerator: auto
2+
device: auto
23
cpu_num: 16
34

45
image_size: [640, 640]

β€Žyolo/config/task/train.yamlβ€Ž

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ epoch: 500
77

88
data:
99
batch_size: 16
10+
equivalent_batch_size: 64
1011
image_size: ${image_size}
1112
cpu_num: ${cpu_num}
1213
shuffle: True

β€Žyolo/lazy.pyβ€Ž

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,18 @@ def main(cfg: Config):
1717
callbacks, loggers, save_path = setup(cfg)
1818

1919
trainer = Trainer(
20-
accelerator="auto",
20+
accelerator=getattr(cfg, "accelerator", "auto"),
21+
devices=cfg.device,
2122
max_epochs=getattr(cfg.task, "epoch", None),
2223
precision="16-mixed",
2324
callbacks=callbacks,
25+
sync_batchnorm=True,
2426
logger=loggers,
2527
log_every_n_steps=1,
2628
gradient_clip_val=10,
2729
gradient_clip_algorithm="norm",
2830
deterministic=True,
29-
enable_progress_bar=not getattr(cfg, "quite", False),
31+
enable_progress_bar=not getattr(cfg, "quiet", False),
3032
default_root_dir=save_path,
3133
)
3234

β€Žyolo/utils/logging_utils.pyβ€Ž

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
from yolo.config.config import Config, YOLOLayer
3939
from yolo.model.yolo import YOLO
4040
from yolo.utils.logger import logger
41-
from yolo.utils.model_utils import EMA
41+
from yolo.utils.model_utils import EMA, GradientAccumulation
4242
from yolo.utils.solver_utils import make_ap_table
4343

4444

@@ -68,7 +68,6 @@ def _init_progress(self, trainer: "Trainer") -> None:
6868
self._reset_progress_bar_ids()
6969
reconfigure(**self._console_kwargs)
7070
self._console = Console()
71-
self._console.clear_live()
7271
self.progress = YOLOCustomProgress(
7372
*self.configure_columns(trainer),
7473
auto_refresh=False,
@@ -105,7 +104,7 @@ def on_train_batch_end(self, trainer, pl_module, outputs, batch: Any, batch_idx:
105104
self._update(self.train_progress_bar_id, batch_idx + 1)
106105
self._update_metrics(trainer, pl_module)
107106
epoch_descript = "[cyan]Train [white]|"
108-
batch_descript = "[green]Train [white]|"
107+
batch_descript = "[green]Batch [white]|"
109108
metrics = self.get_metrics(trainer, pl_module)
110109
metrics.pop("v_num")
111110
for metrics_name, metrics_val in metrics.items():
@@ -238,7 +237,7 @@ def on_validation_batch_end(self, trainer: Trainer, pl_module, outputs, batch, b
238237
logger.log_image("Prediction", images, step=step, boxes=[log_bbox(pred_boxes)])
239238

240239

241-
def setup_logger(logger_name, quite=False):
240+
def setup_logger(logger_name, quiet=False):
242241
class EmojiFormatter(logging.Formatter):
243242
def format(self, record, emoji=":high_voltage:"):
244243
return f"{emoji} {super().format(record)}"
@@ -249,17 +248,17 @@ def format(self, record, emoji=":high_voltage:"):
249248
if rich_logger:
250249
rich_logger.handlers.clear()
251250
rich_logger.addHandler(rich_handler)
252-
if quite:
251+
if quiet:
253252
rich_logger.setLevel(logging.ERROR)
254253

255254
coco_logger = logging.getLogger("faster_coco_eval.core.cocoeval")
256255
coco_logger.setLevel(logging.ERROR)
257256

258257

259258
def setup(cfg: Config):
260-
quite = hasattr(cfg, "quite")
261-
setup_logger("lightning.fabric", quite=quite)
262-
setup_logger("lightning.pytorch", quite=quite)
259+
quiet = hasattr(cfg, "quiet")
260+
setup_logger("lightning.fabric", quiet=quiet)
261+
setup_logger("lightning.pytorch", quiet=quiet)
263262

264263
def custom_wandb_log(string="", level=int, newline=True, repeat=True, prefix=True, silent=False):
265264
if silent:
@@ -273,9 +272,12 @@ def custom_wandb_log(string="", level=int, newline=True, repeat=True, prefix=Tru
273272

274273
progress, loggers = [], []
275274

275+
if cfg.task.task == "train" and hasattr(cfg.task.data, "equivalent_batch_size"):
276+
progress.append(GradientAccumulation(data_cfg=cfg.task.data, scheduler_cfg=cfg.task.scheduler))
277+
276278
if hasattr(cfg.task, "ema") and cfg.task.ema.enable:
277279
progress.append(EMA(cfg.task.ema.decay))
278-
if quite:
280+
if quiet:
279281
logger.setLevel(logging.ERROR)
280282
return progress, loggers, save_path
281283

@@ -336,7 +338,7 @@ def validate_log_directory(cfg: Config, exp_name: str) -> Path:
336338
)
337339

338340
save_path.mkdir(parents=True, exist_ok=True)
339-
if not getattr(cfg, "quite", False):
341+
if not getattr(cfg, "quiet", False):
340342
logger.info(f"πŸ“„ Created log folder: [blue b u]{save_path}[/]")
341343
logger.addHandler(FileHandler(save_path / "output.log"))
342344
return save_path

0 commit comments

Comments
Β (0)