GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - Elucidation/ChessboardFenTensorflowJs: Find chessboard FEN from a screenshot using TensorflowJs

BranchesTags
Open more actions menu

Latest commit

 

History

48 Commits
48 Commits

Folders and files

NameName
Last commit message
Last commit date
frozen_model
frozen_model
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
chessboard_detection.js
chessboard_detection.js
 
 
chessbot_tensorflow_model.js
chessbot_tensorflow_model.js
 
 
example_input.png
example_input.png
 
 
fen2htmldiv.js
fen2htmldiv.js
 
 
filters.js
filters.js
 
 
index.html
index.html
 
 
readme_cropped_input.png
readme_cropped_input.png
 
 
readme_gradient_find.png
readme_gradient_find.png
 
 
readme_input.png
readme_input.png
 
 
readme_prediction.png
readme_prediction.png
 
 
style.css
style.css
 
 

Repository files navigation

TensorflowJs Chessboard Prediction from Screenshots in HTML5

Given a screenshot of a chessboard from lichess.org/chess.com, it tries to find the chessboard and pieces on it, Try it yourself.

image

How it works

This uses a frozen Tensorflow Chessbot model. Unlike that repo this runs completely in javascript using TensorflowJs, all client-side.

Board detection

Finds and separates out the chessboard into a 256x256 px image containing the 32x32 tiles of the chessboard. A very simplified chessboard detector is implemented. It requires the board to mostly fill up the image, be very well aligned and centered. In comparison chessfenbot can find aligned chessboards all around the image. Issue #2

The image is blurred and then the sobel gradients X and Y are used to find strong vertical and horizontal edges in the image corresponding to the chessboard. This is used to guess the bounds of the chessboard, and then generate a 256x256 px grayscale image as input for the tensorflow model.

ML Prediction

Given 256x256px aligned chessboard image, it runs a TensorflowJs model to predict pieces on it.

The model was trained using 32x32 px grayscale tiles of chessboard pieces. For each tile it independently predicts one of 13 classes, 6 white pieces, 6 black pieces, or an empty tile.

We freeze the model graph and weights from Tensorflow Chessbot, and load it up in Javascript using TensorflowJs, allowing everything to run without a server.

image

Running locally

A web server of some sort is needed to allow cross-origin sharing when running locally.

For example, one can use

python -m http.server

or

http-server -o --cors -c-1 -a localhost

About

Find chessboard FEN from a screenshot using TensorflowJs

www.tetralark.com/ChessboardFenTensorflowJs/

Topics

chesschessboardtensorflowtensorflow-examplestensorflow-js

Resources

Readme
MIT license
Activity

Stars

28 stars

Watchers

2 watching

Forks

11 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.