Update app.py
Browse files
app.py
CHANGED
@@ -50,14 +50,14 @@ def btn_load(inp_fen):
|
|
50 |
f.write(str(chess.svg.board(board)))
|
51 |
return 'board.svg', board.fen()
|
52 |
|
53 |
-
def btn_play(inp_fen, inp_move, inp_notation):
|
54 |
board = chess.Board(inp_fen)
|
55 |
|
56 |
if inp_move:
|
57 |
if inp_notation == 'UCI': mv = chess.Move.from_uci(inp_move) #board.push_uci(inp_move)
|
58 |
elif inp_notation == 'SAN': mv = board.parse_san(inp_move) #chess.Move.from_san(inp_move) #board.push_san(inp_move)
|
59 |
else:
|
60 |
-
mv = chess.Move.from_uci(predict_move(board.fen()))
|
61 |
|
62 |
board.push(mv)
|
63 |
|
@@ -70,14 +70,16 @@ with gr.Blocks() as block:
|
|
70 |
gr.Markdown(
|
71 |
'''
|
72 |
# Play YoloChess - Policy Network v0.3
|
73 |
-
110M Parameter Transformer (BERT-base architecture) trained for text classification from scratch on expert games in FEN notation.
|
74 |
'''
|
75 |
)
|
76 |
with gr.Row() as row:
|
77 |
with gr.Column():
|
78 |
-
|
79 |
-
|
|
|
80 |
fen = gr.Textbox(value=chess.Board().fen(), label='FEN')
|
|
|
81 |
with gr.Row():
|
82 |
load_btn = gr.Button("Load")
|
83 |
play_btn = gr.Button("Play")
|
@@ -94,7 +96,7 @@ with gr.Blocks() as block:
|
|
94 |
position_output = gr.Image(label='board')
|
95 |
|
96 |
load_btn.click(fn=btn_load, inputs=fen, outputs=[position_output, fen])
|
97 |
-
play_btn.click(fn=btn_play, inputs=[fen, move, notation], outputs=[position_output, fen, move])
|
98 |
|
99 |
|
100 |
block.launch()
|
|
|
50 |
f.write(str(chess.svg.board(board)))
|
51 |
return 'board.svg', board.fen()
|
52 |
|
53 |
+
def btn_play(inp_fen, inp_move, inp_notation, inp_k):
|
54 |
board = chess.Board(inp_fen)
|
55 |
|
56 |
if inp_move:
|
57 |
if inp_notation == 'UCI': mv = chess.Move.from_uci(inp_move) #board.push_uci(inp_move)
|
58 |
elif inp_notation == 'SAN': mv = board.parse_san(inp_move) #chess.Move.from_san(inp_move) #board.push_san(inp_move)
|
59 |
else:
|
60 |
+
mv = chess.Move.from_uci(predict_move(board.fen(), top_k=inp_k))
|
61 |
|
62 |
board.push(mv)
|
63 |
|
|
|
70 |
gr.Markdown(
|
71 |
'''
|
72 |
# Play YoloChess - Policy Network v0.3
|
73 |
+
110M Parameter Transformer (BERT-base architecture) trained for text classification from scratch on expert games in modified FEN notation.
|
74 |
'''
|
75 |
)
|
76 |
with gr.Row() as row:
|
77 |
with gr.Column():
|
78 |
+
with gr.Row():
|
79 |
+
move = gr.Textbox(label='human player move')
|
80 |
+
notation = gr.Radio(["SAN", "UCI"], value="SAN", label='move notation')
|
81 |
fen = gr.Textbox(value=chess.Board().fen(), label='FEN')
|
82 |
+
top_k = gr.Number(value=3, label='pick from top_k moves', precision=0)
|
83 |
with gr.Row():
|
84 |
load_btn = gr.Button("Load")
|
85 |
play_btn = gr.Button("Play")
|
|
|
96 |
position_output = gr.Image(label='board')
|
97 |
|
98 |
load_btn.click(fn=btn_load, inputs=fen, outputs=[position_output, fen])
|
99 |
+
play_btn.click(fn=btn_play, inputs=[fen, move, notation, top_k], outputs=[position_output, fen, move])
|
100 |
|
101 |
|
102 |
block.launch()
|