Skip to content

Add blood vessel dataset processing script #184

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Oct 18, 2020
Merged

Add blood vessel dataset processing script #184

merged 10 commits into from
Oct 18, 2020

Conversation

yamengxi
Copy link
Collaborator

@yamengxi yamengxi commented Oct 9, 2020

No description provided.

@codecov
Copy link

codecov bot commented Oct 9, 2020

Codecov Report

Merging #184 into master will decrease coverage by 0.11%.
The diff coverage is 77.77%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #184      +/-   ##
==========================================
- Coverage   83.32%   83.20%   -0.12%     
==========================================
  Files          83       83              
  Lines        3921     3924       +3     
  Branches      617      619       +2     
==========================================
- Hits         3267     3265       -2     
- Misses        520      522       +2     
- Partials      134      137       +3     
Flag Coverage Δ
#unittests 83.20% <77.77%> (-0.12%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
mmseg/datasets/custom.py 85.88% <75.00%> (-0.99%) ⬇️
mmseg/version.py 58.33% <100.00%> (ø)
mmseg/datasets/pipelines/transforms.py 96.28% <0.00%> (-1.24%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f705071...3f35e25. Read the comment docs.

osp.join(out_dir, 'images', 'validation',
osp.splitext(img_name)[0] + '.jpg'), img)

now_dir = osp.join(tmp_dir, 'test', '1st_manual')
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now, there is no '1st_manual' in the test dataset.


### DRIVE

The training and validation set of DRIVE could be download from [here](https://drive.grand-challenge.org/). Before that, you should registrate an account.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now, there is no '1st_manual' in the test dataset.

To convert STARE dataset to mmsegmentation format, you should run the following command:

```shell
python tools/convert_datasets/hrf.py ~/stare-images.tar ~/labels-ah.tar ~/labels-vk.tar
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be stair.py?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah......yes, I will fix it.

Comment on lines 63 to 64
osp.splitext(img_name)[0] + '.jpg'),
img[:, :, 0] // 128)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add comments about //128.

Comment on lines +33 to +34
mmcv.mkdir_or_exist(out_dir)
mmcv.mkdir_or_exist(osp.join(out_dir, 'images'))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are not necessary.
The deepest level mkdir will automatically create them.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know that, I write this to make the code easy to understand.

To convert HRF dataset to mmsegmentation format, you should run the following command:

```shell
python tools/convert_datasets/hrf.py ~/healthy.zip ~/healthy_manualsegm.zip ~/glaucoma.zip ~/glaucoma_manualsegm.zip ~/diabetic_retinopathy.zip ~/diabetic_retinopathy_manualsegm.zip
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We may omit ~. We may use /path/to/healthy.zip instead.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK


### DRIVE

The training and validation set of DRIVE could be download from [here](https://drive.grand-challenge.org/). Before that, you should registrate an account. Now, there is no '1st_manual' in the test dataset, if you need it, please search for it by yourself, we do not provide links to download.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
The training and validation set of DRIVE could be download from [here](https://drive.grand-challenge.org/). Before that, you should registrate an account. Now, there is no '1st_manual' in the test dataset, if you need it, please search for it by yourself, we do not provide links to download.
The training and validation set of DRIVE could be download from [here](https://drive.grand-challenge.org/). Before that, you should register an account. Currently '1st_manual' is not provided officially.

osp.join(out_dir, 'annotations', 'validation',
osp.splitext(filename)[0] + '.jpg'),
img[:, :, 0] // 128)
shutil.rmtree(tmp_dir)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add comments about 128.


for filename in sorted(os.listdir(osp.join(tmp_dir, 'files')))[10:]:
img = cv2.imread(osp.join(tmp_dir, 'files', filename))
cv2.imwrite(
Copy link
Collaborator

@xvjiarui xvjiarui Oct 15, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For all cv2.imwrite, we may replace them with mmcv.imwrite, which could also automatically create a directory.

mmcv.mkdir_or_exist(osp.join(out_dir, 'annotations', 'training'))
mmcv.mkdir_or_exist(osp.join(out_dir, 'annotations', 'validation'))

tmp_dir = osp.join(out_dir, 'tmp')
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest using system tmp instead of hard code 'tmp'. On the other hand, we may add an argument so that user could specify their own tmpdir.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the "system tmp"?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You may refer to the doc here.
You may also take a look at this function for reference.

mmcv.mkdir_or_exist(tmp_dir)
zip_file = zipfile.ZipFile(now_path)
zip_file.extractall(tmp_dir)
for filename in sorted(os.listdir(tmp_dir))[:5]:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Direct truncate 5 here is not very safe. We may have some check and assert.

zip_file = zipfile.ZipFile(now_path)
zip_file.extractall(tmp_dir)
for filename in sorted(os.listdir(tmp_dir))[:5]:
img = cv2.imread(osp.join(tmp_dir, filename))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mmcv.imread


The training and validation set of CHASE DB1 could be download from [here](https://staffnet.kingston.ac.uk/~ku15565/CHASE_DB1/assets/CHASEDB1.zip).

To convert CHASE DB1 dataset to mmsegmentation format, you should run the following command:
Copy link
Collaborator

@xvjiarui xvjiarui Oct 17, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
To convert CHASE DB1 dataset to mmsegmentation format, you should run the following command:
To convert CHASE DB1 dataset to MMSegmentation format, you should run the following command:

assert len(os.listdir(tmp_dir)) == HRF_LEN, \
'len(os.listdir(tmp_dir)) != {}'.format(HRF_LEN)

for filename in sorted(os.listdir(tmp_dir))[:5]:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hard code in script is not ideal. We may add a variable at top like here

@xvjiarui xvjiarui merged commit cb2e0d3 into open-mmlab:master Oct 18, 2020
bowenroom pushed a commit to bowenroom/mmsegmentation that referenced this pull request Feb 25, 2022
* Add blood vessel dataset processing script

* Fix syntax error

* Fix syntax error

* Fix syntax error

* Fix bugs

* Fix bugs

* Fix bugs

* Use safe functions and expand more apis

* Use safe functions and expand more apis

* Fix hard code and verify dataset integrity
wjkim81 pushed a commit to wjkim81/mmsegmentation that referenced this pull request Dec 3, 2023
michaelzhang-ai pushed a commit to michaelzhang-ai/mmsegmentation that referenced this pull request Mar 22, 2024
michaelzhang-ai pushed a commit to michaelzhang-ai/mmsegmentation that referenced this pull request Mar 22, 2024
* val

* modify average_clips

* support multi-batch

* update

* update docs

* add changelog
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants