Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sami's Developpement #4

Open
wants to merge 152 commits into
base: Dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
152 commits
Select commit Hold shift + click to select a range
05bb833
Modified path to CONFIG from biom3d.configs.unet_default to biom3d.co…
SafarbatiSami Apr 18, 2023
6328037
Update README.md
SafarbatiSami Apr 19, 2023
62c716b
Merged Preprocessing Tab and Train tab.
SafarbatiSami Apr 19, 2023
14309eb
Merge branch 'main' of https://github.com/SafarbatiSami/biom3d into main
SafarbatiSami Apr 19, 2023
5423e0e
Added autoConfig in Preprocess_autoconfig() ;
SafarbatiSami Apr 19, 2023
2259dac
Merge remote-tracking branch 'upstream/main' into main
SafarbatiSami Apr 21, 2023
73a9e13
Changed dataType of aug_patch_size, patch_size, num_pools to Lists.
SafarbatiSami Apr 21, 2023
e4d69ab
Correction of train bug
SafarbatiSami Apr 24, 2023
54d0686
Modified Remote interface.
SafarbatiSami Apr 27, 2023
4d2707b
.
SafarbatiSami May 9, 2023
06e41ad
Merge branch 'main' of https://github.com/GuillaumeMougeot/biom3d int…
SafarbatiSami May 9, 2023
a627343
Added Parameters_return() function to Display config parameters.
SafarbatiSami May 10, 2023
98141f8
Changes in Remote functioning.
SafarbatiSami May 15, 2023
8c99ae7
Redefined dropdown Menus.
SafarbatiSami May 16, 2023
46cade7
Added Remote parameter.
SafarbatiSami May 16, 2023
536b7f9
Merge branch 'main' of https://github.com/GuillaumeMougeot/biom3d int…
SafarbatiSami May 16, 2023
7ffa3ce
added a popup message
SafarbatiSami Jun 2, 2023
308e464
Merge branch 'main' of https://github.com/GuillaumeMougeot/biom3d int…
SafarbatiSami Jun 2, 2023
abc363d
Merge branch 'main' of https://github.com/GuillaumeMougeot/biom3d int…
SafarbatiSami Jun 2, 2023
2a73681
Added fg_dir parameter
SafarbatiSami Jun 5, 2023
9cc40d3
Merge branch 'main' of https://github.com/GuillaumeMougeot/biom3d int…
SafarbatiSami Jun 5, 2023
295e86d
Merge branch 'main' of https://github.com/GuillaumeMougeot/biom3d int…
SafarbatiSami Jun 5, 2023
a41fde3
modified preprocess for remote
SafarbatiSami Jun 6, 2023
b4417de
correction for folder selection
SafarbatiSami Jun 6, 2023
954f64d
Changes for window size
SafarbatiSami Jun 7, 2023
9734cb4
correction for config path bug
SafarbatiSami Jun 7, 2023
9cb0d7a
train bugfix
SafarbatiSami Jun 7, 2023
49f8580
number of classes bugfix
SafarbatiSami Jun 7, 2023
b90174e
Changed save dir for configs
SafarbatiSami Jun 8, 2023
0c4cfba
changed save dir for configs
SafarbatiSami Jun 8, 2023
7a66ba1
Bugfix remote cfg load/save
SafarbatiSami Jun 9, 2023
372d898
File to generate the executbale file
SafarbatiSami Jun 16, 2023
4094949
Download prediction bugfix
SafarbatiSami Jun 16, 2023
08fcda4
correction popupmsg
SafarbatiSami Jun 16, 2023
5c52e12
Restricted access for local interface while using an executable
SafarbatiSami Jun 16, 2023
a1ad594
Modified Button positions
SafarbatiSami Jun 19, 2023
28992c6
Script to deploy an executable file for User interface
SafarbatiSami Jun 19, 2023
9e431fd
Correction for UI
SafarbatiSami Jun 20, 2023
ce1d571
Added Home button, modified positions for config parameters
SafarbatiSami Jun 20, 2023
094b743
Corrections for Gui
SafarbatiSami Jun 20, 2023
b5196a1
Merge branch 'main' of https://github.com/GuillaumeMougeot/biom3d int…
SafarbatiSami Jun 20, 2023
df29091
changed the way to get auto config results
SafarbatiSami Jun 21, 2023
51ce3a3
Code Cleaning
SafarbatiSami Jun 21, 2023
24e69c9
Module to upload predictions in OMERO
SafarbatiSami Jun 22, 2023
684ed46
improved Uploader
SafarbatiSami Jun 23, 2023
83aa459
Added option to send prediction to OMERO
SafarbatiSami Jun 23, 2023
c7fa9b3
Merge branch 'main' of https://github.com/GuillaumeMougeot/biom3d int…
SafarbatiSami Jun 23, 2023
0952279
improve Omero ulpoad
SafarbatiSami Jul 3, 2023
24877d2
Added loop to do all sub folders
SafarbatiSami Jul 5, 2023
017b161
update
SafarbatiSami Jul 20, 2023
35cf7f8
Removed CLI connection.
SafarbatiSami Jul 25, 2023
8594219
Updated Gui
SafarbatiSami Jul 25, 2023
b203812
update
SafarbatiSami Jul 25, 2023
cafd069
Merge branch 'main' of https://github.com/GuillaumeMougeot/biom3d int…
SafarbatiSami Jul 26, 2023
c523288
Merge branch 'main' of https://github.com/GuillaumeMougeot/biom3d int…
SafarbatiSami Jul 26, 2023
3845b38
Added project output id for omero
SafarbatiSami Jul 26, 2023
48b08c2
Added venv activation while using remote
SafarbatiSami Aug 7, 2023
8989cc4
train loss function plot (still working on it)
SafarbatiSami Aug 8, 2023
238d190
Added training curves
SafarbatiSami Aug 9, 2023
4491d00
updated learning curves
SafarbatiSami Aug 10, 2023
54e1fee
update
SafarbatiSami Aug 10, 2023
32ac5d9
Correction for leaning curves
SafarbatiSami Aug 11, 2023
7f194b0
changes in buttons size
SafarbatiSami Aug 14, 2023
3616305
Merge branch 'main' of https://github.com/GuillaumeMougeot/biom3d int…
SafarbatiSami Aug 14, 2023
2db9c69
Update for GUI
SafarbatiSami Aug 14, 2023
560aa99
update gui
SafarbatiSami Aug 16, 2023
5fa81cd
Merge branch 'main' of https://github.com/GuillaumeMougeot/biom3d int…
SafarbatiSami Aug 16, 2023
cd77277
blitz bugfix
SafarbatiSami Aug 16, 2023
0021bac
update gui
SafarbatiSami Aug 16, 2023
7da89c2
Merge branch 'main' of https://github.com/GuillaumeMougeot/biom3d int…
SafarbatiSami Aug 16, 2023
745a294
Merge branch 'main' of https://github.com/GuillaumeMougeot/biom3d int…
SafarbatiSami Aug 17, 2023
733d72c
Revert "Merge branch 'main' of https://github.com/GuillaumeMougeot/bi…
SafarbatiSami Aug 17, 2023
831f14c
Merge branch 'main' of https://github.com/GuillaumeMougeot/biom3d int…
SafarbatiSami Aug 18, 2023
a524bb3
dataset update bugfix
SafarbatiSami Aug 18, 2023
202050c
Final GUI (maybe)
SafarbatiSami Aug 18, 2023
5c4f783
Merge branch 'main' of https://github.com/GuillaumeMougeot/biom3d int…
SafarbatiSami Aug 18, 2023
db3255d
number of classes bugfix
SafarbatiSami Aug 18, 2023
290c259
plot bugfix
SafarbatiSami Aug 18, 2023
e7967ed
Learning curve Bugfix
SafarbatiSami Aug 18, 2023
2d67a74
Merge branch 'main' of https://github.com/SafarbatiSami/biom3d into main
SafarbatiSami Sep 8, 2023
53e6d5b
Added Objects filtering for prediction in GUI
SafarbatiSami Sep 11, 2023
56fafa9
Learning curves bufix
SafarbatiSami Sep 11, 2023
46099d8
Merge branch 'main' of https://github.com/GuillaumeMougeot/biom3d int…
SafarbatiSami Sep 11, 2023
adc9728
Added option to use a config file for training
SafarbatiSami Sep 13, 2023
d994745
Added function descriptions, added option to choose where to store l…
SafarbatiSami Sep 15, 2023
b4cc422
Code Cleaning, removed useless stuff
SafarbatiSami Sep 18, 2023
25a353c
Added some doc
SafarbatiSami Sep 19, 2023
af289fc
Error handling
SafarbatiSami Sep 20, 2023
e0d85a7
Added Ressources computing
SafarbatiSami Sep 21, 2023
ca8b053
Removed useless imports
SafarbatiSami Sep 22, 2023
1a80e74
modified import
SafarbatiSami Sep 22, 2023
c8f5097
Windows path Bugfix
SafarbatiSami Sep 25, 2023
d4cc139
Merge branch 'main' of https://github.com/GuillaumeMougeot/biom3d int…
SafarbatiSami Sep 25, 2023
2a8df11
error handling
SafarbatiSami Sep 25, 2023
0e9121f
text modification
SafarbatiSami Sep 26, 2023
7d234e1
text correction
SafarbatiSami Sep 26, 2023
bca58f7
text correction
SafarbatiSami Sep 26, 2023
54167f7
text correction
SafarbatiSami Sep 26, 2023
8226105
Added Fine tuning in local
SafarbatiSami Oct 2, 2023
9d34ae8
Added 3 display modes, added fine-tuning in local & remote
SafarbatiSami Oct 3, 2023
f4a73f9
Remote fine tuning update
SafarbatiSami Oct 4, 2023
bcebf96
classes bugfix, path bugfix
SafarbatiSami Oct 10, 2023
dbd7487
Merge branch 'main' of https://github.com/GuillaumeMougeot/biom3d int…
SafarbatiSami Oct 10, 2023
2f79d78
Corrections for Local Path
SafarbatiSami Oct 30, 2023
bf6a17a
updated gui
SafarbatiSami Dec 19, 2023
baa3735
Documentation( en cours)
SafarbatiSami Dec 20, 2023
e446ce5
Trainers documentation
SafarbatiSami Dec 20, 2023
12a300d
Predictors Documentation
SafarbatiSami Dec 20, 2023
591494d
Semseg_torchio Documentation
SafarbatiSami Dec 20, 2023
89820ac
Semseg_patch_fast Documentation
SafarbatiSami Dec 20, 2023
7ff6988
Semseg_Batchgen Documentation
SafarbatiSami Dec 20, 2023
67d0eff
Added browse button in splash screen
SafarbatiSami Dec 21, 2023
e5b5255
Added Biom3d logo to the Gui
SafarbatiSami Dec 21, 2023
44302bf
Adapted preprocessing for 2d images
SafarbatiSami Mar 21, 2024
78269d2
added doc
SafarbatiSami Mar 21, 2024
ee3bf77
Merge branch 'main' of https://github.com/GuillaumeMougeot/biom3d int…
SafarbatiSami Mar 21, 2024
b3ddcb6
version 0.0.38
GuillaumeMougeot Mar 27, 2024
cedc40b
implementation of 2d segmentation
SafarbatiSami Apr 12, 2024
d56cc6d
Merge branch 'main' of https://github.com/GuillaumeMougeot/biom3d int…
SafarbatiSami Apr 12, 2024
aec59e1
Bufix arborescence upload, added attachement file to omero upload
SafarbatiSami Apr 17, 2024
095650f
Inverted Z & T bugfix
SafarbatiSami Apr 26, 2024
09f77e6
Corrections for PR
SafarbatiSami Jun 13, 2024
409d7cc
corrected is2d to is_2d
SafarbatiSami Jun 17, 2024
733c482
Added Model as upload File in OMERO
SafarbatiSami Jun 19, 2024
2ff92b2
Data managment after OMERO prediction
SafarbatiSami Jun 19, 2024
9119cba
Module for training with OMERO data
SafarbatiSami Jun 19, 2024
a14f26d
Updated GUI ( Omero Training, Omero Pred ...)
SafarbatiSami Jun 19, 2024
e404288
latest tests
GuillaumeMougeot Jun 25, 2024
bccc3b3
preprocessing - minor fix for 4-dimensional masks
GuillaumeMougeot Jun 25, 2024
fca5e68
minor fix on preprocessing
GuillaumeMougeot Jun 25, 2024
b0684d7
Removed torch version in dependency for Colab.
GuillaumeMougeot Jun 28, 2024
3bc7acb
updated version in Colab
GuillaumeMougeot Jun 28, 2024
725aa85
added efficientUnet
GuillaumeMougeot Jul 5, 2024
acddb1d
added efficientUnet in register
GuillaumeMougeot Jul 5, 2024
11e0491
removed useless comments
GuillaumeMougeot Jul 5, 2024
cdd09f6
updated colab for torchio
GuillaumeMougeot Jul 8, 2024
76869bd
Omero connection with session id
SafarbatiSami Jul 8, 2024
3bd5b28
Merge branch 'main' of https://github.com/GuillaumeMougeot/biom3d int…
SafarbatiSami Jul 8, 2024
84ddbb5
updated Omero preprocess_train ( now uploads training images)
SafarbatiSami Jul 9, 2024
05b6ece
Added Omero upload after training in GUI
SafarbatiSami Jul 9, 2024
6e11ec3
num_worker to 1
SafarbatiSami Jul 11, 2024
c488dce
Changed num_workers to 8
SafarbatiSami Jul 15, 2024
bf1fa04
removed try catch for omero_uploader
SafarbatiSami Jul 17, 2024
1edd81f
changed num of workers back to 6
SafarbatiSami Jul 17, 2024
c26e351
removed useless import
SafarbatiSami Jul 17, 2024
8884ef9
Merge branch '2D_Segmentation' of https://github.com/SafarbatiSami/bi…
SafarbatiSami Jul 17, 2024
cacc806
Adapted omero uploader to use session id
SafarbatiSami Jul 18, 2024
4e052ed
Added File annotation download
SafarbatiSami Jul 22, 2024
ed9ef6d
Adapted omero uploader for omero_preprocess_train
SafarbatiSami Jul 22, 2024
80c1b5e
Added learning curves plot, Added autoconfig, train
SafarbatiSami Jul 22, 2024
295b099
Correction for omero session bug
SafarbatiSami Jul 23, 2024
e48bc68
Added prediction for omero_preprocess_train
SafarbatiSami Jul 25, 2024
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
7 changes: 7 additions & 0 deletions bash/deploy_win64.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@

