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"
},
"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",
"\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",
"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",
"\n",
"from glob import glob\n",
"import matplotlib\n",
"import matplotlib.pyplot as plt\n",
"import matplotlib.gridspec as gridspec\n",
"import numpy as np\n",
@@ -87,9 +87,9 @@
},
"outputs": [],
"source": [
"!git clone https://github.com/deepmind/deepmind-research.git .\n",
"!pip install ./hierarchical_prob_unet\n",
"from model import HierarchicalProbUNet"
"!git clone https://github.com/deepmind/deepmind-research.git deepmind_research\n",
"%cd deepmind_research/hierarchical_probabilistic_unet\n",
"from model import HierarchicalProbUNet\n"
]
},
{
@@ -112,8 +112,8 @@
},
"outputs": [],
"source": [
"!gsutil cp gs://hpunet_data/test/test.tar.gz /tmp/\n",
"!tar xvfz /tmp/test.tar.gz -C /tmp/test_data"
"!gsutil cp gs://hpunet-data/lidc_crops/test.tar.gz /tmp/\n",
"!tar xvfz /tmp/test.tar.gz -C /tmp/"
]
},
{
@@ -136,8 +136,8 @@
},
"outputs": [],
"source": [
"!gsutil cp gs://hpunet_data/model_weights/checkpoint.tar.gz /tmp/\n",
"!tar xvfz /tmp/checkpoint.tar.gz -C /tmp/checkpoint"
"!gsutil cp gs://hpunet-data/model_checkpoint/checkpoint.tar.gz /tmp/\n",
"!tar xvfz /tmp/checkpoint.tar.gz -C /tmp/"
]
},
{
@@ -153,7 +153,7 @@
"source": [
"#@title Utility to function to batch-up the data.\n",
"\n",
"test_img_dir = '/tmp/test_data'\n",
"test_img_dir = '/tmp/test'\n",
"\n",
"def make_batch(patient_ixs):\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",
" \"\"\"\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",
" # get the first image for the patient\n",
" img_path = glob(os.path.join(patient_dirs[i], '*'))[0]\n",
@@ -254,7 +254,7 @@
"saver = tf.train.Saver()\n",
"with tf.train.MonitoredTrainingSession() as sess:\n",
" # restore checkpoint\n",
" saver.restore(sess, '/tmp/checkpoint')\n",
" saver.restore(sess, '/tmp/checkpoint/tf_graph_data.ckpt')\n",
"\n",
" # sample from the full hierarchy\n",
" rec, s = sess.run([reconstruction, sample_full],\n",
+2 -2
View File
@@ -40,8 +40,8 @@ link to the colab.
## Installation
To install the package locally run:
```bash
git clone https://github.com/deepmind/hierarchical_prob_unet .
cd hierarchical_prob_unet
git clone https://github.com/deepmind/deepmind-research.git .
cd deepmind-research/hierarchical_probabilistic_unet
pip install -e .
```