first commit

This commit is contained in:
2026-06-29 14:40:03 +09:00
commit d86ef2dbf4
7 changed files with 138 additions and 0 deletions
+65
View File
@@ -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
BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 96 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 128 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 41 KiB

+2
View File
@@ -0,0 +1,2 @@
ultralytics==8.4.71
requests==2.32.5
+71
View File
@@ -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)
Binary file not shown.