DerekLiu35 commited on
Commit
70135dd
1 Parent(s): d986ab0

Update image_to_fen/fen.py

Browse files
Files changed (1) hide show
  1. image_to_fen/fen.py +10 -0
image_to_fen/fen.py CHANGED
@@ -7,6 +7,8 @@ import torch
7
  import torchvision
8
  import numpy as np
9
  import re
 
 
10
 
11
  import image_to_fen.util as util
12
 
@@ -94,6 +96,14 @@ def fen_from_onehot(one_hot):
94
 
95
  return output
96
 
 
 
 
 
 
 
 
 
97
  def main():
98
  """Run prediction on image."""
99
  parser = argparse.ArgumentParser(description="Predict FEN string for image of chess board.")
 
7
  import torchvision
8
  import numpy as np
9
  import re
10
+ import chess
11
+ from fentoimage.board import BoardImage
12
 
13
  import image_to_fen.util as util
14
 
 
96
 
97
  return output
98
 
99
+ def fen_and_image(input):
100
+ itf = ImageToFen()
101
+ output = itf.predict(input)
102
+ fen = output.replace('-', '/')
103
+ renderer = BoardImage(fen)
104
+ image = renderer.render()
105
+ return fen, image
106
+
107
  def main():
108
  """Run prediction on image."""
109
  parser = argparse.ArgumentParser(description="Predict FEN string for image of chess board.")