dopaul commited on
Commit
a81eaa2
·
verified ·
1 Parent(s): 6098f6b

Upload yolo segmentation model

Browse files
Files changed (2) hide show
  1. README.md +117 -0
  2. model.pt +3 -0
README.md ADDED
@@ -0,0 +1,117 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ tags:
4
+ - computer-vision
5
+ - chess
6
+ - yolo
7
+ - segmentation
8
+ - instance-segmentation
9
+
10
+ model-index:
11
+ - name: chess_board_segmentation
12
+ results: []
13
+ ---
14
+
15
+ # chess_board_segmentation
16
+
17
+ ChessBoard segmentation model trained with YOLO
18
+
19
+ ## Model Details
20
+
21
+ - **Model Type**: YOLO Segmentation
22
+ - **Task**: instance-segmentation
23
+ - **License**: apache-2.0
24
+
25
+ ## Usage
26
+
27
+ ### Loading the Model
28
+
29
+ ```python
30
+ from src.chess_board_detection.yolo.segmentation.segmentation_model import ChessBoardSegmentationModel
31
+
32
+ # Load the model
33
+ model = ChessBoardSegmentationModel(model_path="path/to/downloaded/model.pt")
34
+
35
+ # Get polygon coordinates for a chessboard
36
+ polygon_info, is_valid = model.get_polygon_coordinates("path/to/chessboard_image.jpg")
37
+
38
+ if is_valid:
39
+ print(f"Detected chessboard polygon: {polygon_info}")
40
+
41
+ # Extract corners from the segmentation
42
+ corners = model.extract_corners_from_segmentation(
43
+ "path/to/chessboard_image.jpg",
44
+ polygon_info
45
+ )
46
+ print(f"Extracted corners: {corners}")
47
+
48
+ # Visualize results
49
+ model.plot_eval("path/to/chessboard_image.jpg", show=True)
50
+ ```
51
+
52
+ ### Direct YOLO Usage
53
+
54
+ ```python
55
+ from ultralytics import YOLO
56
+
57
+ # Load the model
58
+ model = YOLO("path/to/downloaded/model.pt")
59
+
60
+ # Run segmentation
61
+ results = model("path/to/chessboard_image.jpg")
62
+
63
+ # Get masks and polygons
64
+ for result in results:
65
+ if result.masks is not None:
66
+ for mask in result.masks:
67
+ polygon = mask.xy[0] # Polygon coordinates
68
+ print(f"Polygon points: {polygon}")
69
+ ```
70
+
71
+ ### Training Data Format
72
+
73
+ This model expects YOLO segmentation format with polygon annotations:
74
+
75
+ ```yaml
76
+ # data.yaml
77
+ train: path/to/train/images
78
+ val: path/to/val/images
79
+ nc: 1
80
+ names: ['chessboard']
81
+ ```
82
+
83
+ With corresponding label files containing polygon coordinates:
84
+ ```
85
+ # labels/image.txt
86
+ 0 x1 y1 x2 y2 x3 y3 x4 y4 ... # normalized coordinates
87
+ ```
88
+
89
+ ## Training
90
+
91
+ This model was trained using the ChessBoard Segmentation training pipeline:
92
+
93
+ ```bash
94
+ python src/chess_board_detection/yolo/segmentation/train_segmentation.py \
95
+ --data data/chessboard_segmentation/chess-board-3/data.yaml \
96
+ --epochs 100 \
97
+ --batch 16 \
98
+ --pretrained-model yolov8s-seg.pt
99
+ ```
100
+
101
+ ## Model Performance
102
+
103
+ <!-- Add performance metrics here after training -->
104
+
105
+ ## Citation
106
+
107
+ If you use this model in your research, please cite:
108
+
109
+ ```bibtex
110
+ @misc{dopaul_chess_board_segmentation,
111
+ title={chess_board_segmentation},
112
+ author={dopaul},
113
+ year={2024},
114
+ publisher={Hugging Face},
115
+ url={https://huggingface.co/dopaul/chess_board_segmentation}
116
+ }
117
+ ```
model.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ecb872b97925deb30449ec5c41ba479f1a9ed4702ac03940e0d06afbaa75d132
3
+ size 23849524