Implementation of a Neural Network that can detect whether a video is Ingame or not
Video explanation (YouTube)
Authors:
Christian C.,
Moritz M.,
Luca S.
Related Projects:
Twitch Compilation Creator,
YouTube Uploader,
YouTube Watcher
This project implements a convolutional neural network architecture that can be trained to detect whether a given video clip is in-game or not. The network is trained using transfer learning by choosing one of the following architectures: ResNet50 (default), VGG16, InceptionV3
This project requires Poetry to install the required dependencies. Check out this link to install Poetry on your operating system.
Make sure you have installed Python 3.8 or higher! Otherwise Step 3 will let you know that you have no compatible Python version installed.
-
Clone/Download this repository
Note: For test models/assets, download Release v1.0
-
Navigate to the root of the repository
-
Run
poetry install
to create a virtual environment with Poetry -
Run
poetry run python src/filename.py
to run the program. Alternatively you can runpoetry shell
followed bypython src/filename.py
-
Enjoy :)
This utility can be used to build the dataset by splitting video files into images.
This script is used to verify the performance of the trained neural network by specifying a path to the model of the trained neural network, and a video clip that should be analyzed.
This script is used to train a neural network (e.g. create a model) on a given dataset. If enough data is present, the neural network will learn to distinguish Ingame clips from clips that are not ingame (e.g. Lobby, Queue, ...)
Let's assume you want to create a new model for the game Dota2. The following steps have to be performed:
- Download clips for Dota2 that are both ingame and not ingame (recommended source: Twitch)
HINT: You can download clips manually or by creating a compilation with TwitchCompilationCreator
- Split the clips into images via
video2images.py
- Create the following folder structure
...
│
└───anyFolderName
│
└───dota2
└───nogame
- Sort the clips from step 1 into those folders depending on if they are ingame or not
- Create a
main.py
file in./src/
to initialize aGameDetection
object, then run it (see example below) - Test the created model on a few example clips using
predict.py
to verify its accuracy
NOTE: The number of images in the 'gamename' or 'nogame' folder has to be greater than or equal to the defined batch size
# For more information about the parameters, check out game_detection.py
m = GameDetection(
model_name="ResNet50",
game_name="dota2",
dataset_path="---PATH TO 'anyFolderName'---",
input_size=(224, 224),
batch_size=16,
save_generated_images=False,
convert_to_gray=False,
)
m.train(epochs=2)