Skip to content

Commit

Permalink
Merge pull request #16 from mantidproject/37527_deploy_cnn
Browse files Browse the repository at this point in the history
Update README.md with latest instructions
  • Loading branch information
RichardWaiteSTFC authored Sep 11, 2024
2 parents 65d82f6 + abc2353 commit b8a6a8d
Showing 1 changed file with 7 additions and 13 deletions.
20 changes: 7 additions & 13 deletions diffraction/WISH/bragg-detect/cnn/README.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,16 @@
Bragg Peaks detection using a Faster RCNN model
Bragg Peaks detection using a pre-trained Faster RCNN deep neural network
================

Inorder to use the pretrained Faster RCNN model inside mantid, below steps are required.
Inorder to use the pre-trained Faster RCNN model inside mantid using an IDAaaS instance, below steps are required.

* Install mantid from conda `mamba create -n mantid_cnn -c mantid mantidworkbench`
* Activate the conda environment with `mamba activate mantid_cnn`
* Launch workbench from `workbench` command
* Download the script repository's `scriptrepository\diffraction\WISH` directory as instructed here https://docs.mantidproject.org/nightly/workbench/scriptrepository.html
* Check whether `<local path>\diffraction\WISH` path is available at `Python Script Directories` tab from `File->Manage User Directories`.
* Close the workbench
* From command line, change the directory to the place where the scripts were downloaded ex: `<local path>\diffraction\WISH\bragg-detect\cnn`
* Within the same conda enviroment, install pytorch dependancies by running `pip install -r requirements.txt`
* Install NVIDIA CUDA Deep Neural Network library (cuDNN) by running `conda install -c anaconda cudnn`
* Re-launch workbench from `workbench` command
* Launch an IDAaaS instance with GPUs from WISH > Wish Single Crystal GPU Advanced
* Launch Mantid workbench nightly from Applications->Software->Mantid->Mantid Workbench Nightly
* Download `scriptrepository\diffraction\WISH` directory from mantid's script repository as instructed here https://docs.mantidproject.org/nightly/workbench/scriptrepository.html
* Check whether `<local path>\diffraction\WISH` path is listed under `Python Script Directories` tab from `File->Manage User Directories` of Mantid workbench.
* Below is an example code snippet to test the code. It will create a peaks workspace with the inferred peaks from the cnn and will do a peak filtering using the q_tol provided using `BaseSX.remove_duplicate_peaks_by_qlab`.
```python
from cnn.BraggDetectCNN import BraggDetectCNN
model_weights = r'path/to/pretrained/fasterrcnn_resnet50_model_weights.pt'
model_weights = r'/mnt/ceph/auxiliary/wish/BraggDetect_FasterRCNN_Resnet50_Weights_v1.pt'
cnn_peaks_detector = BraggDetectCNN(model_weights_path=model_weights, batch_size=64)
cnn_peaks_detector.find_bragg_peaks(workspace='WISH00042730', output_ws_name="CNN_Peaks", conf_threshold=0.0, q_tol=0.05)
```
Expand Down

0 comments on commit b8a6a8d

Please sign in to comment.