Skip to content

Use U-Net to segment the lines on a Go board for recog'ing the positions of intersection points.

License

Notifications You must be signed in to change notification settings

Noirewinter/goboard-segmentation

Repository files navigation

GoBoard segmentation

Python Pytorch TFLite Linux MacOS

Design goals

This project is an attempt to solve the recognition of Go board information through visual technology in the Go game scenario. Its main application is the segmentation task of lines on the Go board, accurately identifying the position of lines from the board. Subsequently, it can be combined with tasks such as detection to match the relationship between various objects to achieve accurate reconstruction of board information.

Background and Implementation

When recognizing board information from freely captured Go board images, we typically employ traditional computer vision (CV) algorithms to perform noise reduction, localization, and reconstruction. However, we often encounter challenges such as tilted shooting angles, blurred target objects, and distorted target regions due to curling. For these adverse conditions that are almost always encountered in free-shooting scenarios, relying solely on CV approaches for processing cannot achieve ideal performance requirements.

By combining deep-learning-based detection tasks with CV methods, the robustness issues brought about by object interference and tilted angles can be improved. However, when facing distortion, especially excessive curling deformation in the context of capturing images of book pages, the results are still unsatisfactory. Therefore, an attempt is made to implement segmentation tasks:

  • Leverage the high positional accuracy of segmentation tasks
  • Combine with CV algorithms to accurately locate the intersection points of the board lines
  • Reconstruct the board based on the relationship between the intersection points and the positions of the pieces (not a segmentation task)

The segmentation algorithm is implemented using U-Net Page to achieve better performance.

With a small amount of sample training, the algorithm has achieved excellent results. To attain even higher performance, more diverse data is needed for training. At the same time, this algorithm is an attempt to solve similar problems and can be extended to a range of applications such as chessboard detection, table detection, and more.

Environment

Ubuntu 20.04
Python 3.8.x

Usage

Installation

Quick install dependencies: pip install -r requirements.txt

Training

To train a segmentor with pre-trained models, run:

./train.py [-h] [--train_data TRAIN_DATA] [--val_data VAL_DATA] [--save_path SAVE_PATH] [--pretrained_path PRETRAINED_PATH]
                [--num_epochs NUM_EPOCHS] [--lr LR] [--batch_size BATCH_SIZE] [--imgsz IMGSZ]

Inference

To inference based on PyTorch model, run:

./infer.py [-h] --model_path MODEL_PATH [--data_dir DATA_DIR] [--output_dir OUTPUT_DIR] [--imgsz IMGSZ]

To inference based on TFLite model, run:

./tflite_infer.py [-h] --model_path MODEL_PATH [--data_dir DATA_DIR] [--output_dir OUTPUT_DIR] [--imgsz IMGSZ]

Here are some examples of visualization (with test model board-seg.pth):

Export TFLite

./export.py [-h] --model_path MODEL_PATH --output_path OUTPUT_PATH [--imgsz IMGSZ]

About

Use U-Net to segment the lines on a Go board for recog'ing the positions of intersection points.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages