-
-
Notifications
You must be signed in to change notification settings - Fork 256
Add CheXlocalize_Dataset for CheXpert official val/test + segmentation masks #191
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
Open
AmlanMishra2004
wants to merge
11
commits into
mlmed:main
Choose a base branch
from
AmlanMishra2004:add-chexlocalize-dataset
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+452
−3
Open
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
a937d2a
Add CheXlocalize_Dataset for CheXpert official val/test + segmentatio…
AmlanMishra2004 879db0a
Align CheXlocalize mask dict with other loaders, document annotation …
AmlanMishra2004 29e8dc3
Stop fabricating AP/PA=AP for blinded CheXlocalize test set, use UNKNOWN
AmlanMishra2004 79f2ca4
Add usage example to CheXlocalize_Dataset docstring
AmlanMishra2004 fdd9580
Add demo notebook for CheXlocalize_Dataset pathology masks
AmlanMishra2004 a9caf8b
Decode CheXlocalize COCO RLE masks without pycocotools.
AmlanMishra2004 5544966
Revert "Decode CheXlocalize COCO RLE masks without pycocotools."
AmlanMishra2004 3251914
Match AP/PA unknown sentinel casing to other fields ("Unknown")
AmlanMishra2004 7d67900
Default pathology_masks=True for CheXlocalize_Dataset
AmlanMishra2004 6b04d00
Update chexlocalize tests for Unknown casing and pathology_masks default
AmlanMishra2004 d284087
Disable pathology_masks in blinded_test_csv test to match CI deps
AmlanMishra2004 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,117 @@ | ||
| { | ||
| "cells": [ | ||
| { | ||
| "cell_type": "code", | ||
| "execution_count": null, | ||
| "metadata": {}, | ||
| "outputs": [], | ||
| "source": [ | ||
| "%load_ext autoreload\n", | ||
| "%autoreload 2" | ||
| ] | ||
| }, | ||
| { | ||
| "cell_type": "code", | ||
| "execution_count": null, | ||
| "metadata": {}, | ||
| "outputs": [], | ||
| "source": [ | ||
| "import os,sys\n", | ||
| "sys.path.insert(0,\"..\")\n", | ||
| "import numpy as np\n", | ||
| "import pandas as pd\n", | ||
| "import matplotlib.pyplot as plt" | ||
| ] | ||
| }, | ||
| { | ||
| "cell_type": "code", | ||
| "execution_count": null, | ||
| "metadata": {}, | ||
| "outputs": [], | ||
| "source": [ | ||
| "import torchxrayvision as xrv" | ||
| ] | ||
| }, | ||
| { | ||
| "cell_type": "markdown", | ||
| "metadata": {}, | ||
| "source": [ | ||
| "`CheXlocalize_Dataset` follows the same `pathology_masks` interface as `NIH_Dataset`, `VinBrain_Dataset`, and `SIIM_Pneumothorax_Dataset`: `sample[\"pathology_masks\"]` is a sparse dict keyed by pathology index, each value a `(1, H, W)` array." | ||
| ] | ||
| }, | ||
| { | ||
| "cell_type": "code", | ||
| "execution_count": null, | ||
| "metadata": {}, | ||
| "outputs": [], | ||
| "source": [ | ||
| "dataset_path = \"/home/groups/akshaysc/joecohen/CheXpert\"" | ||
| ] | ||
| }, | ||
| { | ||
| "cell_type": "code", | ||
| "execution_count": null, | ||
| "metadata": {}, | ||
| "outputs": [], | ||
| "source": [ | ||
| "def plot_sample_with_masks(sample, df):\n", | ||
| " width = len(sample[\"pathology_masks\"])\n", | ||
| " fig, axs = plt.subplots(1, max(2,1+width), sharey=True, figsize=(3+3*width,3))\n", | ||
| " axs[0].imshow(sample[\"img\"][0], cmap=\"Greys_r\");\n", | ||
| " axs[0].set_title(\"idx:\" + str(sample[\"idx\"]))\n", | ||
| " for i, patho in enumerate(sample[\"pathology_masks\"].keys()):\n", | ||
| " axs[i+1].imshow(sample[\"img\"][0], cmap=\"Greys_r\");\n", | ||
| " axs[i+1].imshow(sample[\"pathology_masks\"][patho][0]+1, alpha=0.5);\n", | ||
| " axs[i+1].set_title(df.pathologies[patho])\n", | ||
| " plt.show()" | ||
| ] | ||
| }, | ||
| { | ||
| "cell_type": "code", | ||
| "execution_count": null, | ||
| "metadata": {}, | ||
| "outputs": [], | ||
| "source": [ | ||
| "d_chexlocalize = xrv.datasets.CheXlocalize_Dataset(\n", | ||
| " imgpath=os.path.join(dataset_path, \"CheXpert-v1.0/test\"),\n", | ||
| " csvpath=os.path.join(dataset_path, \"test_labels.csv\"),\n", | ||
| " pathology_masks=True,\n", | ||
| " segmentation_jsonpath=os.path.join(dataset_path, \"gt_segmentations_test.json\"))" | ||
| ] | ||
| }, | ||
| { | ||
| "cell_type": "code", | ||
| "execution_count": null, | ||
| "metadata": {}, | ||
| "outputs": [], | ||
| "source": [ | ||
| "d_chexlocalize.csv.has_masks.value_counts()" | ||
| ] | ||
| }, | ||
| { | ||
| "cell_type": "code", | ||
| "execution_count": null, | ||
| "metadata": {}, | ||
| "outputs": [], | ||
| "source": [ | ||
| "for idx in np.where(d_chexlocalize.csv.has_masks)[0][:5]:\n", | ||
| " sample = d_chexlocalize[idx]\n", | ||
| " if len(sample[\"pathology_masks\"]) > 0:\n", | ||
| " plot_sample_with_masks(sample, d_chexlocalize)" | ||
| ] | ||
| } | ||
| ], | ||
| "metadata": { | ||
| "kernelspec": { | ||
| "display_name": "Python 3", | ||
| "language": "python", | ||
| "name": "python3" | ||
| }, | ||
| "language_info": { | ||
| "name": "python", | ||
| "version": "3" | ||
| } | ||
| }, | ||
| "nbformat": 4, | ||
| "nbformat_minor": 5 | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I left a comment to run the notebook and include the images but that may be an issue with the license so disregard it.