Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.ipynb_checkpoints
notebooks/model_tests/*
91 changes: 91 additions & 0 deletions notebooks/Prediction_bayesian.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import tensorflow as tf\n",
"import nobrainer\n",
"from nobrainer.volume import standardize_numpy\n",
"import pandas as pd"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# image constants\n",
"block_shape=(128,128,128)\n",
"batch_size = 1"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Load sample dataset\n",
"csv_path = nobrainer.utils.get_data()\n",
"tmp = pd.read_csv(csv_path)\n",
"features = tmp['features'].tolist()\n",
"image_path = features[0]"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Load pre-trained model\n",
"model_path = \"/trained-models/neuronets/kwyk/0.4.1/all_50_bvwn_multi_prior/\"\n",
"model = tf.keras.models.load_model(model_path)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# predict\n",
"out,variance, entropy = nobrainer.prediction.predict_from_filepath(image_path,\n",
" model,\n",
" block_shape = (128,128,128),\n",
" batch_size = batch_size,\n",
" normalizer = standardize_numpy,\n",
" n_samples=2,\n",
" return_variance=True,\n",
" return_entropy=True,\n",
" )\n",
" "
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.3"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
87 changes: 87 additions & 0 deletions notebooks/Prediction_deterministic.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [],
"source": [
"import tensorflow as tf\n",
"import nobrainer\n",
"from nobrainer.volume import standardize_numpy\n",
"import pandas as pd"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [],
"source": [
"# Load sample dataset\n",
"csv_path = nobrainer.utils.get_data()\n",
"tmp = pd.read_csv(csv_path)\n",
"features = tmp['features'].tolist()\n",
"image_path = features[0]"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# image constants\n",
"block_shape=(128,128,128)\n",
"batch_size = 1"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Load pre-trained model\n",
"model_path = \"/trained-models/neuronets/brainy/0.1.0/brain-extraction-unet-128iso-model.h5\"\n",
"model = tf.keras.models.load_model(model_path)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# predict\n",
"out = nobrainer.prediction.predict_from_filepath(image_path, \n",
" model,\n",
" block_shape = (128,128,128),\n",
" batch_size = batch_size,\n",
" normalizer = standardize_numpy,\n",
" )"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.3"
}
},
"nbformat": 4,
"nbformat_minor": 2
}