{"id":39070162,"url":"https://github.com/monocongo/segment_deeplab","last_synced_at":"2026-01-17T18:20:08.260Z","repository":{"id":97693346,"uuid":"236093877","full_name":"monocongo/segment_deeplab","owner":"monocongo","description":"This project describes the use of TensorFlow's DeepLab v3 for semantic segmentation.","archived":false,"fork":false,"pushed_at":"2020-01-26T01:53:48.000Z","size":14,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-06-11T19:52:37.550Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":null,"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/monocongo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2020-01-24T22:24:59.000Z","updated_at":"2020-01-25T03:12:31.000Z","dependencies_parsed_at":"2023-03-30T20:33:54.649Z","dependency_job_id":null,"html_url":"https://github.com/monocongo/segment_deeplab","commit_stats":{"total_commits":6,"total_committers":1,"mean_commits":6.0,"dds":0.0,"last_synced_commit":"841b3a2d246f0340ae930d399a89e33b1af8613d"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/monocongo/segment_deeplab","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/monocongo%2Fsegment_deeplab","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/monocongo%2Fsegment_deeplab/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/monocongo%2Fsegment_deeplab/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/monocongo%2Fsegment_deeplab/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/monocongo","download_url":"https://codeload.github.com/monocongo/segment_deeplab/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/monocongo%2Fsegment_deeplab/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28515299,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-17T17:57:59.192Z","status":"ssl_error","status_checked_at":"2026-01-17T17:57:52.527Z","response_time":85,"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":[],"created_at":"2026-01-17T18:20:03.572Z","updated_at":"2026-01-17T18:20:08.240Z","avatar_url":"https://github.com/monocongo.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# segment_deeplab\nThis project describes the use of TensorFlow's \n[DeepLab v3](https://github.com/tensorflow/models/tree/master/research/deeplab) \nfor semantic segmentation.\n\n### Prerequisites\nWe assume a Linux development environment running on Ubuntu 18.04. We assume that \nthe training of the model will be performed on a system with an NVIDIA GPU, and \nas such we need to have CUDA and cuDNN installed. \n\n1. Install [CUDA](https://developer.nvidia.com/cuda-toolkit):\n    ```bash\n    $ wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/cuda-ubuntu1804.pin\n    $ sudo mv cuda-ubuntu1804.pin /etc/apt/preferences.d/cuda-repository-pin-600\n    $ sudo apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/7fa2af80.pub\n    $ sudo add-apt-repository \"deb http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/ /\"\n    $ sudo apt-get update\n    $ sudo apt-get -y install cuda\n    ```\n2. Install [cuDNN](https://developer.nvidia.com/rdp/cudnn-download):\n    1. Login to the [NVIDIA Developer Network](https://developer.nvidia.com)\n    2. Download the [cuDNN Runtime Library for Ubuntu18.04](https://developer.nvidia.com/compute/machine-learning/cudnn/secure/7.6.5.32/Production/10.2_20191118/Ubuntu18_04-x64/libcudnn7_7.6.5.32-1%2Bcuda10.2_amd64.deb)\n    ```\n    $ sudo apt install ./libcudnn7_7.6.5.32-1+cuda10.2_amd64.deb\n    ```\n3. Install [OpenCV](https://opencv.org/):\n    ```\n    $ sudo apt-get install libopencv-dev python3-opencv\n    ```   \n### Python Environment\n1. Create a new Python virtual environment:\n    ```bash\n    $ conda config --add channels conda-forge\n    $ conda create -n deeplab python=3 --yes\n    $ conda activate deeplab\n    ```\n2. Get the TensorFlow DeepLab API:\n    ```bash\n    $ git clone https://github.com/tensorflow/models.git\n    $ cd models/research\n    $ export TFMODELS=`pwd`\n    $ cd deeplab\n    $ export DEEPLAB=`pwd`\n    ```\n3. Install additional libraries we'll use in our project (assumes that `conda-forge` \nis the primary channel):\n    ```bash\n    $ for pkg in opencv imutils tensorflow-gpu\n    \u003e do\n    \u003e conda install $pkg --yes\n    \u003e done\n    $ pip install cvdata\n    ```\n4. Verify the installation:\n    ```bash\n    $ python\n    \u003e\u003e\u003e import cv2\n    \u003e\u003e\u003e import cvdata\n    \u003e\u003e\u003e import imutils\n    \u003e\u003e\u003e import tensorflow\n    \u003e\u003e\u003e\n    ```\n5. Set the `models/research` directory into the `PYTHONPATH` environment variable:\n    ```bash\n    $ export PYTHONPATH=/home/ubuntu/git/models/research\n    ```\n### Training Dataset\nAcquire a dataset of images and corresponding object segmentation masks. This project \nassumes a dataset with a directory of image files in JPG format and a corresponding \ndirectory of mask image files in PNG format matching to each image file. The mask \nfiles are expected to contain mask values corresponding to the class ID of the objects \nbeing masked, with unmasked/background having value 0. For example if we have two \nclasses, dog and cat with class IDs 1 and 2 respectively, then all dog masks in a \nmask image will be denoted with value 1 and all cat masks will be denoted with value 2.\n\nAn example dataset that includes image mask files is the \n[ISIC 2018 Skin Lesion Analysis Dataset](https://challenge2018.isic-archive.com/).\n\nIn order to convert the dataset of images and masks into TFRecords, which is the \ndata format used for training data, we'll use the [cvdata](https://pypi.org/project/cvdata/) \npackage's `cvdata_mask` entry point:\n```bash\n$ cvdata_mask --images /data/images --masks /data/masks \\\n\u003e       --in_format png --out_format tfrecord \\\n\u003e       --tfrecords /data/tfrecords \\\n\u003e       --shards 4 -- train_pct 0.8\n```\nThe above example execution will result in eight TFRecord files -- four TFRecords \nfor the training set, comprising of 80% of the images/masks, and four TFRecords \nfor the validation set, comprising of 20% of the images/masks.\n\nOnce we have the TFRecords for training and validation we then modify the file `$DEEPLAB/segmentation_dataset.py`\n### Training\n\n##### Pretrained model\nDownload a pretrained model checkpoint from the \n[DeepLab Model Zoo](https://github.com/tensorflow/models/blob/master/research/deeplab/g3doc/model_zoo.md):\n```bash\n$ wget http://download.tensorflow.org/models/xception_65_coco_pretrained_2018_10_02.tar.gz\n$ tar -zxf xception_65_coco_pretrained_2018_10_02.tar.gz\n``` \n\n##### Training script\nRun the [DeepLab training script](https://github.com/tensorflow/models/blob/master/research/deeplab/train.py) \nreferencing the pretrained model checkpoint, local dataset directory, training \nlog directory, etc. For example:\n```bash\n$ cd ${TFMODELS}\n$ python deeplab/train.py \\\n    --logtostderr \\\n    --training_number_of_steps=30000 \\\n    --train_split=\"train\" \\\n    --model_variant=\"xception_65\" \\\n    --atrous_rates=6 \\\n    --atrous_rates=12 \\\n    --atrous_rates=18 \\\n    --output_stride=16 \\\n    --decoder_output_stride=4 \\\n    --train_crop_size=\"513,513\" \\\n    --train_batch_size=1 \\\n    --dataset=\"basins\" \\\n    --tf_initial_checkpoint=/home/ubuntu/deeplab/pretrained/x65-b2u1s2p-d48-2-3x256-sc-cr300k_init.ckpt.data-00000-of-00001 \\\n    --train_logdir=${DEEPLAB}/datasets/basins/exp/train_on_train_set/train \\\n    --dataset_dir=${DEEPLAB}/datasets/basins\n```\n\n##### Evaluation script\nOnce the model has started training and has written some checkpoints then an evaluation \ncan be preformed using the [DeepLab evaluation script](https://github.com/tensorflow/models/blob/master/research/deeplab/eval.py). \nFor example:\n```bash\n$ cd ${TFMODELS}\n$ python deeplab/eval.py \\\n    --logtostderr \\\n    --eval_split=\"val\" \\\n    --model_variant=\"xception_65\" \\\n    --atrous_rates=6 \\\n    --atrous_rates=12 \\\n    --atrous_rates=18 \\\n    --output_stride=16 \\\n    --decoder_output_stride=4 \\\n    --eval_crop_size=\"513,513\" \\\n    --dataset=\"basins\" \\\n    --checkpoint_dir=${DEEPLAB}/datasets/basins/exp/train_on_train_set/train \\\n    --eval_logdir=${DEEPLAB}/datasets/basins/exp/train_on_train_set/eval \\\n    --dataset_dir=${DEEPLAB}/datasets/basins\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmonocongo%2Fsegment_deeplab","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmonocongo%2Fsegment_deeplab","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmonocongo%2Fsegment_deeplab/lists"}