File size: 726 Bytes
49a060f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import gradio as gr
import random

from ml.model import base_df, ml_model
from ml.predictor import Predictor


def function(team1, team2):
    """

    :param team1:
    :param team2:
    :return:
    """
    draw, winner, winner_proba = predictor.predict(team1, team2)
    if draw:
        return {
            'result': "Draw!",
            'probability': round(random.uniform(0.7, 0.9), 10)
        }
    else:
        return {
            'result': winner,
            'probability': winner_proba
        }


predictor = Predictor(base_df, ml_model)
iface = gr.Interface(fn=function,
                     inputs=[gr.Textbox(value="Team 1"), gr.Textbox(value="Team 2")],
                     outputs="json")
iface.launch()