{"id":18428576,"url":"https://github.com/sthalles/deeplab_v3","last_synced_at":"2025-04-12T22:23:04.274Z","repository":{"id":27619948,"uuid":"114664198","full_name":"sthalles/deeplab_v3","owner":"sthalles","description":"Tensorflow Implementation of the Semantic Segmentation DeepLab_V3 CNN","archived":false,"fork":false,"pushed_at":"2022-12-08T02:09:07.000Z","size":595,"stargazers_count":805,"open_issues_count":17,"forks_count":284,"subscribers_count":22,"default_branch":"master","last_synced_at":"2025-03-28T01:04:13.179Z","etag":null,"topics":["deep-learning","deeplab-v3","python","semantic-segmentation","tensorflow"],"latest_commit_sha":null,"homepage":"","language":"Jupyter Notebook","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sthalles.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-12-18T16:38:50.000Z","updated_at":"2025-01-03T12:16:02.000Z","dependencies_parsed_at":"2023-01-14T07:08:30.432Z","dependency_job_id":null,"html_url":"https://github.com/sthalles/deeplab_v3","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sthalles%2Fdeeplab_v3","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sthalles%2Fdeeplab_v3/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sthalles%2Fdeeplab_v3/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sthalles%2Fdeeplab_v3/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sthalles","download_url":"https://codeload.github.com/sthalles/deeplab_v3/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247103246,"owners_count":20884024,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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","deeplab-v3","python","semantic-segmentation","tensorflow"],"created_at":"2024-11-06T05:14:05.143Z","updated_at":"2025-04-04T02:04:15.422Z","avatar_url":"https://github.com/sthalles.png","language":"Jupyter Notebook","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003ca href=\"https://doi.org/10.5281/zenodo.1248776\"\u003e\u003cimg src=\"https://zenodo.org/badge/DOI/10.5281/zenodo.1248776.svg\" alt=\"DOI\"\u003e\u003c/a\u003e\n\n# DeepLab_V3 Image Semantic Segmentation Network\n\nImplementation of the Semantic Segmentation DeepLab_V3 CNN as described at [Rethinking Atrous Convolution for Semantic Image Segmentation](https://arxiv.org/pdf/1706.05587.pdf).\n\nFor a complete documentation of this implementation, check out the [blog post](https://sthalles.github.io/deep_segmentation_network/).\n\n## Dependencies\n\n- Python 3.x\n- Numpy\n- Tensorflow 1.10.1\n\n## Downloads\n\n### Evaluation\n\nPre-trained model.\n\n- [checkpoints](https://www.dropbox.com/sh/s7sx69pqjhrk0s4/AACXWCRd9JJ0zvcvDES9G3sba?dl=0)\n\nPlace the checkpoints folder inside `./tboard_logs`. If the folder **does not** exist, create it.\n\n### Retraining\n\nOriginal datasets used for training.\n\n- Dataset\n  * [Option 1](https://mega.nz/#F!LlFCSaBB!1L_EoepUwhrHw4lHv1HRaA)\n  * [Option 2](http://www.mediafire.com/?wx7h526chc4ar)\n\nPlace the tfrecords files inside ```./dataset/tfrecords```. Create the folder if it **does not** exist.\n\n## Training and Eval\n\nOnce you have the training and validation *TfRefords* files, just run the command bellow. Before running Deeplab_v3, the code will look for the proper `ResNets` checkpoints inside ```./resnet/checkpoints```, if the folder does not exist, it will first be **downloaded**.\n\n```\npython train.py --starting_learning_rate=0.00001 --batch_norm_decay=0.997 --crop_size=513 --gpu_id=0 --resnet_model=resnet_v2_50\n```\n\nCheck out the *train.py* file for more input argument options. Each run produces a folder inside the *tboard_logs* directory (create it if not there).\n\nTo evaluate the model, run the *test.py* file passing to it the *model_id* parameter (the name of the folder created inside *tboard_logs* during training).\n\nNote: Make sure the `test.tfrecords` is downloaded and placed inside `./dataset/tfrecords`.\n\n```\npython test.py --model_id=16645\n```\n\n## Retraining\n\nTo use a different dataset, you just need to modify the ```CreateTfRecord.ipynb``` notebook inside the ```dataset/``` folder, to suit your needs.\n\nAlso, be aware that originally Deeplab_v3 performs random crops of size **513x513** on the input images. This **crop_size** parameter can be configured by changing the ```crop_size``` hyper-parameter in **train.py**.\n\n## Datasets\n\nTo create the dataset, first make sure you have the [Pascal VOC 2012](http://host.robots.ox.ac.uk/pascal/VOC/voc2012/) and/or the [Semantic Boundaries Dataset and Benchmark](http://home.bharathh.info/pubs/codes/SBD/download.html) datasets downloaded.\n\n**Note: You do not need both datasets.**\n - If you just want to test the code with one of the datasets (say the SBD), run the notebook normally, and it should work.\n\nAfter, head to ```dataset/``` and run the ```CreateTfRecord.ipynb``` notebook.\n\nThe ```custom_train.txt``` file contains the name of the images selected for training. This file is designed to use the Pascal VOC 2012 set as a **TESTING** set. Therefore, it doesn't contain any images from the VOC 2012 val dataset. For more info, see the **Training** section of [Deeplab Image Semantic Segmentation Network](https://sthalles.github.io/deep_segmentation_network/).\n\nObs. You can skip that part and direct download the datasets used in this experiment - See the **Downloads** section\n\n## Serving\n\nFor full documentation on serving this Semantic Segmentation CNN, refer to [How to deploy TensorFlow models to production using TF Serving](https://sthalles.github.io/serving_tensorflow_models/).\n\nAll the serving scripts are placed inside: ```./serving/```.\n\nTo export the model and to perform client requests do the following:\n\n1. Create a python3 virtual environment and install the dependencies from the ```serving_requirements.txt``` file;\n\n2. Using the python3 env, run ```deeplab_saved_model.py```. The exported model should reside into ```./serving/model/```;\n\n3. Create a python2 virtual environment and install the dependencies from the ```client_requirements.txt``` file;\n\n4. From the python2 env, run the ```deeplab_client.ipynb``` notebook;\n\n## Results\n\n- Pixel accuracy: ~91%\n- Mean Accuracy: ~82%\n- Mean Intersection over Union (mIoU): ~74%\n- Frequency weighed Intersection over Union: ~86\n\n![Results](https://github.com/sthalles/sthalles.github.io/blob/master/assets/deep_segmentation_network/results1.png)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsthalles%2Fdeeplab_v3","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsthalles%2Fdeeplab_v3","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsthalles%2Fdeeplab_v3/lists"}