File size: 7,918 Bytes
e8a8dd9 382e94b 884a572 e8a8dd9 1c4a022 e8a8dd9 1c4a022 e8a8dd9 1c4a022 e8a8dd9 1c4a022 e8a8dd9 e29db42 e8a8dd9 e29db42 e8a8dd9 382e94b e8a8dd9 382e94b e8a8dd9 ce48a3d e8a8dd9 ce48a3d e8a8dd9 bda55bf e8a8dd9 ce48a3d e8a8dd9 6220b63 e8a8dd9 |
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 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 |
import streamlit as st
import plotly.express as px
import pandas as pd
import numpy as np
from tools import generator, get_plot
from PIL import Image
def set_app_title_and_logo():
st.set_page_config(
page_title="QB-GPT",
page_icon=":rocket:",
layout="wide",
)
def qb_gpt_page(ref_df, ref, tokenizer, model):
print(ref_df.columns)
with st.container():
colt1, colt2 = st.columns(2)
with colt1:
selected_home_team = st.selectbox("Select Home team", ref_df['home_team'].unique())
filtered_df = ref_df[(ref_df['home_team'] == selected_home_team)]
with colt2:
selected_away_team= st.selectbox("Select Away team ", filtered_df['away_team'].unique())
filtered_df = filtered_df[(filtered_df['away_team'] == selected_away_team)].reset_index(drop ="True")
cola, colb = st.columns(2)
with cola:
selected_gameId = st.selectbox("Select Game ID", filtered_df['gameId'].unique())
filtered_df = filtered_df[(filtered_df['gameId'] == selected_gameId)]
with colb:
selected_Play= st.selectbox("Select Play ", filtered_df['playId'].unique())
filtered_df = filtered_df[(filtered_df['playId'] == selected_Play)].reset_index(drop ="True")
# Display the filtered DataFrame
st.write("Filtered Data:")
st.dataframe(filtered_df)
with st.container():
col1, col2 = st.columns(2)
with col1:
temperature = st.slider("Temperature", 1.0, 10.0, 1.5, step = 0.5)
with col2:
n_select = st.slider("N movements to shortlist", 2, 100, 10, step = 1)
QB_gen = generator(model=model,
tokenizer=tokenizer,
temp = temperature,
n_select = n_select)
selected = filtered_df["index"][0]
selection = ref[selected]
colc, cold = st.columns(2)
with colc:
starts = st.slider("Starting frame from which QB GPT generates", 1, 21, 1, step = 1)
with cold:
frames = st.slider("Number of frames to generate", 1, 50, 20, step = 1)
if st.button("Generate"):
trial_d = QB_gen.tokenizer.truncate_to_time_t(selection, starts)
generated = QB_gen.generate_sequence(trial_d, frames)
decoded = QB_gen.tokenizer.decode_sequence(generated)
step1 = QB_gen.prepare_for_plot(decoded)
plot = pd.DataFrame(step1)
decoded_true = QB_gen.tokenizer.decode_sequence(selection)
step1_true = QB_gen.prepare_for_plot(decoded_true)
plot_true = pd.DataFrame(step1_true)
fig_gen = get_plot(plot, frames, "Generated")
st.plotly_chart(fig_gen)
fig_true = get_plot(plot_true, frames, "True")
st.plotly_chart(fig_true)
def contacts_and_disclaimers():
st.title("QB-GPT - Your Football Playbook Powerhouse!")
with st.expander("***What is QB-GPT?***"):
qb_gpt_what = """
QuarterBack-GPT (QB-GPT) is a companion in the world of football strategy and analytics. It's an innovative application with a model relying on the remarkable capabilities of Transformers to generate football plays in a realistic fashion.
"""
st.markdown(qb_gpt_what)
with st.expander("***What's inside QB-GPT***"):
qb_gpt_transf = """
At the heart of QB-GPT lies the cutting-edge Transformer model, a deep learning architecture known for its prowess in understanding sequential data.
A more detailed blogpost about the model QB-GPT can be found [here](https://medium.com/@sam.chaineau/transformers-can-generate-nfl-plays-introducing-qb-gpt-2d40f16a03eb)
"""
st.markdown(qb_gpt_transf)
with st.expander("***QB-GPT in Action***"):
qb_gpt_act = """
With QB-GPT, you can explore a wide range of football scenarios. The eventual goal is to create a complete framework able to predict plays' results and optimize lineups, play calls etc.
"""
st.markdown(qb_gpt_act)
with st.expander("***Author***"):
col1, col2 = st.columns([4, 1])
with col1:
author_text = """
My name is Samuel Chaineau, I am 26 and live in Paris. This is my second work related to Deep-Learning applied to NFL NGS data. This work is released as an app in order to facilitate the interaction and feedbacks from user. I also hope having constructive academic/scientific feedbacks to improve the model and bring it to the next level.
I have a background in economics, management, statistics and computer sciences. I am currently the CTO of a french healthcare start-up called Nuvocare. Prior to that I worked 2 and a half years as a Data Scientist at Ekimetrics.
***Contacts***
If interested by the project, the app or wishing to discuss any related topics, feel free to contact me on :
- Linkedin : [My profile](https://www.linkedin.com/in/samuel-chaineau-734b13122/)
- X (Twitter, nobody says X) : [My profile](https://twitter.com/samboucon)
- Or you can follow me on Medium : [My blog](https://medium.com/@sam.chaineau)
"""
st.markdown(author_text)
with col2:
image = Image.open('./assets/photo_cv.jpg')
st.image(image)
with st.expander("***Disclaimers***"):
disclaimer_text = """
This work is at a very early stage and while I think it shows promising results, I acknowledge that the model may yield disturbing results and potentially wrong.
Maintaining and improving QB-GPT will be a long run.
I used data only found publicly on the internet (GitHub and Kaggle). I don't hold any relationship with NFL officials or any NFL teams.
I do not intend to have any payments or commercial activities via this app. It is a POC showing abilities, advantages and flaws of current SotA technologies applied to sports analytics.
"""
st.markdown(disclaimer_text)
with st.expander("***License***"):
license_text = """
**License**
This application and its associated work are released under the **Creative Commons Attribution-NonCommercial 4.0 International License**.
**Creative Commons Attribution-NonCommercial 4.0 International License (CC BY-NC 4.0)**
You are free to:
- **Share** - copy and redistribute the material in any medium or format.
- **Adapt** - remix, transform, and build upon the material.
Under the following terms:
- **Attribution (BY)**: You must give appropriate credits and indicate if changes were made. You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use.
- **Non-Commercial (NC)**: You may not use the material for commercial purposes.
- **No Derivatives (ND)**: If you remix, transform, or build upon the material, you may not distribute the modified material.
For a full description of the license terms, please visit the [Creative Commons Attribution-NonCommercial 4.0 International License](https://creativecommons.org/licenses/by-nc/4.0/).
This license is designed to allow others to use, remix, and build upon your work, but not for commercial purposes. It requires proper attribution and restricts commercial use and the creation of derivative works.
"""
st.markdown(license_text) |