{"id":16135549,"url":"https://github.com/mayukhdeb/mind_the_bend","last_synced_at":"2026-03-05T09:33:14.794Z","repository":{"id":112696940,"uuid":"220813801","full_name":"Mayukhdeb/mind_the_bend","owner":"Mayukhdeb","description":"vision based deep learning for racing games :racing_car:","archived":false,"fork":false,"pushed_at":"2020-07-13T08:56:45.000Z","size":46134,"stargazers_count":14,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-07-05T20:12:06.872Z","etag":null,"topics":["deep-learning","opencv2","pillow","pyautogui","pytorch","self-driving-car"],"latest_commit_sha":null,"homepage":"","language":"Jupyter Notebook","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Mayukhdeb.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-11-10T16:02:41.000Z","updated_at":"2022-11-21T16:39:57.000Z","dependencies_parsed_at":null,"dependency_job_id":"f56b0b21-325a-4eb6-b8c1-925e42cbd756","html_url":"https://github.com/Mayukhdeb/mind_the_bend","commit_stats":{"total_commits":103,"total_committers":3,"mean_commits":"34.333333333333336","dds":0.3106796116504854,"last_synced_commit":"09940749220eaa0252c9b53590819cf2a19ed9d6"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Mayukhdeb/mind_the_bend","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Mayukhdeb%2Fmind_the_bend","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Mayukhdeb%2Fmind_the_bend/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Mayukhdeb%2Fmind_the_bend/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Mayukhdeb%2Fmind_the_bend/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Mayukhdeb","download_url":"https://codeload.github.com/Mayukhdeb/mind_the_bend/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Mayukhdeb%2Fmind_the_bend/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30117719,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-05T08:19:04.902Z","status":"ssl_error","status_checked_at":"2026-03-05T08:17:37.148Z","response_time":93,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["deep-learning","opencv2","pillow","pyautogui","pytorch","self-driving-car"],"created_at":"2024-10-09T23:08:33.582Z","updated_at":"2026-03-05T09:33:14.719Z","avatar_url":"https://github.com/Mayukhdeb.png","language":"Jupyter Notebook","funding_links":[],"categories":[],"sub_categories":[],"readme":"# mind_the_bend :racing_car:\n\nVision based deep learning for racing games. \n\n[![Binder](https://camo.githubusercontent.com/bfeb5472ee3df9b7c63ea3b260dc0c679be90b97/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f72656e6465722d6e627669657765722d6f72616e67652e7376673f636f6c6f72423d66333736323626636f6c6f72413d346434643464)](https://nbviewer.jupyter.org/github/Mayukhdeb/mind_the_bend/tree/master/)\n\nDoes the car stay on track by itself ? *yes*\n\nShould you trust your life on it ? *no*\n\n\u003e Note: The  model is trained and tested on an open source racing sim called speed dreams, you can install it from [here](https://flathub.org/apps/details/org.speed_dreams.SpeedDreams)\n\n# Ensemble model (under progresss)\n\u003cimg src=\"images/ensemble_design.jpg\" width=\"100%\"\u003e.\n\n\n\u003cimg src=\"images/ensemble_driver.gif\" width=\"50%\"\u003e.\n\n\n## data collection\nFor the ensemble model, data was collected from 2 perspectives within the game:\n* one of them would be responsible for the \"colors\" with a simple RGB image from the bonnet of the car \n* another one would be for the \"edges\" from a third person perspective \n\n\u003cimg src=\"images/ensemble_data.png\" width=\"50%\"\u003e.\n\n\n\n\n\n# Vanilla model:\n\n\u003cimg src=\"images/drunk_driver.gif\" width=\"80%\"\u003e.\n\n![3 channel 56*80 RGB image](https://github.com/Mayukhdeb/mind_the_bend/blob/master/images/pipeline.png \"3 channel 56*80 RGB image being fed into the CNN which returns steering values\")\n\nHere's the Project [in action](https://photos.app.goo.gl/ibtjnBxFtZ5SXGPJA)\n\n## :movie_camera:\tCollection of training data -\n* Rapidly takes screenshots of the game and saves them into a folder\n* The label in this case is the x-co-ordinate of the mouse which is captured by pyautogui and is stored in the formatted filename of each collected image\n\u003e image fileame formatting is done as  (x-value)_(unique_ID).png\n\n##  :mag_right: Processing images\n* Converts all images to numpy arrays with a depth of 3 for R,G and B color channels \n* The shape gets changed from  ``` [ width, height, depth ] ``` to ```[ depth, width, height]``` for it to be of the right size for the CNN input channel\n* Augmentation techniques like `RandomAffine()` get applied upon the images before the forward pass through the CNN for training\n\n## :chart_with_upwards_trend: Data preprocessing and augmentation\n* First things first, plotted the frequency distribution of each steering value hen\n* Roughly doubled the amount of training data by generating mirror images of existing images and vstacking them with reversed steer value. \n*  Flattened the frequency distribution by oversampling some labels with the Imbalanced-learn library and torch transforms\n* Normalised the steering values by replacing the x-co-ordinates with steering values. In my case the \"straight\" steer value was at x = 400, for normalised_value = 400 - x_value. \n\u003e note :  Right is negative steer value and left is positive\n\n## :red_car: Self driving \n\n\u003cimg src=\"example.gif\" width=\"60%\"\u003e.\n\n* Rapidly taken screenshots are prerpocessed and fed to the trained CNN drunk_driver()\n* drunk_driver() returns a steer value \n* Returned value is taken care  of by pyautogui which moves the mouse accordingly \n\n\u003cimg src=\"images/flex_mode.gif\" width=\"80%\"\u003e.\n\n\n### Stuff that's under way right now - \n* ~~take screenshots at a higher framerate both while collecting training data and testing trained models~~\n* ~~Figuring out a better data augmentation technique, instead of just making copies~~\n* Create and train an ensemble model with frames from different perspectives (forward, top down)\n\n## :heavy_exclamation_mark: need help\n* need a proper way to terminate/pause the loop in wear_your_seatbelts.ipynb when the CNN takes over mouse control, currently its done by moving the mouse to the corner of the screen manually \n* ~~kernel dies after about 5 mins of data collection in collect_training_data.ipynb~~\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmayukhdeb%2Fmind_the_bend","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmayukhdeb%2Fmind_the_bend","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmayukhdeb%2Fmind_the_bend/lists"}