# create a venv :
python -m venv NAME_OF_YOUR_VIRTUAL_ENV
# then install :
pip install pyinstaller python-tk numpy SimpleITK scikit-image tqdm paramiko pyyaml matplotlib
# run the pyinstaller (with console) and exclude modules
pyinstaller -F --clean --upx-dir PATH_TO_UPX PATH_TO_GUI\gui.py --exclude=biom3d --exclude=torch --hidden-import='PIL._tkinter_finder'
19 changes: 12 additions & 7 deletions bash/run_eval.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,21 @@
# --dir_lab data/msd/Task07_Pancreas/labelsTr_test\
# --num_classes 2

# python -m biom3d.eval\
# --dir_pred data/btcv/Testing_small/preds/20230522-182916-unet_default\
# --dir_lab data/btcv/Testing_small/label\
# --num_classes 13

python -m biom3d.eval\
--dir_pred data/nucleus/official/test/preds/20230908-202124-nucleus_official_fold4\
--dir_lab data/nucleus/official/test/msk\
--dir_pred data/msd/Task06_Lung/preds/20230531-092023-unet_lung\
--dir_lab data/msd/Task06_Lung/labelsTr_test\
--num_classes 1

# python -m biom3d.eval\
# --dir_pred data/msd/Task07_Pancreas/preds/20230523-105736-unet_default\
# --dir_lab data/msd/Task07_Pancreas/labelsTr_test\
# --num_classes 2

