commit d86ef2dbf44e87705f4a3a57ccf5e7ca456c0567 Author: Daekeun Date: Mon Jun 29 14:40:03 2026 +0900 first commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ef6c1a9 --- /dev/null +++ b/.gitignore @@ -0,0 +1,65 @@ +# Python +__pycache__/ +*.py[cod] +*$py.class +*.so +.Python +*.egg-info/ +.eggs/ +dist/ +build/ +*.egg +.venv/ +venv/ +env/ + +# IDE +.vscode/ +.idea/ +*.swp +*.swo + +# OS +.DS_Store +Thumbs.db +desktop.ini + +# Model weights & exports +# weights/ +# *.pt +# *.pth +# *.onnx +# *.engine +# *.weights + +# Images (inference input/output) +*_marked.jpg +*_marked.jpeg +*_marked.png +image.jpg +*.jpg +*.jpeg +*.png +*.bmp +*.webp +!image1.jpg +!image2.jpg +!image3.jpg + +# Ultralytics outputs +runs/ +output/ +outputs/ +results/ + +# ClearML +clearml.conf +*.log + +# Jupyter +.ipynb_checkpoints/ + +# Environment & secrets +.env +.env.* +*.pem diff --git a/image1.jpg b/image1.jpg new file mode 100644 index 0000000..d95348f Binary files /dev/null and b/image1.jpg differ diff --git a/image2.jpg b/image2.jpg new file mode 100644 index 0000000..920bb71 Binary files /dev/null and b/image2.jpg differ diff --git a/image3.jpg b/image3.jpg new file mode 100644 index 0000000..2254e82 Binary files /dev/null and b/image3.jpg differ diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..85e901c --- /dev/null +++ b/requirements.txt @@ -0,0 +1,2 @@ +ultralytics==8.4.71 +requests==2.32.5 diff --git a/start.py b/start.py new file mode 100644 index 0000000..c3e77fa --- /dev/null +++ b/start.py @@ -0,0 +1,71 @@ +import json +import math +from pathlib import Path +from ultralytics import YOLO +import requests +import argparse + +from clearml import Task # 1. ClearML 임포트 + +# 방법 A) 가장 최신 트렌드인 NMS-Free 임베디드 특화 모델 로드 +model = YOLO("./weights/yolo26m.pt") # Medium 크기 가중치 자동 다운로드 + +task = Task.init( + project_name="Normal_Object_Detection", + task_name="YOLOv26m_coc80_Inference_Agent" +) + +def xyxy_to_xywh(box: dict) -> dict: + x1 = math.floor(box["x1"]) + y1 = math.floor(box["y1"]) + x2 = math.ceil(box["x2"]) + y2 = math.ceil(box["y2"]) + return {"x": x1, "y": y1, "w": x2 - x1, "h": y2 - y1} + + +# 방법 B) 복잡한 구도나 정밀 식별에 강한 어텐션 기반 모델 로드 +# model = YOLO("yolo12m.pt") + +def main(image_path: str): + # 이미지 원격 추론 테스트 (COCO 80종 기본 탐지 가능) + # results = model("https://acai.ketidev.kr:20443/detect/image/202606/20260619_145116_image.jpg") + results = model(image_path) + + result = results[0] + + image_path = Path(result.path) + marked_path = image_path.with_name(f"{image_path.stem}_marked{image_path.suffix}") + result.save(filename=str(marked_path)) + + detections = [] + for det in result.summary(): + detections.append({**det, "box": xyxy_to_xywh(det["box"])}) + + output = { + "path": result.path, + "marked_path": str(marked_path), + "shape": {"height": result.orig_shape[0], "width": result.orig_shape[1]}, + "speed_ms": result.speed, + "detections": detections, + } + print(json.dumps(output, indent=2, ensure_ascii=False)) + +if __name__ == "__main__": + parser = argparse.ArgumentParser() + parser.add_argument("--image_url", type=str) + args = parser.parse_args() + + image_url = args.image_url + + if image_url is None: + print("Image path is required") + exit(1) + + response = requests.get(image_url) + response.raise_for_status() + image_data = response.content + with open("image.jpg", "wb") as f: + f.write(image_data) + image_path = "image.jpg" + + main(image_path) \ No newline at end of file diff --git a/weights/yolo26m.pt b/weights/yolo26m.pt new file mode 100644 index 0000000..7f71e5a Binary files /dev/null and b/weights/yolo26m.pt differ