This repository contains code and resources for creating an AI model that can play the popular Chrome Dino Game using PyTorch and EfficientNet. The goal of this project is to train an AI agent to achieve high scores in the game by automatically detecting and reacting to obstacles.
The repository includes scripts for capturing game screens, processing the captured images to create a dataset, and a Jupyter notebook for training the AI model. By following the provided instructions, you can set up the environment, collect game data, and train your own AI model to play the Chrome Dino Game.
Feel free to explore the code, modify it according to your requirements, and experiment with different approaches to improve the AI agent's performance.
- Python 3.10
- PyTorch 1.10.0
- CUDA Toolkit 11.1 (for GPU acceleration)
To get started with the project, follow these steps:
-
Clone the repository:
git clone https://github.com/GuglielmoCerri/pytorch-dino-ai-game.git
-
Create a new conda environment:
conda env create -f environment.yml
-
Activate the environment:
conda activate dino
-
Start playing the Chrome Dino Game
-
Capture the game screens by running the captures.py script:
python src/captures.py
-
Process the captured images and create a dataset using the process.py script:
python src/process.py
-
Train and Test the AI model using the train_test.ipynb notebook
-
Watch the AI play the game using dino.py. The script automatically pressing the space bar based on the model's predictions.
python src/dino.py
- Add DownKey class: As the AI agent currently only supports jumping over obstacles, the game's versatility is limited. The aim of this issue is to introduce a new class called 'DownKey' that would allow the AI agent to duck under obstacles.
- Real-time Performance Metrics: To display The AI's performance metrics in real-time during game play.
Thank you for considering contributing to this project! Contributions are welcome and greatly appreciated.
To contribute to the project, please follow these steps:
- Fork the repository and create your branch from
main
. - Make your desired changes to the codebase.
- Ensure that your code follows the project's coding style and conventions.
- Write tests to validate your changes, if applicable.
- Commit your changes with clear and descriptive commit messages.
- Push your changes to your forked repository.
- Submit a pull request to the main repository, explaining the changes you have made.
Please note the following guidelines for contributing:
- Be respectful and considerate towards others.
- Ensure that your contributions align with the project's goals and scope.
- Provide detailed and constructive feedback in any discussions.
- Follow the project's code of conduct.
By contributing to this project, you agree to abide by the Contributor Covenant Code of Conduct.
Thank you for your support and contributions!
This project is licensed under the MIT License. See the LICENSE file for details.