# python -m biom3d.eval\
# --dir_pred data/nucleus/official/test/preds/20230908-202124-nucleus_official_fold4\
# --dir_lab data/nucleus/official/test/msk\
# --num_classes 1

# python -m biom3d.eval\
# --dir_pred data/mito/test/pred/20230203-091249-unet_mito\
# --dir_lab data/mito/test/msk\
Expand Down
23 changes: 15 additions & 8 deletions bash/run_pred.sh
Original file line number Diff line number Diff line change
Expand Up @@ -112,18 +112,25 @@
# --dir_in "data/nucleus/aline_bug/img"\
# --dir_out "data/nucleus/aline_bug/preds"

# python -m biom3d.pred\
# --name seg\
# --log logs/20240219-100225-reims_full_fold0\
# --dir_in data/reims/big_stack/img\
# --dir_out data/reims/big_stack/preds\

python -m biom3d.pred\
--name seg\
--log logs/20240219-100225-reims_full_fold0\
--dir_in data/reims/big_stack/img\
--dir_out data/reims/big_stack/preds\
--name seg_eval\
--log logs/20240319-094430-reims_large_full_no47_fold0\
--dir_in data/reims/large/test/img\
--dir_out data/reims/large/test/preds\
--dir_lab data/reims/large/test/msk

