{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"pygments_lexer":"ipython3","nbconvert_exporter":"python","version":"3.6.4","file_extension":".py","codemirror_mode":{"name":"ipython","version":3},"name":"python","mimetype":"text/x-python"}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"code","source":"# This Python 3 environment comes with many helpful analytics libraries installed\n# It is defined by the kaggle/python Docker image: https://github.com/kaggle/docker-python\n# For example, here's several helpful packages to load\n\nimport numpy as np # linear algebra\nimport pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)\nimport cv2\nimport random\n\n#Ignore warnings\nimport warnings\nwarnings.filterwarnings('ignore')\n\n# Input data files are available in the read-only \"../input/\" directory\n# For example, running this (by clicking run or pressing Shift+Enter) will list all files under the input directory\n\nimport os\nfor dirname, _, filenames in os.walk('/kaggle/input'):\n    for filename in filenames:\n        print(os.path.join(dirname, filename))\n\n# You can write up to 20GB to the current directory (/kaggle/working/) that gets preserved as output when you create a version using \"Save & Run All\" \n# You can also write temporary files to /kaggle/temp/, but they won't be saved outside of the current session","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","_kg_hide-input":true,"_kg_hide-output":true,"execution":{"iopub.status.busy":"2022-07-30T22:48:08.445248Z","iopub.execute_input":"2022-07-30T22:48:08.446098Z","iopub.status.idle":"2022-07-30T22:48:08.460127Z","shell.execute_reply.started":"2022-07-30T22:48:08.446033Z","shell.execute_reply":"2022-07-30T22:48:08.458670Z"},"collapsed":true,"jupyter":{"outputs_hidden":true},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"<iframe width=\"942\" height=\"530\" src=\"https://www.youtube.com/embed/smZizYVXGJQ\" title=\"The Bundesliga Is On Fire - Powered By 442oons\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture\" allowfullscreen></iframe>","metadata":{}},{"cell_type":"markdown","source":"#The Bundesliga Is On Fire - Powered By 442oons\n\nThe funniest part was when Muller sprayed the fire extinguisher.\n\nhttps://www.youtube.com/watch?v=smZizYVXGJQ","metadata":{}},{"cell_type":"code","source":"#By Rob Mulla https://www.kaggle.com/robikscube/kaggle-deepfake-detection-introduction  \n\nimport cv2 as cv\nimport os\nimport matplotlib.pylab as plt\ntrain_dir = '/kaggle/input/dfl-bundesliga-data-shootout/test'\nfig, ax = plt.subplots(1,1, figsize=(15, 15))\ntrain_video_files = [train_dir + x for x in os.listdir(train_dir)]\n# video_file = train_video_files[30]\nvideo_file = '../input/dfl-bundesliga-data-shootout/test/019d5b34_1.mp4'\ncap = cv.VideoCapture(video_file)\nsuccess, image = cap.read()\nimage = cv.cvtColor(image, cv.COLOR_BGR2RGB)\ncap.release()   \nax.imshow(image)\nax.xaxis.set_visible(False)\nax.yaxis.set_visible(False)\nax.title.set_text(f\"FRAME 0: {video_file.split('/')[-1]}\")\nplt.grid(False)","metadata":{"_kg_hide-input":true,"execution":{"iopub.status.busy":"2022-07-30T22:48:16.321933Z","iopub.execute_input":"2022-07-30T22:48:16.322212Z","iopub.status.idle":"2022-07-30T22:48:17.079966Z","shell.execute_reply.started":"2022-07-30T22:48:16.322190Z","shell.execute_reply":"2022-07-30T22:48:17.079327Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train = pd.read_csv('../input/dfl-bundesliga-data-shootout/train.csv', encoding='utf8')\ntrain.head()","metadata":{"execution":{"iopub.status.busy":"2022-07-30T22:48:24.194528Z","iopub.execute_input":"2022-07-30T22:48:24.194976Z","iopub.status.idle":"2022-07-30T22:48:24.234765Z","shell.execute_reply.started":"2022-07-30T22:48:24.194937Z","shell.execute_reply":"2022-07-30T22:48:24.233034Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sub = pd.read_csv('../input/dfl-bundesliga-data-shootout/sample_submission.csv', encoding='utf8')\nsub.head()","metadata":{"execution":{"iopub.status.busy":"2022-07-30T22:48:29.981758Z","iopub.execute_input":"2022-07-30T22:48:29.982235Z","iopub.status.idle":"2022-07-30T22:48:30.001033Z","shell.execute_reply.started":"2022-07-30T22:48:29.982209Z","shell.execute_reply":"2022-07-30T22:48:29.999650Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#Code by Lucas Abrahão https://www.kaggle.com/lucasabrahao/trabalho-manufatura-an-lise-de-dados-no-brasil\n\ntrain[\"event\"].value_counts().plot.barh(color=['blue', '#f5005a', 'darkgreen', 'orange', 'black'], title='Fußball-Bundesliga Events');","metadata":{"_kg_hide-input":true,"execution":{"iopub.status.busy":"2022-07-30T22:48:34.426320Z","iopub.execute_input":"2022-07-30T22:48:34.426751Z","iopub.status.idle":"2022-07-30T22:48:34.576866Z","shell.execute_reply.started":"2022-07-30T22:48:34.426722Z","shell.execute_reply":"2022-07-30T22:48:34.576143Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#Code by Jeff Herman https://www.kaggle.com/jth359/video-to-frames-and-face-detection-using-opencv/data\n\nvidObj = cv2.VideoCapture('/kaggle/input/dfl-bundesliga-data-shootout/clips/cd987c_1.mp4')\n\ncount = 0\n\nwhile True: \n      \n    success, image = vidObj.read() \n    \n    if success:\n        cv2.imwrite(f\"frame{count}.jpg\", image) \n    else: \n        break\n        \n    count += 1","metadata":{"execution":{"iopub.status.busy":"2022-07-30T22:48:39.877383Z","iopub.execute_input":"2022-07-30T22:48:39.877748Z","iopub.status.idle":"2022-07-30T22:49:06.233215Z","shell.execute_reply.started":"2022-07-30T22:48:39.877718Z","shell.execute_reply":"2022-07-30T22:49:06.232177Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#https://stackoverflow.com/questions/25359288/how-to-know-total-number-of-frame-in-a-file-with-cv2-in-python\n\ncap = cv2.VideoCapture(\"/kaggle/input/dfl-bundesliga-data-shootout/test/019d5b34_1.mp4\")\nlength = int(cap.get(cv2.CAP_PROP_FRAME_COUNT))\nprint( length )","metadata":{"execution":{"iopub.status.busy":"2022-07-30T22:49:11.471048Z","iopub.execute_input":"2022-07-30T22:49:11.471340Z","iopub.status.idle":"2022-07-30T22:49:11.506957Z","shell.execute_reply.started":"2022-07-30T22:49:11.471318Z","shell.execute_reply":"2022-07-30T22:49:11.506068Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#Code by Jeff Herman https://www.kaggle.com/jth359/video-to-frames-and-face-detection-using-opencv/data\n\nimport matplotlib.pyplot as plt\nimport matplotlib.image as mpimg\n\nfor i in range(0, 700, 100):  ## the original was 0,1300,100 The length is 702 above \n    img = mpimg.imread(f'./frame{i}.jpg')\n    imgplot = plt.imshow(img)\n    plt.show()","metadata":{"_kg_hide-input":true,"execution":{"iopub.status.busy":"2022-07-30T22:49:16.542395Z","iopub.execute_input":"2022-07-30T22:49:16.542718Z","iopub.status.idle":"2022-07-30T22:49:19.454054Z","shell.execute_reply.started":"2022-07-30T22:49:16.542694Z","shell.execute_reply":"2022-07-30T22:49:19.453380Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import plotly.graph_objects as go\nimport plotly.offline as py\nimport plotly.express as px\nfrom plotly.offline import iplot","metadata":{"execution":{"iopub.status.busy":"2022-07-30T22:49:25.538090Z","iopub.execute_input":"2022-07-30T22:49:25.538452Z","iopub.status.idle":"2022-07-30T22:49:26.513358Z","shell.execute_reply.started":"2022-07-30T22:49:25.538428Z","shell.execute_reply":"2022-07-30T22:49:26.512409Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"fig = px.parallel_categories(sub, color=\"score\", color_continuous_scale=px.colors.sequential.OrRd, title='Fußball-Bundesliga')\nfig.show()","metadata":{"_kg_hide-input":true,"execution":{"iopub.status.busy":"2022-07-30T22:49:29.652392Z","iopub.execute_input":"2022-07-30T22:49:29.652795Z","iopub.status.idle":"2022-07-30T22:49:30.662007Z","shell.execute_reply.started":"2022-07-30T22:49:29.652754Z","shell.execute_reply":"2022-07-30T22:49:30.660811Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"fig = px.bar(train, \n             x='event', y='time',color_discrete_sequence=['#DC143C'],\n             title='Fußball-Bundesliga Events', text='event_attributes')\nfig.show()","metadata":{"_kg_hide-input":true,"execution":{"iopub.status.busy":"2022-07-30T23:07:51.138134Z","iopub.execute_input":"2022-07-30T23:07:51.139948Z","iopub.status.idle":"2022-07-30T23:07:51.306441Z","shell.execute_reply.started":"2022-07-30T23:07:51.139870Z","shell.execute_reply":"2022-07-30T23:07:51.305621Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#Code by Baris Dincer https://www.kaggle.com/brsdincer/human-evolution-process-dcgan/notebook\n\n#PATH PROCESS\nimport os\nimport os.path\nfrom pathlib import Path\nimport glob\n#IMAGE PROCESS\nfrom PIL import Image\nfrom keras.preprocessing import image\nfrom tensorflow.keras.preprocessing.image import ImageDataGenerator\nimport cv2\nfrom keras.applications.vgg16 import preprocess_input, decode_predictions\nimport imageio\nfrom IPython.display import Image\nimport matplotlib.image as mpimg\nfrom skimage.transform import resize\nfrom mpl_toolkits.mplot3d import Axes3D\nfrom matplotlib import cm\nimport zipfile\nfrom io import BytesIO\nfrom nibabel import FileHolder\nfrom nibabel.analyze import AnalyzeImage\nimport PIL\nfrom IPython import display","metadata":{"execution":{"iopub.status.busy":"2022-07-30T22:49:44.928793Z","iopub.execute_input":"2022-07-30T22:49:44.929091Z","iopub.status.idle":"2022-07-30T22:49:51.047502Z","shell.execute_reply.started":"2022-07-30T22:49:44.929068Z","shell.execute_reply":"2022-07-30T22:49:51.046624Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#Code by Baris Dincer https://www.kaggle.com/brsdincer/human-evolution-process-dcgan/notebook\n\n#SCALER & TRANSFORMATION\nfrom sklearn.preprocessing import StandardScaler\nfrom sklearn.preprocessing import MinMaxScaler\nfrom keras.utils.np_utils import to_categorical\nfrom sklearn.model_selection import train_test_split\nfrom keras import regularizers\nfrom sklearn.preprocessing import LabelEncoder\n#ACCURACY CONTROL\nfrom sklearn.metrics import confusion_matrix, accuracy_score, classification_report, roc_auc_score, roc_curve\nfrom sklearn.model_selection import GridSearchCV, cross_val_score\nfrom sklearn.metrics import mean_squared_error, r2_score","metadata":{"execution":{"iopub.status.busy":"2022-07-30T22:49:53.350459Z","iopub.execute_input":"2022-07-30T22:49:53.351316Z","iopub.status.idle":"2022-07-30T22:49:53.461035Z","shell.execute_reply.started":"2022-07-30T22:49:53.351291Z","shell.execute_reply":"2022-07-30T22:49:53.459833Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#Code by Baris Dincer https://www.kaggle.com/brsdincer/human-evolution-process-dcgan/notebook\n\n#OPTIMIZER\nfrom tensorflow.keras.optimizers import RMSprop,Adam,Optimizer,Optimizer, SGD\n#MODEL LAYERS\nfrom tensorflow.keras.models import Sequential\nfrom keras.layers import Dense, Dropout, Flatten, Conv2D, MaxPool2D, BatchNormalization,MaxPooling2D,BatchNormalization,\\\n                        Permute, TimeDistributed, Bidirectional,GRU, SimpleRNN,\\\nLSTM, GlobalAveragePooling2D, SeparableConv2D, ZeroPadding2D, Convolution2D, ZeroPadding2D,Reshape, Conv2DTranspose, LeakyReLU\nfrom tensorflow.keras import models\nfrom keras import layers\nimport tensorflow as tf\nfrom tensorflow.keras.applications import VGG16,VGG19,inception_v3\nfrom keras import backend as K\nfrom tensorflow.keras.utils import plot_model\nfrom keras.datasets import mnist\nimport keras","metadata":{"execution":{"iopub.status.busy":"2022-07-30T22:50:09.151459Z","iopub.execute_input":"2022-07-30T22:50:09.151844Z","iopub.status.idle":"2022-07-30T22:50:09.162966Z","shell.execute_reply.started":"2022-07-30T22:50:09.151812Z","shell.execute_reply":"2022-07-30T22:50:09.161768Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#Code by Baris Dincer https://www.kaggle.com/brsdincer/human-evolution-process-dcgan/notebook\n\n#SKLEARN CLASSIFIER\nfrom xgboost import XGBClassifier, XGBRegressor\nfrom lightgbm import LGBMClassifier, LGBMRegressor\nfrom catboost import CatBoostClassifier, CatBoostRegressor\nfrom sklearn.linear_model import LogisticRegression\nfrom sklearn.naive_bayes import GaussianNB\nfrom sklearn.ensemble import RandomForestClassifier, RandomForestRegressor\nfrom sklearn.ensemble import GradientBoostingClassifier, GradientBoostingRegressor\nfrom sklearn.ensemble import BaggingRegressor\nfrom sklearn.tree import DecisionTreeClassifier, DecisionTreeRegressor\nfrom sklearn.neural_network import MLPClassifier, MLPRegressor\nfrom sklearn.neighbors import KNeighborsClassifier, KNeighborsRegressor\nfrom sklearn.linear_model import LinearRegression\nfrom sklearn.cross_decomposition import PLSRegression\nfrom sklearn.linear_model import Ridge\nfrom sklearn.linear_model import RidgeCV\nfrom sklearn.linear_model import Lasso\nfrom sklearn.linear_model import LassoCV\nfrom sklearn.linear_model import ElasticNet\nfrom sklearn.linear_model import ElasticNetCV\n#IGNORING WARNINGS\nfrom warnings import filterwarnings\nfilterwarnings(\"ignore\",category=DeprecationWarning)\nfilterwarnings(\"ignore\", category=FutureWarning) \nfilterwarnings(\"ignore\", category=UserWarning)","metadata":{"execution":{"iopub.status.busy":"2022-07-30T22:50:17.011751Z","iopub.execute_input":"2022-07-30T22:50:17.012059Z","iopub.status.idle":"2022-07-30T22:50:17.826485Z","shell.execute_reply.started":"2022-07-30T22:50:17.012035Z","shell.execute_reply":"2022-07-30T22:50:17.825435Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"Video_Path = \"../input/dfl-bundesliga-data-shootout/test/019d5b34_1.mp4\"","metadata":{"execution":{"iopub.status.busy":"2022-07-30T22:50:25.564206Z","iopub.execute_input":"2022-07-30T22:50:25.564704Z","iopub.status.idle":"2022-07-30T22:50:25.567911Z","shell.execute_reply.started":"2022-07-30T22:50:25.564680Z","shell.execute_reply":"2022-07-30T22:50:25.567349Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#Code by Baris Dincer https://www.kaggle.com/brsdincer/human-evolution-process-dcgan/notebook\n\nVideo_IMG_List = []\n\nVideo_Cap = cv2.VideoCapture(Video_Path)\n\n\nwhile Video_Cap.isOpened():\n\n    \n    ret,frame = Video_Cap.read()\n    \n    if ret != True:\n        break\n        \n    if Video_Cap.isOpened():\n        Transformation_IMG = cv2.cvtColor(frame,cv2.COLOR_BGR2RGB)\n        Resize_IMG = cv2.resize(Transformation_IMG,(180,180))\n        Video_IMG_List.append(Resize_IMG)\n        \n        \nVideo_Cap.release()","metadata":{"execution":{"iopub.status.busy":"2022-07-30T22:50:30.747273Z","iopub.execute_input":"2022-07-30T22:50:30.747652Z","iopub.status.idle":"2022-07-30T22:50:35.792182Z","shell.execute_reply.started":"2022-07-30T22:50:30.747627Z","shell.execute_reply":"2022-07-30T22:50:35.791421Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(np.shape(np.asarray(Video_IMG_List)))","metadata":{"execution":{"iopub.status.busy":"2022-07-30T22:50:41.258823Z","iopub.execute_input":"2022-07-30T22:50:41.259146Z","iopub.status.idle":"2022-07-30T22:50:41.280309Z","shell.execute_reply.started":"2022-07-30T22:50:41.259122Z","shell.execute_reply":"2022-07-30T22:50:41.279301Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#Code by Baris Dincer https://www.kaggle.com/brsdincer/human-evolution-process-dcgan/notebook\n\nfigure = plt.figure(figsize=(8,8))\n\nPick_IMG = Video_IMG_List[1]\nplt.xlabel(Pick_IMG.shape)\nplt.ylabel(Pick_IMG.size)\nplt.imshow(Pick_IMG);","metadata":{"_kg_hide-input":true,"execution":{"iopub.status.busy":"2022-07-30T22:50:47.355669Z","iopub.execute_input":"2022-07-30T22:50:47.356099Z","iopub.status.idle":"2022-07-30T22:50:47.654329Z","shell.execute_reply.started":"2022-07-30T22:50:47.356076Z","shell.execute_reply":"2022-07-30T22:50:47.653298Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#Code by Baris Dincer https://www.kaggle.com/brsdincer/human-evolution-process-dcgan/notebook\n\nfigure = plt.figure(figsize=(8,8))\n\nPick_IMG = Video_IMG_List[700]#Original is 1000, but we have 750, 180, 180, 3 \nplt.xlabel(Pick_IMG.shape)\nplt.ylabel(Pick_IMG.size)\nplt.imshow(Pick_IMG);","metadata":{"_kg_hide-input":true,"execution":{"iopub.status.busy":"2022-07-30T22:50:57.148711Z","iopub.execute_input":"2022-07-30T22:50:57.149011Z","iopub.status.idle":"2022-07-30T22:50:57.440625Z","shell.execute_reply.started":"2022-07-30T22:50:57.148987Z","shell.execute_reply":"2022-07-30T22:50:57.439606Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#Code by Baris Dincer https://www.kaggle.com/brsdincer/human-evolution-process-dcgan/notebook\n\nfigure = plt.figure(figsize=(8,8))\n\nPick_IMG = Video_IMG_List[610]#Original 3410\nplt.xlabel(Pick_IMG.shape)\nplt.ylabel(Pick_IMG.size)\nplt.imshow(Pick_IMG);","metadata":{"_kg_hide-input":true,"execution":{"iopub.status.busy":"2022-07-30T22:51:05.688429Z","iopub.execute_input":"2022-07-30T22:51:05.688780Z","iopub.status.idle":"2022-07-30T22:51:06.012749Z","shell.execute_reply.started":"2022-07-30T22:51:05.688753Z","shell.execute_reply":"2022-07-30T22:51:06.011852Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"figure,axis = plt.subplots(4,4,figsize=(10,10))\n\nfor i,ax in enumerate(axis.flat):\n    \n    IMG_From_List = Video_IMG_List[i]\n    ax.set_xlabel(IMG_From_List.shape)\n    ax.imshow(IMG_From_List)\n    \nplt.tight_layout()\nplt.show()","metadata":{"_kg_hide-input":true,"execution":{"iopub.status.busy":"2022-07-30T22:51:13.565976Z","iopub.execute_input":"2022-07-30T22:51:13.566284Z","iopub.status.idle":"2022-07-30T22:51:15.282247Z","shell.execute_reply.started":"2022-07-30T22:51:13.566259Z","shell.execute_reply":"2022-07-30T22:51:15.281282Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"X_Train = np.asarray(Video_IMG_List)","metadata":{"execution":{"iopub.status.busy":"2022-07-30T22:51:23.407559Z","iopub.execute_input":"2022-07-30T22:51:23.408201Z","iopub.status.idle":"2022-07-30T22:51:23.426226Z","shell.execute_reply.started":"2022-07-30T22:51:23.408168Z","shell.execute_reply":"2022-07-30T22:51:23.425346Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(X_Train.shape)","metadata":{"execution":{"iopub.status.busy":"2022-07-30T22:51:29.016830Z","iopub.execute_input":"2022-07-30T22:51:29.017186Z","iopub.status.idle":"2022-07-30T22:51:29.022309Z","shell.execute_reply.started":"2022-07-30T22:51:29.017157Z","shell.execute_reply":"2022-07-30T22:51:29.021312Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#Code by Baris Dincer https://www.kaggle.com/brsdincer/human-evolution-process-dcgan/notebook\n\nfigure = plt.figure(figsize=(8,8))\n\nPick_IMG = X_Train[410]\nplt.xlabel(Pick_IMG.shape)\nplt.ylabel(Pick_IMG.size)\nplt.imshow(Pick_IMG);","metadata":{"_kg_hide-input":true,"execution":{"iopub.status.busy":"2022-07-30T22:51:34.275244Z","iopub.execute_input":"2022-07-30T22:51:34.275793Z","iopub.status.idle":"2022-07-30T22:51:34.586090Z","shell.execute_reply.started":"2022-07-30T22:51:34.275762Z","shell.execute_reply":"2022-07-30T22:51:34.585355Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#Code by Baris Dincer https://www.kaggle.com/brsdincer/human-evolution-process-dcgan/notebook\n\nfigure = plt.figure(figsize=(8,8))\n\nPick_IMG = X_Train[534]#Original 3534\nplt.xlabel(Pick_IMG.shape)\nplt.ylabel(Pick_IMG.size)\nplt.imshow(Pick_IMG);","metadata":{"_kg_hide-input":true,"execution":{"iopub.status.busy":"2022-07-30T22:51:41.768511Z","iopub.execute_input":"2022-07-30T22:51:41.769046Z","iopub.status.idle":"2022-07-30T22:51:42.083656Z","shell.execute_reply.started":"2022-07-30T22:51:41.769016Z","shell.execute_reply":"2022-07-30T22:51:42.082694Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#Code by Ducky https://www.kaggle.com/code/illgamhoduck/nfl-starter-eda\n\nENV_DIR = '../input'\nDATA_DIR = f'{ENV_DIR}/dfl-bundesliga-data-shootout'","metadata":{"execution":{"iopub.status.busy":"2022-07-30T22:51:49.394583Z","iopub.execute_input":"2022-07-30T22:51:49.394902Z","iopub.status.idle":"2022-07-30T22:51:49.398970Z","shell.execute_reply.started":"2022-07-30T22:51:49.394877Z","shell.execute_reply":"2022-07-30T22:51:49.397997Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"os.listdir(DATA_DIR)","metadata":{"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#Code by Ducky https://www.kaggle.com/code/illgamhoduck/nfl-starter-eda\n\n# Bounding Box\ntrain_df = pd.read_csv(f'{DATA_DIR}/train.csv') #We don't have labels to make it\n\n# Tracking Information using Sensor\n#train_tracking_df = pd.read_csv(f'{DATA_DIR}/train_player_tracking.csv')\n#test_tracking_df = pd.read_csv(f'{DATA_DIR}/test_player_tracking.csv')\n\n# images/\n# -----------------------------------------------------------------------\n# Trained images using images_labels.csv and predict the train, test\n# The prediction result is [train/test]_baseline_helmets.csv\n# No player information is included\n\n# information of images without player information\n#image_df = pd.read_csv(f'{DATA_DIR}/image_labels.csv')\n\n# Baseline Prediction - Trained by images inside folder images/\ntrain_predict_df = pd.read_csv(f'{DATA_DIR}/train.csv')\n\n#test_predict_df = pd.read_csv(f'{DATA_DIR}/test_baseline_helmets.csv')","metadata":{"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"#Get Image by frame","metadata":{}},{"cell_type":"code","source":"#https://stackoverflow.com/questions/10748822/img-image-openfp-attributeerror-class-image-has-no-attribute-open\n\nimport PIL.Image","metadata":{"execution":{"iopub.status.busy":"2022-07-30T22:52:53.851088Z","iopub.execute_input":"2022-07-30T22:52:53.851465Z","iopub.status.idle":"2022-07-30T22:52:53.856031Z","shell.execute_reply.started":"2022-07-30T22:52:53.851436Z","shell.execute_reply":"2022-07-30T22:52:53.854937Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# reference : https://www.kaggle.com/coldfir3/eda-helmet-keypoint-tracking-data-comparison\ndef get_frame_from_video(video_path, frame):\n    video_path = f\"{DATA_DIR}/test/{video_path}\"\n    frame = frame - 1\n    \n    !ffmpeg \\\n        -hide_banner \\\n        -loglevel fatal \\\n        -nostats \\\n        -i $video_path -vf \"select=eq(n\\,$frame)\" -vframes 1 frame.jpg\n    \n    img = PIL.Image.open('frame.jpg')#StackOverflow https://stackoverflow.com/questions/10748822/img-image-openfp-attributeerror-class-image-has-no-attribute-open\n    os.remove('frame.jpg') \n    return img","metadata":{"execution":{"iopub.status.busy":"2022-07-30T23:01:08.155525Z","iopub.execute_input":"2022-07-30T23:01:08.156426Z","iopub.status.idle":"2022-07-30T23:01:08.164644Z","shell.execute_reply.started":"2022-07-30T23:01:08.156313Z","shell.execute_reply":"2022-07-30T23:01:08.163332Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"#Above original was  img = Image.open('frame.jpg')  Though it returned an error","metadata":{}},{"cell_type":"code","source":"#Code by Ducky https://www.kaggle.com/code/illgamhoduck/nfl-starter-eda\n\nget_frame_from_video('019d5b34_1.mp4', 1)","metadata":{"_kg_hide-input":true,"execution":{"iopub.status.busy":"2022-07-30T23:01:14.613818Z","iopub.execute_input":"2022-07-30T23:01:14.614130Z","iopub.status.idle":"2022-07-30T23:01:15.444171Z","shell.execute_reply.started":"2022-07-30T23:01:14.614107Z","shell.execute_reply":"2022-07-30T23:01:15.443279Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"#Display a Video","metadata":{}},{"cell_type":"code","source":"#Code by Ducky https://www.kaggle.com/code/illgamhoduck/nfl-starter-eda\n\nfrom IPython.display import Video, display\n\ndef video(video_path, ratio=0.7):\n    nfl_video = Video(f\"{DATA_DIR}/test/{video_path}\",\n                      embed=True,\n                      height=int(720 * ratio),\n                      width=int(1280 * ratio))\n    return nfl_video\n    \nvideo('019d5b34_1.mp4')","metadata":{"execution":{"iopub.status.busy":"2022-07-30T23:02:31.844677Z","iopub.execute_input":"2022-07-30T23:02:31.844986Z","iopub.status.idle":"2022-07-30T23:02:32.168274Z","shell.execute_reply.started":"2022-07-30T23:02:31.844962Z","shell.execute_reply":"2022-07-30T23:02:32.167351Z"},"_kg_hide-input":true,"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"#Fußball-Bundesliga it's really On Fire!","metadata":{"execution":{"iopub.status.busy":"2022-07-30T22:59:01.977443Z","iopub.execute_input":"2022-07-30T22:59:01.977749Z","iopub.status.idle":"2022-07-30T22:59:02.334411Z","shell.execute_reply.started":"2022-07-30T22:59:01.977723Z","shell.execute_reply":"2022-07-30T22:59:02.333288Z"}}},{"cell_type":"markdown","source":"#Acknowledgements:\n\nBaris Dincer https://www.kaggle.com/brsdincer/human-evolution-process-dcgan/notebook\n\nRob Mulla https://www.kaggle.com/robikscube/kaggle-deepfake-detection-introduction\n\nJeff Herman https://www.kaggle.com/jth359/video-to-frames-and-face-detection-using-opencv/data\n\nDucky https://www.kaggle.com/code/illgamhoduck/nfl-starter-eda","metadata":{}},{"cell_type":"markdown","source":"![](https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQHoXVDcAx4V8UeN8VK5Csy2nmR8OpLSRTODQ&usqp=CAU)esportes.r7.com","metadata":{}}]}