์ฝ๋ฐฑ
์ฝ๋ฐฑ
Ultralytics ํ๋ ์์ํฌ๋ ํธ๋ ์ธ, ๋ฐธ, ๋ด๋ณด๋ด๊ธฐ, ์์ธก ๋ชจ๋์ ์ ๋ต์ ๋จ๊ณ์์ ์ฝ๋ฐฑ์ ์ง์
์ ์ผ๋ก ์ง์ํฉ๋๋ค. ๊ฐ ์ฝ๋ฐฑ์ Trainer
, Validator
๋๋ Predictor
๊ฐ์ฒด๋ฅผ ์ฌ์ฉํ ์ ์์ต๋๋ค. ์ด๋ฌํ ๊ฐ์ฒด์ ๋ชจ๋ ์์ฑ์ ๋ฌธ์์ ์ฐธ์กฐ ์น์
์์ ์ฐพ์ ์ ์์ต๋๋ค.
Watch: ๋ง์คํฐ๋ง Ultralytics YOLOv8 : ์ฝ๋ฐฑ
์์
์์ธก์ผ๋ก ์ถ๊ฐ ์ ๋ณด ๋ฐํ
์ด ์์ ์์๋ ๊ฐ ๊ฒฐ๊ณผ ๊ฐ์ฒด์ ํจ๊ป ์๋ณธ ํ๋ ์์ ๋ฐํํ๋ ค๊ณ ํฉ๋๋ค. ์ด๋ฅผ ์ํํ๋ ๋ฐฉ๋ฒ์ ๋ค์๊ณผ ๊ฐ์ต๋๋ค.
from ultralytics import YOLO
def on_predict_batch_end(predictor):
"""Handle prediction batch end by combining results with corresponding frames; modifies predictor results."""
_, image, _, _ = predictor.batch
# Ensure that image is a list
image = image if isinstance(image, list) else [image]
# Combine the prediction results with the corresponding frames
predictor.results = zip(predictor.results, image)
# Create a YOLO model instance
model = YOLO(f'yolov8n.pt')
# Add the custom callback to the model
model.add_callback("on_predict_batch_end", on_predict_batch_end)
# Iterate through the results and frames
for (result, frame) in model.predict(): # or model.track()
pass
๋ชจ๋ ์ฝ๋ฐฑ
์ง์๋๋ ๋ชจ๋ ์ฝ๋ฐฑ์ ๋ค์๊ณผ ๊ฐ์ต๋๋ค. ์์ธํ ๋ด์ฉ์ ์ฝ๋ฐฑ ์์ค ์ฝ๋๋ฅผ ์ฐธ์กฐํ์ธ์.
ํธ๋ ์ด๋ ์ฝ๋ฐฑ
์ฝ๋ฐฑ | ์ค๋ช |
---|---|
on_pretrain_routine_start |
์ฌ์ ํ๋ จ ๋ฃจํด์ด ์์๋ ๋ ํธ๋ฆฌ๊ฑฐ๋ฉ๋๋ค. |
on_pretrain_routine_end |
์ฌ์ ํ๋ จ ๋ฃจํด์ด ๋๋๋ฉด ํธ๋ฆฌ๊ฑฐ๋ฉ๋๋ค. |
on_train_start |
ํธ๋ ์ด๋ ์์ ์ ํธ๋ฆฌ๊ฑฐ๋จ |
on_train_epoch_start |
๊ฐ ํ๋ จ ์ํฌํฌ๊ฐ ์์๋ ๋ ํธ๋ฆฌ๊ฑฐ๋ฉ๋๋ค. |
on_train_batch_start |
๊ฐ ๊ต์ก ๋ฐฐ์น๊ฐ ์์๋ ๋ ํธ๋ฆฌ๊ฑฐ๋ฉ๋๋ค. |
optimizer_step |
์ตํฐ๋ง์ด์ ๋จ๊ณ์์ ํธ๋ฆฌ๊ฑฐ๋จ |
on_before_zero_grad |
๊ทธ๋ผ๋ฐ์ด์ ์ด 0์ด ๋๊ธฐ ์ ์ ํธ๋ฆฌ๊ฑฐ๋ฉ๋๋ค. |
on_train_batch_end |
๊ฐ ๊ต์ก ๋ฐฐ์น๊ฐ ๋๋ ๋๋ง๋ค ํธ๋ฆฌ๊ฑฐ๋ฉ๋๋ค. |
on_train_epoch_end |
๊ฐ ํ๋ จ ์ํฌํฌ๊ฐ ๋๋ ๋๋ง๋ค ํธ๋ฆฌ๊ฑฐ๋ฉ๋๋ค. |
on_fit_epoch_end |
๊ฐ ํ ์ํฌํฌ๊ฐ ๋๋ ๋๋ง๋ค ํธ๋ฆฌ๊ฑฐ๋ฉ๋๋ค. |
on_model_save |
๋ชจ๋ธ์ด ์ ์ฅ๋ ๋ ํธ๋ฆฌ๊ฑฐ๋ฉ๋๋ค. |
on_train_end |
๊ต์ก ํ๋ก์ธ์ค๊ฐ ์ข ๋ฃ๋๋ฉด ํธ๋ฆฌ๊ฑฐ๋ฉ๋๋ค. |
on_params_update |
๋ชจ๋ธ ํ๋ผ๋ฏธํฐ๊ฐ ์ ๋ฐ์ดํธ๋ ๋ ํธ๋ฆฌ๊ฑฐ๋ฉ๋๋ค. |
teardown |
๊ต์ก ํ๋ก์ธ์ค๊ฐ ์ ๋ฆฌ ์ค์ผ ๋ ํธ๋ฆฌ๊ฑฐ๋ฉ๋๋ค. |
์ ํจ์ฑ ๊ฒ์ฌ๊ธฐ ์ฝ๋ฐฑ
์ฝ๋ฐฑ | ์ค๋ช |
---|---|
on_val_start |
์ ํจ์ฑ ๊ฒ์ฌ๊ฐ ์์๋ ๋ ํธ๋ฆฌ๊ฑฐ๋ฉ๋๋ค. |
on_val_batch_start |
๊ฐ ์ ํจ์ฑ ๊ฒ์ฌ ๋ฐฐ์น๊ฐ ์์๋ ๋ ํธ๋ฆฌ๊ฑฐ๋ฉ๋๋ค. |
on_val_batch_end |
๊ฐ ์ ํจ์ฑ ๊ฒ์ฌ ๋ฐฐ์น๊ฐ ๋๋ ๋ ํธ๋ฆฌ๊ฑฐ๋ฉ๋๋ค. |
on_val_end |
์ ํจ์ฑ ๊ฒ์ฌ๊ฐ ์ข ๋ฃ๋๋ฉด ํธ๋ฆฌ๊ฑฐ๋ฉ๋๋ค. |
์์ธก์ ์ฝ๋ฐฑ
์ฝ๋ฐฑ | ์ค๋ช |
---|---|
on_predict_start |
์์ธก ํ๋ก์ธ์ค๊ฐ ์์๋ ๋ ํธ๋ฆฌ๊ฑฐ๋ฉ๋๋ค. |
on_predict_batch_start |
๊ฐ ์์ธก ๋ฐฐ์น๊ฐ ์์๋ ๋ ํธ๋ฆฌ๊ฑฐ๋ฉ๋๋ค. |
on_predict_postprocess_end |
์์ธก ํ์ฒ๋ฆฌ ์ข ๋ฃ ์ ํธ๋ฆฌ๊ฑฐ๋จ |
on_predict_batch_end |
๊ฐ ์์ธก ๋ฐฐ์น๊ฐ ๋๋ ๋ ํธ๋ฆฌ๊ฑฐ๋ฉ๋๋ค. |
on_predict_end |
์์ธก ํ๋ก์ธ์ค๊ฐ ์ข ๋ฃ๋๋ฉด ํธ๋ฆฌ๊ฑฐ๋ฉ๋๋ค. |
๋ด๋ณด๋ด๊ธฐ ์ฝ๋ฐฑ
์ฝ๋ฐฑ | ์ค๋ช |
---|---|
on_export_start |
๋ด๋ณด๋ด๊ธฐ ํ๋ก์ธ์ค๊ฐ ์์๋ ๋ ํธ๋ฆฌ๊ฑฐ๋ฉ๋๋ค. |
on_export_end |
๋ด๋ณด๋ด๊ธฐ ํ๋ก์ธ์ค๊ฐ ์ข ๋ฃ๋๋ฉด ํธ๋ฆฌ๊ฑฐ๋ฉ๋๋ค. |
์์ฑ 2023-11-12, ์ ๋ฐ์ดํธ 2024-05-03
์์ฑ์: glenn-jocher (4), RizwanMunawar (1), Laughing-q (1)