diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..f8634ec --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +.ipynb_checkpoints +notebooks/model_tests/* diff --git a/notebooks/Prediction_bayesian.ipynb b/notebooks/Prediction_bayesian.ipynb new file mode 100644 index 0000000..26ba65a --- /dev/null +++ b/notebooks/Prediction_bayesian.ipynb @@ -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 +} diff --git a/notebooks/Prediction_deterministic.ipynb b/notebooks/Prediction_deterministic.ipynb new file mode 100644 index 0000000..c8738f8 --- /dev/null +++ b/notebooks/Prediction_deterministic.ipynb @@ -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 +}