https://github.com/kittinan/trex-keras-cnn
Play T-Rex game with Keras using convolutional neural network
https://github.com/kittinan/trex-keras-cnn
cnn-classification keras trex-game
Last synced: 4 months ago
JSON representation
Play T-Rex game with Keras using convolutional neural network
- Host: GitHub
- URL: https://github.com/kittinan/trex-keras-cnn
- Owner: kittinan
- License: mit
- Created: 2018-03-06T10:58:55.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2018-03-14T16:20:15.000Z (over 7 years ago)
- Last Synced: 2025-04-05T18:50:44.318Z (6 months ago)
- Topics: cnn-classification, keras, trex-game
- Language: Python
- Size: 955 KB
- Stars: 21
- Watchers: 1
- Forks: 4
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# T-Rex Keras CNN
## T-rex game
[http://www.trex-game.skipser.com](http://www.trex-game.skipser.com)### Install Requirement
```
pip install -r requirements.txt
```Recommended to use Tensorflow-GPU as backend
## Instruction
### 1. Collect Data
- Edit screen capture config in [collect_data.py](https://github.com/kittinan/trex-keras-cnn/blob/e349a721be7031075edf800bf581ddde2369929f/collect_data.py#L9) Line 9
- run [collect_data.py](https://github.com/kittinan/trex-keras-cnn/blob/master/collect_data.py) as root (require root by keybaord package)
This game use 3 keys on keyboard to record screen capture, the screen capture image will store in ./img/ folder. The image capture resolution is 650x130 pixel
| Key | Description |
| ---------------- | --------------------------- |
| Up Arrow (↑) | T-Rex Jump |
| Down Arrow (↓) | T-Rex Crouch |
| Right Arrow (→) | T-Rex ran normal |if you want to exit collect_data.py press **esc** key.
Please check your screen capture correction in the folder ./img/ before go to next step
*Example image captured*
![]()
### 2. Training
Just run [train.py](https://github.com/kittinan/trex-keras-cnn/blob/master/train.py)
```bash
python train.py
```train until 98%+ accuracy. the weight file trex_weight.h5 will create.
### 3. Play your model
run [player.py](https://github.com/kittinan/trex-keras-cnn/blob/master/player.py) as root (require root by keybaord package)
```bash
python player.py
```It possible T-Rex will jump before barrier, you can modify delay in [player.py](https://github.com/kittinan/trex-keras-cnn/blob/f270752de93caefc45182eb270163b78c0093972/player.py#L43)
## Dataset & Pretrained Model
Available soon
## Contributing
Feel free to contribute on this project, I will be happy to work with you.## License
The MIT License (MIT)