Answers.Body: <p>I suggest that you just use 13 classes, and let the network learn to ignore the square's background color. I used this approach when I did a &quot;chess position search engine&quot; of Youtube videos, and didn't notice any issues. Neural networks are very good at learning on which features are important, and what should be ignored (or internally &quot;normalized&quot; away).</p>
  <p>Granted, real-life photos have a lot more variability than digital ones. But my data had its own issues, due to overlay graphics, and pieces being in the process of being moved. Here are samples of <a href="https://nikonyrh.github.io/Agadmator_samples_white.jpg" rel="nofollow noreferrer">white</a> and <a href="https://nikonyrh.github.io/Agadmator_samples_black.jpg" rel="nofollow noreferrer">black</a> pieces.</p>
  <p>I actually ended up having two extra categories: squares where multiple pieces overlap, and squares where the content wasn't from chess board at all (the source video was showing something else).</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2024-05-24T12:32:20.203Z
Answers.LastActivityDate: 2024-05-24T12:32:20.203Z
Answers.UserDisplayName: NikoNyrh
Body: <p>Ok, so I am working on a project which classifies chess pieces. The input is just a chess piece from a specific chess set on a white / black square on the chessboard. So it's just an image of a chess square on the board, with a chess piece on it (or without).</p>
  <p>Assume the dataset on which the model is trained is balanced (has the same amount of photos of every piece on a square of a specific color, etc.).</p>
  <p>What's the best way of labeling these? I will explain what are my ideas and thoughts:</p>
  <ol>
  <li><p>13 classes, every combination of PIECE-COLOR and EMPTY square, 13 in total. The problem with this approach though is that I think the color of the square that the piece is on will mess up with the prediction (not sure if this would be the case), even though the dataset is balanced.</p>
  </li>
  <li><p>25 classes, every combination of SQUARECOLOR-PIECE-COLOR and EMPTY square. I am thinking maybe this would have better results, but I don't know if that's the case, maybe it's a bit too complex?</p>
  </li>
  <li><p>Classify the type of piece first / empty (ignoring the color at first), so 7 classes, and after the type of piece is identified then just the classification of the color (white / black). Maybe this is better than the two above, but I kinda run into the first problem, when trying to classify the color of the piece maybe the color of the square will mess up the results.</p>
  </li>
  </ol>
  <p>What would be best? Are there any other ideas? I want to use a classifier, not object detection, for experimental purposes. I know each one has pros and cons, but I want to hear some opinions.</p>
  <p>Edit: After thinking a little bit I thought of a fourth method which is similar to the third one. Classify the type of piece / empty square, and then classify the color by having 4 labels which indicate square color and piece color (so 4 combinations in total).</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2024-05-23T12:31:12.517Z
Comments.Text: Is your task to classify pieces from photos of in real life, or from screencaps of electronic chess games, or both, or something else?
Comments.UserDisplayName: Neil Slater
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2024-05-23T12:34:45.710Z
Comments.Text: From photos from real life, but basically the input of the problem that I described here is just a part of that photo, just think it as small photo of a chess square on a chessboard, with a piece on it (or empty)
Comments.UserDisplayName: vct12345
Tags: <machine-learning><classification><image-recognition><chess><labels>
Title: Best way to classify chess pieces on a chessboard (on a square) [more details in the post]?
UserDisplayName: vct12345
ThreadText: # Best way to classify chess pieces on a chessboard (on a square) [more details in the post]?
  
  (Asked by: username_0 on 2024-05-23)
  
  Ok, so I am working on a project which classifies chess pieces. The input is just a chess piece from a specific chess set on a white / black square on the chessboard. So it's just an image of a chess square on the board, with a chess piece on it (or without).
  
  Assume the dataset on which the model is trained is balanced (has the same amount of photos of every piece on a square of a specific color, etc.).
  
  What's the best way of labeling these? I will explain what are my ideas and thoughts:
  
  1. 13 classes, every combination of PIECE-COLOR and EMPTY square, 13 in total. The problem with this approach though is that I think the color of the square that the piece is on will mess up with the prediction (not sure if this would be the case), even though the dataset is balanced.
  2. 25 classes, every combination of SQUARECOLOR-PIECE-COLOR and EMPTY square. I am thinking maybe this would have better results, but I don't know if that's the case, maybe it's a bit too complex?
  3. Classify the type of piece first / empty (ignoring the color at first), so 7 classes, and after the type of piece is identified then just the classification of the color (white / black). Maybe this is better than the two above, but I kinda run into the first problem, when trying to classify the color of the piece maybe the color of the square will mess up the results.
  
  What would be best? Are there any other ideas? I want to use a classifier, not object detection, for experimental purposes. I know each one has pros and cons, but I want to hear some opinions.
  
  Edit: After thinking a little bit I thought of a fourth method which is similar to the third one. Classify the type of piece / empty square, and then classify the color by having 4 labels which indicate square color and piece color (so 4 combinations in total).
  
  **Tags:** machine-learning, classification, image-recognition, chess, labels
  
  > **Comments:**
  > **username_1**: Is your task to classify pieces from photos of in real life, or from screencaps of electronic chess games, or both, or something else?  
  > **username_0**: From photos from real life, but basically the input of the problem that I described here is just a part of that photo, just think it as small photo of a chess square on a chessboard, with a piece on it (or empty)  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_2 on 2024-05-24. Score: 0
  
  I suggest that you just use 13 classes, and let the network learn to ignore the square's background color. I used this approach when I did a "chess position search engine" of Youtube videos, and didn't notice any issues. Neural networks are very good at learning on which features are important, and what should be ignored (or internally "normalized" away).
  
  Granted, real-life photos have a lot more variability than digital ones. But my data had its own issues, due to overlay graphics, and pieces being in the process of being moved. Here are samples of [white](https://username_2.github.io/Agadmator_samples_white.jpg) and [black](https://username_2.github.io/Agadmator_samples_black.jpg) pieces.
  
  I actually ended up having two extra categories: squares where multiple pieces overlap, and squares where the content wasn't from chess board at all (the source video was showing something else).
  
  
  ---
  
  