# python -m biom3d.pred\
# --name seg_eval\
# --log logs/20240218-072550-reims_fold0\
# --dir_in data/reims/test_match/img\
# --dir_out data/reims/test_match/preds\
# --dir_lab data/reims/test_match/msk
# --log logs/20230501-153638-unet_default\
# --dir_in data/mito/test/img\
# --dir_out data/mito/test/pred\
# --dir_lab data/mito/test/msk

# python -m biom3d.pred\
# --name seg_single\
Expand Down
Binary file added docs/_static/image/gui_remote_predict.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/_static/image/gui_remote_predict_omero.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed docs/_static/image/gui_remote_train.PNG
Binary file not shown.
Binary file added docs/_static/image/gui_remote_train.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/_static/image/gui_splash.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion docs/biom3d_colab.ipynb
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"cells":[{"cell_type":"code","execution_count":null,"metadata":{"cellView":"form","id":"P8jnH3QZH9L4"},"outputs":[],"source":["#@markdown ## First check that your Runtime is in GPU mode (you can run this cell to do so)\n","\n","#@markdown If not, go to `Runtime` > `Change runtime type` > `Hardware accelerator` > `GPU`\n","\n","!nvidia-smi"]},{"cell_type":"code","execution_count":null,"metadata":{"cellView":"form","id":"NhwL5qt9fdg5"},"outputs":[],"source":["#@markdown ##Install Biom3d and import the necessary Python library\n","!pip3 install biom3d==0.0.31\n","\n","import os\n","import biom3d\n","from biom3d.train import train\n","from biom3d.pred import pred\n","from biom3d.eval import eval"]},{"cell_type":"code","execution_count":null,"metadata":{"cellView":"form","id":"Relk7WNAkTzM"},"outputs":[],"source":["#@markdown ##Mount your Google drive\n","\n","from google.colab import drive\n","drive.mount('/content/gdrive')"]},{"cell_type":"code","execution_count":null,"metadata":{"cellView":"form","id":"3RPq3yPxlNmj"},"outputs":[],"source":["#@markdown ## Define input and output folders\n","\n","#@markdown **Where training data will be saved?** This will include two folders: the config folder (containing configuration files) and the logs folder (containing the model folders)\n","\n","biom3d_dir = '/content/gdrive/MyDrive/biom3d'#@param {type:\"string\"}\n","model_name = \"unet_default\" #@param {type:\"string\"}\n","\n","#@markdown **Where are your images and masks?**\n","img_dir = \"\" #@param {type:\"string\"}\n","msk_dir = \"\" #@param {type:\"string\"}\n","\n","#@markdown **How many classes are there in your annotations?**\n","\n","num_classes = 1 #@param {type:\"number\"}\n","\n","#@markdown **How long would you like to train your model?**\n","num_epochs = 2 #@param {type:\"number\"}"]},{"cell_type":"code","execution_count":null,"metadata":{"cellView":"form","id":"EkLs_MoFtnLv"},"outputs":[],"source":["#@markdown ## Preprocess your data before training\n","config_path = biom3d.preprocess.auto_config_preprocess(\n"," img_dir=img_dir,\n"," msk_dir=msk_dir,\n"," num_classes=num_classes,\n"," desc=model_name,\n"," config_dir=os.path.join(biom3d_dir, \"configs/\"),\n"," base_config=None,\n"," ct_norm=False,\n"," num_epochs=num_epochs,\n"," logs_dir=os.path.join(biom3d_dir, \"logs/\"),\n",")"]},{"cell_type":"code","execution_count":null,"metadata":{"cellView":"form","id":"fn639Efzrfwe"},"outputs":[],"source":["#@markdown ## Start the training\n","\n","#@markdown If you want to use of different configuration file or use an existing one, complete the following field. **Leave this field empty if you want to use the config file obtained during the preprocessing.**\n","\n","custom_config_path = \"\" #@param {type:\"string\"}\n","\n","if len(custom_config_path) > 0:\n"," config_path = custom_config_path\n","\n","print(\"We will the following configuration file for training:\", config_path)\n","builder = train(config=config_path)"]},{"cell_type":"code","execution_count":null,"metadata":{"cellView":"form","id":"4eKiLPQnsokH"},"outputs":[],"source":["#@markdown ## Make predictions with your trained model\n","\n","#@markdown **Path to the model folder: leave it empty if you want to use the model obtained during the previous training step.** This should look like `/content/gdrive/MyDrive/biom3d/logs/20230602-162331-unet_default_fold0`.\n","\n","custom_log_path = \"\" #@param {type:\"string\"}\n","\n","if len(custom_log_path) > 0:\n"," log=custom_log_path\n","else:\n"," assert 'builder' in locals().keys(), \"No existing model folder found. Please complete the `custom_log_path` field or train a model.\"\n"," log = builder.base_dir\n","\n","#@markdown **Prediction input directory:**\n","pred_dir_in = \"\" #@param {type:\"string\"}\n","\n","#@markdown **Prediction output directory:** (where the prediction masks will be stored)\n","pred_dir_out = \"\"#@param {type:\"string\"}\n","\n","dir_out = pred(\n"," log=log,\n"," dir_in=pred_dir_in,\n"," dir_out=pred_dir_out\n"," )\n"]},{"cell_type":"code","execution_count":null,"metadata":{"cellView":"form","id":"8l8FPDb_13iI"},"outputs":[],"source":["#@markdown ## Evaluate your model on a test set\n","\n","#@markdown **Prediction output directory:** where the previous prediction masks have been stored and the number of classes in your images. Leave the default values if you want to use the previous prediction path.\n","new_pred_dir_out = \"\"#@param {type:\"string\"}\n","new_num_classes = 0 #@param {type:\"number\"}\n","\n","if new_num_classes == 0:\n"," assert 'num_classes' in locals().keys(), \"Number of classes equal to zero and the previous number of classes does not exist. Please provide one.\"\n"," new_num_classes = num_classes\n","\n","if len(new_pred_dir_out) == 0:\n"," assert len(dir_out) > 0, \"Prediction path seems to be empty and no previous path detected.\"\n"," new_pred_dir_out = dir_out\n","\n","#@markdown **Path to test masks** The test masks must correspond to the predictions.\n","test_msk_dir = \"\" #@param {type:\"string\"}\n","\n","eval(\n"," dir_lab=test_msk_dir,\n"," dir_out=new_pred_dir_out,\n"," num_classes=new_num_classes\n",")"]}],"metadata":{"accelerator":"GPU","colab":{"authorship_tag":"ABX9TyPrfgBkQIScxLMN00pfvqBQ","gpuType":"T4","provenance":[]},"kernelspec":{"display_name":"Python 3","name":"python3"},"language_info":{"name":"python"}},"nbformat":4,"nbformat_minor":0}
{"cells":[{"cell_type":"code","execution_count":null,"metadata":{"cellView":"form","id":"P8jnH3QZH9L4"},"outputs":[],"source":["#@markdown ## First check that your Runtime is in GPU mode (you can run this cell to do so)\n","\n","#@markdown If not, go to `Runtime` > `Change runtime type` > `Hardware accelerator` > `GPU`\n","\n","!nvidia-smi"]},{"cell_type":"code","execution_count":null,"metadata":{"cellView":"form","id":"NhwL5qt9fdg5"},"outputs":[],"source":["#@markdown ##Install Biom3d and import the necessary Python library\n","!pip3 install biom3d==0.0.40 torchio deprecated --no-deps\n","!pip3 install SimpleITK paramiko netcat appdirs\n","\n","import os\n","import biom3d\n","from biom3d.train import train\n","from biom3d.pred import pred\n","from biom3d.eval import eval"]},{"cell_type":"code","execution_count":null,"metadata":{"cellView":"form","id":"Relk7WNAkTzM"},"outputs":[],"source":["#@markdown ##Mount your Google drive\n","\n","from google.colab import drive\n","drive.mount('/content/gdrive')"]},{"cell_type":"code","execution_count":null,"metadata":{"cellView":"form","id":"3RPq3yPxlNmj"},"outputs":[],"source":["#@markdown ## Define input and output folders\n","\n","#@markdown **Where training data will be saved?** This will include two folders: the config folder (containing configuration files) and the logs folder (containing the model folders)\n","\n","biom3d_dir = '/content/gdrive/MyDrive/biom3d'#@param {type:\"string\"}\n","model_name = \"unet_default\" #@param {type:\"string\"}\n","\n","#@markdown **Where are your images and masks?**\n","img_dir = \"\" #@param {type:\"string\"}\n","msk_dir = \"\" #@param {type:\"string\"}\n","\n","#@markdown **How many classes are there in your annotations?**\n","\n","num_classes = 1 #@param {type:\"number\"}\n","\n","#@markdown **How long would you like to train your model?**\n","num_epochs = 2 #@param {type:\"number\"}"]},{"cell_type":"code","execution_count":null,"metadata":{"cellView":"form","id":"EkLs_MoFtnLv"},"outputs":[],"source":["#@markdown ## Preprocess your data before training\n","config_path = biom3d.preprocess.auto_config_preprocess(\n"," img_dir=img_dir,\n"," msk_dir=msk_dir,\n"," num_classes=num_classes,\n"," desc=model_name,\n"," config_dir=os.path.join(biom3d_dir, \"configs/\"),\n"," base_config=None,\n"," ct_norm=False,\n"," num_epochs=num_epochs,\n"," logs_dir=os.path.join(biom3d_dir, \"logs/\"),\n",")"]},{"cell_type":"code","execution_count":null,"metadata":{"cellView":"form","id":"fn639Efzrfwe"},"outputs":[],"source":["#@markdown ## Start the training\n","\n","#@markdown If you want to use of different configuration file or use an existing one, complete the following field. **Leave this field empty if you want to use the config file obtained during the preprocessing.**\n","\n","custom_config_path = \"\" #@param {type:\"string\"}\n","\n","if len(custom_config_path) > 0:\n"," config_path = custom_config_path\n","\n","print(\"We will the following configuration file for training:\", config_path)\n","builder = train(config=config_path)"]},{"cell_type":"code","execution_count":null,"metadata":{"cellView":"form","id":"4eKiLPQnsokH"},"outputs":[],"source":["#@markdown ## Make predictions with your trained model\n","\n","#@markdown **Path to the model folder: leave it empty if you want to use the model obtained during the previous training step.** This should look like `/content/gdrive/MyDrive/biom3d/logs/20230602-162331-unet_default_fold0`.\n","\n","custom_log_path = \"\" #@param {type:\"string\"}\n","\n","if len(custom_log_path) > 0:\n"," log=custom_log_path\n","else:\n"," assert 'builder' in locals().keys(), \"No existing model folder found. Please complete the `custom_log_path` field or train a model.\"\n"," log = builder.base_dir\n","\n","#@markdown **Prediction input directory:**\n","pred_dir_in = \"\" #@param {type:\"string\"}\n","\n","#@markdown **Prediction output directory:** (where the prediction masks will be stored)\n","pred_dir_out = \"\"#@param {type:\"string\"}\n","\n","dir_out = pred(\n"," log=log,\n"," dir_in=pred_dir_in,\n"," dir_out=pred_dir_out\n"," )\n"]},{"cell_type":"code","execution_count":null,"metadata":{"cellView":"form","id":"8l8FPDb_13iI"},"outputs":[],"source":["#@markdown ## Evaluate your model on a test set\n","\n","#@markdown **Prediction output directory:** where the previous prediction masks have been stored and the number of classes in your images. Leave the default values if you want to use the previous prediction path.\n","new_pred_dir_out = \"\"#@param {type:\"string\"}\n","new_num_classes = 0 #@param {type:\"number\"}\n","\n","if new_num_classes == 0:\n"," assert 'num_classes' in locals().keys(), \"Number of classes equal to zero and the previous number of classes does not exist. Please provide one.\"\n"," new_num_classes = num_classes\n","\n","if len(new_pred_dir_out) == 0:\n"," assert len(dir_out) > 0, \"Prediction path seems to be empty and no previous path detected.\"\n"," new_pred_dir_out = dir_out\n","\n","#@markdown **Path to test masks** The test masks must correspond to the predictions.\n","test_msk_dir = \"\" #@param {type:\"string\"}\n","\n","eval(\n"," dir_lab=test_msk_dir,\n"," dir_out=new_pred_dir_out,\n"," num_classes=new_num_classes\n",")"]}],"metadata":{"accelerator":"GPU","colab":{"authorship_tag":"ABX9TyPrfgBkQIScxLMN00pfvqBQ","gpuType":"T4","provenance":[]},"kernelspec":{"display_name":"Python 3","name":"python3"},"language_info":{"name":"python"}},"nbformat":4,"nbformat_minor":0}
4 changes: 4 additions & 0 deletions docs/quick_run_gui.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@ Biom3d comes with 2 modes: local or remote. 'Local' means that the computation w

