Spaces:
Runtime error
Runtime error
Commit
•
25a3735
1
Parent(s):
b2e793b
Upload 2 files
Browse files- app.py +57 -0
- modelo_search.pkl +3 -0
app.py
ADDED
@@ -0,0 +1,57 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import pickle
|
2 |
+
import pandas as pd
|
3 |
+
import gradio as gr
|
4 |
+
|
5 |
+
import warnings
|
6 |
+
warnings.filterwarnings("ignore")
|
7 |
+
|
8 |
+
# Cargar el modelo
|
9 |
+
with open('modelo_search.pkl', 'rb') as f:
|
10 |
+
model = pickle.load(f)
|
11 |
+
|
12 |
+
def predict(mainline_moves, Opening, WhiteFideId, BlackFideId, WhiteElo, BlackElo):
|
13 |
+
df_model = pd.DataFrame({"mainline_moves":mainline_moves,
|
14 |
+
"Opening":Opening,
|
15 |
+
"WhiteFideId":WhiteFideId,
|
16 |
+
"BlackFideId":BlackFideId,
|
17 |
+
"WhiteElo": WhiteElo,
|
18 |
+
"BlackElo": BlackElo},
|
19 |
+
index= [0])
|
20 |
+
|
21 |
+
label_pred = model.predict(df_model)[0].item()
|
22 |
+
|
23 |
+
if label_pred == 0:
|
24 |
+
return "Ganó Blancas"
|
25 |
+
elif label_pred == 1:
|
26 |
+
return "Ganó Negras"
|
27 |
+
else:
|
28 |
+
return "Tablas"
|
29 |
+
|
30 |
+
# Definir los widgets de entrada
|
31 |
+
|
32 |
+
mainline_moves = gr.inputs.Number(label="Mainline Moves")
|
33 |
+
Opening = gr.inputs.Textbox(label="Opening")
|
34 |
+
WhiteFideId = gr.inputs.Textbox(label="White Fide ID")
|
35 |
+
BlackFideId = gr.inputs.Textbox(label="Black Fide ID")
|
36 |
+
WhiteElo = gr.inputs.Slider(label="White Elo",
|
37 |
+
minimum=0, maximum=3000, step=10,
|
38 |
+
default=2400)
|
39 |
+
BlackElo = gr.inputs.Slider(label="Black Elo",
|
40 |
+
minimum=0, maximum=3000, step=10,
|
41 |
+
default=2400)
|
42 |
+
|
43 |
+
# Definir la salida
|
44 |
+
output_label = gr.outputs.Label(num_top_classes=1, label="Resultado de la partida")
|
45 |
+
|
46 |
+
# Definir la interfaz
|
47 |
+
iface = gr.Interface(fn=predict,
|
48 |
+
inputs=[mainline_moves, Opening, WhiteFideId, BlackFideId, WhiteElo, BlackElo],
|
49 |
+
outputs=output_label,
|
50 |
+
title="Predicción de partidas de Ajedrez",
|
51 |
+
theme=gr.themes.Soft(),
|
52 |
+
layout="horizontal",
|
53 |
+
allow_flagging=False,
|
54 |
+
description="Coloca los datos solicitados y descubre el resultado de la partida!")
|
55 |
+
|
56 |
+
# Ejecutar la interfaz
|
57 |
+
iface.launch()
|
modelo_search.pkl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:d816df98fe397a2f869b5f59c783f1a1bd15f33dbdec9227f273520f942ec636
|
3 |
+
size 1098288
|