Downloads · 30 days
7
7% of all-time downloads
marco-costa-ml/balatro-yolo
balatro-yolo is a object detection model from marco-costa-ml. Use it when you need objects located in an image. It is set up for ultralytics. The card lists the license as mit.
Fine-tuned YOLOv8 model for detecting gameplay objects in Balatro from video frames.
Downloads · 30 days
7
7% of all-time downloads
All-time downloads
96
Public
Repo size
54.9 MB
Likes
0
Public
Click a slice to open those files.
.pt52.5 MB · 97%
From the Hugging Face model README
Fine-tuned YOLOv8 model for detecting gameplay objects in Balatro from video frames.
This model is trained on large-scale annotated gameplay data and is designed to detect all relevant in-game objects required for reconstructing structured game state. It serves as the first stage in a full computer vision pipeline used for dataset generation and imitation learning.
For information on how this model was trained, see Balatro CV Pipeline repository
balatro-yolo/
├── assets/
│ ├── train_batch0.jpg
│ ├── val_batch0_pred.jpg
│ └── results.png
├── weights/
│ └── model.pt
├── config.json
├── inference.py
├── data.yaml
└── README.md
The model predicts bounding boxes and class labels for a wide range of gameplay elements, including:
This enables full reconstruction of game state when combined with tracking and OCR.
video frame
↓
YOLOv8 detection (this model)
↓
bounding boxes + class IDs + confidence
↓
object tracking
↓
state composition
↓
structured dataset
gameplay video frames are loaded
frames are optionally downsampled via frame_stride
batches of frames are passed through YOLOv8
detections are written to CSV with:
The output is used downstream for:
pip install ultralytics opencv-python torch numpy
from ultralytics import YOLO
model = YOLO("weights/model.pt")
results = model("frame.png")
for r in results:
boxes = r.boxes.xyxy
classes = r.boxes.cls
confs = r.boxes.conf
import cv2
from ultralytics import YOLO
model = YOLO("weights/model.pt")
cap = cv2.VideoCapture("clip.mp4")
while cap.isOpened():
ret, frame = cap.read()
if not ret:
break
results = model.predict(source=frame, imgsz=640, half=True, verbose=False)
annotated = results[0].plot()
cv2.imshow("output", annotated)
if cv2.waitKey(1) == 27:
break
cap.release()
cv2.destroyAllWindows()
nohup python scripts/detect/detect_bulk.py \
--project-root $PROJECT_ROOT \
--video-dir $VIDEO_DIR \
--model-path $MODEL_PATH \
--gpus 0,1,2,3,4,5,6,7 \
--frame-stride 2 \
--imgsz 640 \
--batch-size 32 \
--recursive \
--half \
> $LOG_FILE 2>&1 &
frame_strideEach detection is written to CSV with the following schema:
video_id
frame_idx
timestamp_ms
class_id
conf
x1
y1
x2
y2
model_name
model_version
box_layout_version
This format is designed for downstream processing into:
The model was trained using YOLOv8 with a custom dataset:
nc: 400 classes
imgsz: 640
epochs: 150
batch: 56
from ultralytics import YOLO
model = YOLO("yolov8m.pt")
model.train(
data="data.yaml",
epochs=150,
patience=40,
imgsz=640,
batch=56,
workers=16,
device="0,1,2,3,4,5,6,7"
)


precision: 0.999
recall: 0.996
mAP50: 0.995
mAP50-95: 0.993
The model is trained on a large-scale annotated dataset of Balatro gameplay frames.
This model is part of a full computer vision system for reconstructing gameplay state from video.
video
↓
object detection (this model)
↓
object tracking
↓
composed object state
↓
observations dataset
↓
ML agent training
The final goal is to enable large-scale imitation learning without requiring access to the game engine.
MIT