Make colab notebook runnable.

PiperOrigin-RevId: 282560718
This commit is contained in:
Simon Kohl
2019-11-26 15:26:26 +00:00
committed by Diego de Las Casas
parent e5798e10d8
commit cef986bf9c
2 changed files with 14 additions and 14 deletions
+12 -12
View File
@@ -39,8 +39,7 @@
"id": "ntSZbVLBTzIC" "id": "ntSZbVLBTzIC"
}, },
"source": [ "source": [
"#Colab: [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/googlecolab/colabtools/blob/master/notebooks/colab-github-demo.ipynb)\n", "#Colab: [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/deepmind/deepmind-research/blob/master/hierarchical_probabilistic_unet/HPU_Net.ipynb)\n",
"\n",
"If you haven't already opened this notebook in colab, you can click the button above to open it there." "If you haven't already opened this notebook in colab, you can click the button above to open it there."
] ]
}, },
@@ -59,6 +58,7 @@
"!pip install dm-sonnet==1.35\n", "!pip install dm-sonnet==1.35\n",
"\n", "\n",
"from glob import glob\n", "from glob import glob\n",
"import matplotlib\n",
"import matplotlib.pyplot as plt\n", "import matplotlib.pyplot as plt\n",
"import matplotlib.gridspec as gridspec\n", "import matplotlib.gridspec as gridspec\n",
"import numpy as np\n", "import numpy as np\n",
@@ -87,9 +87,9 @@
}, },
"outputs": [], "outputs": [],
"source": [ "source": [
"!git clone https://github.com/deepmind/deepmind-research.git .\n", "!git clone https://github.com/deepmind/deepmind-research.git deepmind_research\n",
"!pip install ./hierarchical_prob_unet\n", "%cd deepmind_research/hierarchical_probabilistic_unet\n",
"from model import HierarchicalProbUNet" "from model import HierarchicalProbUNet\n"
] ]
}, },
{ {
@@ -112,8 +112,8 @@
}, },
"outputs": [], "outputs": [],
"source": [ "source": [
"!gsutil cp gs://hpunet_data/test/test.tar.gz /tmp/\n", "!gsutil cp gs://hpunet-data/lidc_crops/test.tar.gz /tmp/\n",
"!tar xvfz /tmp/test.tar.gz -C /tmp/test_data" "!tar xvfz /tmp/test.tar.gz -C /tmp/"
] ]
}, },
{ {
@@ -136,8 +136,8 @@
}, },
"outputs": [], "outputs": [],
"source": [ "source": [
"!gsutil cp gs://hpunet_data/model_weights/checkpoint.tar.gz /tmp/\n", "!gsutil cp gs://hpunet-data/model_checkpoint/checkpoint.tar.gz /tmp/\n",
"!tar xvfz /tmp/checkpoint.tar.gz -C /tmp/checkpoint" "!tar xvfz /tmp/checkpoint.tar.gz -C /tmp/"
] ]
}, },
{ {
@@ -153,7 +153,7 @@
"source": [ "source": [
"#@title Utility to function to batch-up the data.\n", "#@title Utility to function to batch-up the data.\n",
"\n", "\n",
"test_img_dir = '/tmp/test_data'\n", "test_img_dir = '/tmp/test'\n",
"\n", "\n",
"def make_batch(patient_ixs):\n", "def make_batch(patient_ixs):\n",
" \"\"\"Assembles a batch of the first image for each specified patient.\n", " \"\"\"Assembles a batch of the first image for each specified patient.\n",
@@ -164,7 +164,7 @@
" segmentations of shape (b, 128, 128, 4).\n", " segmentations of shape (b, 128, 128, 4).\n",
" \"\"\"\n", " \"\"\"\n",
" img, seg = [], []\n", " img, seg = [], []\n",
" patient_dirs = glob(os.path.join(test_img_dir, '*'))\n", " patient_dirs = glob(os.path.join(test_img_dir, 'images', '*'))\n",
" for i in patient_ixs:\n", " for i in patient_ixs:\n",
" # get the first image for the patient\n", " # get the first image for the patient\n",
" img_path = glob(os.path.join(patient_dirs[i], '*'))[0]\n", " img_path = glob(os.path.join(patient_dirs[i], '*'))[0]\n",
@@ -254,7 +254,7 @@
"saver = tf.train.Saver()\n", "saver = tf.train.Saver()\n",
"with tf.train.MonitoredTrainingSession() as sess:\n", "with tf.train.MonitoredTrainingSession() as sess:\n",
" # restore checkpoint\n", " # restore checkpoint\n",
" saver.restore(sess, '/tmp/checkpoint')\n", " saver.restore(sess, '/tmp/checkpoint/tf_graph_data.ckpt')\n",
"\n", "\n",
" # sample from the full hierarchy\n", " # sample from the full hierarchy\n",
" rec, s = sess.run([reconstruction, sample_full],\n", " rec, s = sess.run([reconstruction, sample_full],\n",
+2 -2
View File
@@ -40,8 +40,8 @@ link to the colab.
## Installation ## Installation
To install the package locally run: To install the package locally run:
```bash ```bash
git clone https://github.com/deepmind/hierarchical_prob_unet . git clone https://github.com/deepmind/deepmind-research.git .
cd hierarchical_prob_unet cd deepmind-research/hierarchical_probabilistic_unet
pip install -e . pip install -e .
``` ```