If you have installed biom3d with the local version simply click on the 'Start locally' button to start, you can choose a path to store your files in the field over the button, by default, the files are stored in the directory where biom3d have been launched.

<<<<<<< HEAD
If you have installed biom3d with the remote version, you must then complete the required fields. The first one is the IP address of your remote computer (where the API of biom3d is installed). The second and third one is your user name and password to connect to the remote computer, the forth one is the path to your virtual environment (if you don't have a virtual environment leave it empty ).
=======
If you have installed biom3d with the remote version, you must then complete the required fields. The first one is the IP address of your remote computer (where the API of biom3d is installed). The second and third one is your user name and password to connect to the remote computer, the forth one is the path to your virtual environment (if you don't have a virtual environment leave it empty).
>>>>>>> f562750641a74b960ed698e427ed811313552d0e


## Preprocess & Train
Expand Down
Binary file added logo_biom3d_crop.ico
Binary file not shown.
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "biom3d"
version = "0.0.37"
version = "0.0.40"
authors = [
{name="Guillaume Mougeot", email="guillaume.mougeot@laposte.net"},
]
Expand All @@ -17,7 +17,7 @@ classifiers = [
"Operating System :: OS Independent",
]
dependencies = [
"torch>1.10.0",
"torch",
"tqdm>=4.62.3",
"scikit-image>=0.14",
"scipy>=1.9.1",
Expand Down
Loading