Cursor Madrid
Hackathon 3
LibreYOLO 트랙


해커를 환영합니다. LibreYOLO가 무엇인지 알아보고 설정 튜토리얼을 따른 다음 예제를 복사하여 개발을 시작하십시오.
LibreYOLO 소개
LibreYOLO는 최첨단 객체 탐지를 학습하고 배포하기 위한 현대적인 100% MIT 라이선스 엔진입니다. 제작자가 처음 의도한 대로 누구나 YOLO를 다시 이용할 수 있게 하려고 만들어졌습니다.

설정 튜토리얼
아래 프롬프트를 Cursor에 붙여 넣으십시오. 에이전트가 소스에서 LibreYOLO를 설치하고 설치를 검증하는 과정을 안내합니다. Windows, macOS, Linux에서 작동합니다.
# Install LibreYOLO (Cursor Hackathon, LibreYOLO Track)
#
# Your job: get LibreYOLO installed from source on the user's machine and
# verify it imports. The user is on Windows, macOS, or Linux. Adapt the
# venv activation line to match. Everything else is identical across OSes.
#
# Prereqs the user must already have:
# - Python 3.10 or newer (check: python --version or python3 --version)
# - git
# If either is missing, stop and tell the user. Do not silently install.
#
# If LibreYOLO is already installed and importable in the current environment,
# skip the install steps and jump straight to VERIFY.
# 1. Clone the dev branch (we will move to main later)
git clone -b dev https://github.com/LibreYOLO/libreyolo.git
cd libreyolo
# 2. Create a virtual environment (stdlib only, no extra tools required)
python -m venv .venv
# 3. Activate it
# macOS / Linux:
source .venv/bin/activate
# Windows PowerShell (run instead of the line above):
# .venv\Scripts\Activate.ps1
# Windows cmd.exe:
# .venv\Scripts\activate.bat
# 4. Upgrade pip (avoids resolver bugs on older Python installs)
python -m pip install --upgrade pip
# 5. Install LibreYOLO in editable mode
pip install -e .
# 6. VERIFY (should print: LibreYOLO ready)
python -c "from libreyolo import LibreYOLO; print('LibreYOLO ready')"
# OPTIONAL: smoke test on a real image (downloads small weights on first run)
python -c "from libreyolo import LibreYOLO; m = LibreYOLO('LibreYOLO9t.pt'); r = m('https://raw.githubusercontent.com/LibreYOLO/libreyolo/release/libreyolo/assets/parkour.jpg'); print(len(r), 'detections')"
# === FAST PATH (only if the user already has `uv` installed) ===============
# Replaces steps 2-5 with a much faster resolver. Skip if uv is not present.
# Do NOT install uv just for this; pip is already fine.
# uv venv
# source .venv/bin/activate # or .venv\Scripts\Activate.ps1 on Windows
# uv pip install -e .
# === GPU NOTES =============================================================
# Step 5 installs the default PyTorch wheel from PyPI:
# - Linux: CUDA 12.x build (works with NVIDIA GPU out of the box)
# - macOS: CPU + MPS (Apple Silicon GPU works automatically)
# - Windows: CPU only by default
# Windows + NVIDIA GPU: install a CUDA torch wheel BEFORE step 5:
# pip install --index-url https://download.pytorch.org/whl/cu121 torch torchvision
# Hackathon-safe default: the CPU build is fine for small images and YOLO9t.
# === OPTIONAL EXTRAS (install only if your project needs them) =============
# pip install -e ".[onnx]" # ONNX export + ONNX Runtime inference
# pip install -e ".[rfdetr]" # RF-DETR transformer flagship
# pip install -e ".[tensorrt]" # NVIDIA TensorRT (Linux/Windows + CUDA)
# pip install -e ".[openvino]" # Intel CPU/GPU/VPU acceleration
# pip install -e ".[ncnn]" # Lightweight CPU/Vulkan deployment
# === IF THINGS BREAK =======================================================
# Windows: "running scripts is disabled on this system" when activating venv:
# Set-ExecutionPolicy -Scope CurrentUser RemoteSigned (run once, then retry)
# macOS / Linux: "python: command not found":
# use python3 -m venv .venv instead, and python3 -m pip ... for step 4
# torch wheel mismatch / ImportError:
# find the right wheel at https://pytorch.org/get-started/locally/
# Anything else: ask the user to paste the full error, then debug.상자 안의 아무 곳이나 클릭하여 모두 선택하거나 복사 버튼을 사용하십시오.
예제 1: 객체 탐지
경량 플래그십 YOLO9t를 사용하는 최소한의 완전한 탐지 예제입니다. LibreYOLO를 설치한 후 Python 파일이나 노트북에 붙여 넣어 모든 기능이 작동하는지 확인하고 Results 객체의 구조를 살펴볼 수 있습니다.
from libreyolo import LibreYOLO, SAMPLE_IMAGE
# One factory, any architecture. Auto-detects family, size, and classes.
model = LibreYOLO("LibreYOLO9t.pt")
# Accepts file paths, URLs, PIL, NumPy, tensors, or raw bytes.
result = model(SAMPLE_IMAGE, save=True)
print(result.boxes.xyxy) # (N, 4) tensor of bounding boxes
print(result.boxes.conf) # (N,) confidence scores
print(result.names[int(result.boxes.cls[0].item())]) # first class name
print(result.saved_path) # where the annotated image was saved
상자 안의 아무 곳이나 클릭하여 모두 선택하거나 복사 버튼을 사용하십시오.
예제 2: RF-DETR 분할
트랜스포머 플래그십 RF-DETR 모델을 사용한 인스턴스 분할입니다. -seg 접미사는 팩토리가 분할 헤드를 불러오도록 지정하므로 한 번의 호출로 바운딩 박스와 인스턴스별 이진 마스크를 얻습니다.
# Required once for RF-DETR examples pip install -e ".[rfdetr]"
상자 안의 아무 곳이나 클릭하여 모두 선택하거나 복사 버튼을 사용하십시오.
from libreyolo import LibreYOLO, SAMPLE_IMAGE
# RF-DETR is the transformer flagship. The "-seg" suffix tells the factory
# to load the segmentation head. Same call shape as detection.
model = LibreYOLO("LibreRFDETRs-seg.pt")
# save=True draws boxes plus translucent mask overlays on top of the image.
result = model(SAMPLE_IMAGE, save=True)
# Boxes still work the same as in detection
print(result.boxes.xyxy) # (N, 4) bounding boxes
print(result.boxes.cls) # (N,) class IDs
# Masks are the new bit
print(result.masks.data.shape) # (N, H, W) binary masks at image resolution
print(result.masks.xy[0].shape) # polygon contour for the first instance
print(result.saved_path) # annotated output path
상자 안의 아무 곳이나 클릭하여 모두 선택하거나 복사 버튼을 사용하십시오.
예제 3: 인체 키포인트
YOLO-NAS pose를 사용한 인체 자세 추정입니다. -pose 접미사가 키포인트 헤드를 불러와 탐지된 사람마다 사람 바운딩 박스와 17개 COCO 키포인트를 반환합니다.
from libreyolo import LibreYOLO, SAMPLE_IMAGE
# YOLO-NAS pose predicts one person box plus 17 COCO keypoints per person.
model = LibreYOLO("LibreYOLONASs-pose.pt")
result = model(SAMPLE_IMAGE, save=True)
print(result.boxes.xyxy) # (N, 4) person boxes
print(result.keypoints.xy.shape) # (N, 17, 2) pixel coordinates
print(result.keypoints.conf.shape) # (N, 17) keypoint confidence
if len(result):
print(result.keypoints.xy[0, 0]) # first person's nose keypoint
print(result.saved_path) # annotated output path
상자 안의 아무 곳이나 클릭하여 모두 선택하거나 복사 버튼을 사용하십시오.
예제 4: 비디오 추론
비디오에서 동일한 LibreYOLO 호출을 실행합니다. 모델 한 줄만 바꾸면 탐지, 분할 또는 키포인트 작업을 수행할 수 있습니다. RF-DETR 분할에는 예제 2의 rfdetr 추가 패키지가 여전히 필요합니다.
from libreyolo import LibreYOLO
# Pick one model:
model = LibreYOLO("LibreYOLO9t.pt") # detection
# model = LibreYOLO("LibreRFDETRs-seg.pt") # segmentation
# model = LibreYOLO("LibreYOLONASs-pose.pt") # keypoints
for frame in model("clip.mp4", stream=True, save=True):
print(frame.frame_idx, len(frame))
상자 안의 아무 곳이나 클릭하여 모두 선택하거나 복사 버튼을 사용하십시오.
예제 5: 객체 추적
ByteTrack은 비디오 프레임 간에 안정적인 ID를 추가합니다. 탐지에서 인원 계수, 스포츠 영상, 교통 분석 또는 같은 객체가 화면에 계속 있는지 알아야 하는 모든 작업으로 가장 빠르게 확장할 수 있습니다.
pip install libreyolo[tracking]
상자 안의 아무 곳이나 클릭하여 모두 선택하거나 복사 버튼을 사용하십시오.
from libreyolo import LibreYOLO
model = LibreYOLO("LibreYOLO9t.pt")
for result in model.track(
"clip.mp4",
track_conf=0.25,
iou=0.45,
save=True, # writes runs/track/<video_stem>.mp4 by default
vid_stride=1,
):
print(result.frame_idx, result.track_id)
상자 안의 아무 곳이나 클릭하여 모두 선택하거나 복사 버튼을 사용하십시오.