mirror of
https://github.com/google-deepmind/deepmind-research.git
synced 2026-05-09 21:07:49 +08:00
Make colab notebook runnable.
PiperOrigin-RevId: 282560718
This commit is contained in:
committed by
Diego de Las Casas
parent
e5798e10d8
commit
cef986bf9c
@@ -39,8 +39,7 @@
|
||||
"id": "ntSZbVLBTzIC"
|
||||
},
|
||||
"source": [
|
||||
"#Colab: [](https://colab.research.google.com/github/googlecolab/colabtools/blob/master/notebooks/colab-github-demo.ipynb)\n",
|
||||
"\n",
|
||||
"#Colab: [](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",
|
||||
|
||||
@@ -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 .
|
||||
```
|
||||
|
||||
|
||||
Reference in New Issue
Block a user