-
Notifications
You must be signed in to change notification settings - Fork 20
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
added detectree example notebook #4
Conversation
Check out this pull request on See visual diffs & provide feedback on Jupyter Notebooks. Powered by ReviewNB |
|
Added code so forest-modelling-detectree-v2 will run on cpu |
View / edit / reply to this conversation on ReviewNB acocac commented on 2021-09-21T09:35:18Z Great description! I would add the hyperlink to Mask R-CNN and mention it's available through the detectron2 framework. shmh40 commented on 2021-09-23T09:29:43Z Added hyperlink |
View / edit / reply to this conversation on ReviewNB acocac commented on 2021-09-21T09:35:19Z There are some libraries that the notebook doesn't longer need and others I added for interactive plotting. I would suggest to replace the original cells of this section by the following ones:
Cell 1: ## install detectron2 !python -m pip install 'git+https://github.com/facebookresearch/detectron2.git'
Cell 2: import cv2 shmh40 commented on 2021-09-23T09:31:15Z Agreed |
View / edit / reply to this conversation on ReviewNB acocac commented on 2021-09-21T09:35:20Z remove
shmh40 commented on 2021-09-23T09:31:04Z Done |
View / edit / reply to this conversation on ReviewNB acocac commented on 2021-09-21T09:35:20Z remove shmh40 commented on 2021-09-23T09:31:27Z Done |
View / edit / reply to this conversation on ReviewNB acocac commented on 2021-09-21T09:35:21Z remove shmh40 commented on 2021-09-23T09:31:41Z Done |
View / edit / reply to this conversation on ReviewNB acocac commented on 2021-09-21T09:35:21Z remove shmh40 commented on 2021-09-23T09:31:54Z Done |
View / edit / reply to this conversation on ReviewNB acocac commented on 2021-09-21T09:35:22Z Before the Load data section, I would provide a sort of project folder structure (a python dictionary) into a new section Set Folder Structure. I provide the cell to add into this new suggestion.
# Define the project main folder data_folder = './detectree'
shmh40 commented on 2021-09-23T09:33:16Z Done - thank you |
View / edit / reply to this conversation on ReviewNB acocac commented on 2021-09-21T09:35:23Z remove as we install intake zenodo fetcher plugin in the Install and load libraries section. Note we don't need to install intake and intake-array as they're already available in environment.yml file of the Environmental AI book. |
View / edit / reply to this conversation on ReviewNB acocac commented on 2021-09-21T09:35:23Z remove as we are importing intake and intake zenodo in the Install and load libraries section. Also, we aren't longer using tempfile due to the proposed folder structure.
|
View / edit / reply to this conversation on ReviewNB acocac commented on 2021-09-21T09:35:24Z Line #1. # create a temp dir remove
shmh40 commented on 2021-09-23T09:58:22Z Done |
View / edit / reply to this conversation on ReviewNB acocac commented on 2021-09-21T09:35:25Z Line #2. path = tempfile.mkdtemp() remove |
View / edit / reply to this conversation on ReviewNB acocac commented on 2021-09-21T09:35:25Z Line #3. add
# write a catalog YAML file
shmh40 commented on 2021-09-23T09:58:13Z Done |
View / edit / reply to this conversation on ReviewNB acocac commented on 2021-09-21T09:35:26Z Line #4. catalog_file = os.path.join(path, 'catalog.yaml')
change:
catalog_file = os.path.join(data_folder, 'catalog.yaml') |
View / edit / reply to this conversation on ReviewNB acocac commented on 2021-09-21T09:35:26Z Line #15. urlpath: "{{ CATALOG_DIR }}/Sep_2014_RGB_602500_646600.tif"
change:
urlpath: "{{ CATALOG_DIR }}/input/tiff/Sep_2014_RGB_602500_646600.tif" |
View / edit / reply to this conversation on ReviewNB acocac commented on 2021-09-21T09:35:27Z Line #1. # let's investigate the data-array, what is the shape? Bounds? Bands? CRS?
move this text into the markdown of the subheading,
Let's investigate the
shmh40 commented on 2021-09-23T09:58:01Z Done |
View / edit / reply to this conversation on ReviewNB acocac commented on 2021-09-21T09:35:28Z add some additional text below the subsection heading, for example:
The Mask R-CNN requires images in shmh40 commented on 2021-09-23T09:57:54Z Done |
View / edit / reply to this conversation on ReviewNB acocac commented on 2021-09-21T09:35:28Z Line #15. cv2.imwrite('/home/jovyan/lustre_scratch/sepilok_data/spare_pngs/tile_'+str(minx)+'_'+str(miny)+'.png', rgb_rescaled)
change to: filepath = config['in_png'] + '/' + 'tile_' + str(minx) + '_' + str(miny) + '.png' shmh40 commented on 2021-09-23T09:57:47Z Done
|
View / edit / reply to this conversation on ReviewNB acocac commented on 2021-09-21T09:35:29Z Line #1. filepath = "/home/jovyan/lustre_scratch/sepilok_data/spare_pngs/tile_602500_646600.png" remove shmh40 commented on 2021-09-23T09:57:27Z Done |
View / edit / reply to this conversation on ReviewNB acocac commented on 2021-09-21T09:35:29Z Before this section, we can add a new subsection Download the pretrained model with the following cell:
# define the URL to retrieve the model fn = 'model_final.pth' url = f'https://zenodo.org/record/5515408/files/{fn}?download=1'
shmh40 commented on 2021-09-23T09:57:19Z Nice acocac commented on 2021-09-23T14:45:53Z (: |
View / edit / reply to this conversation on ReviewNB acocac commented on 2021-09-21T09:35:30Z Line #1. from detectron2.utils.visualizer import ColorMode remove |
View / edit / reply to this conversation on ReviewNB acocac commented on 2021-09-21T09:35:31Z Line #2. from detectron2.engine import DefaultTrainer remove |
View / edit / reply to this conversation on ReviewNB acocac commented on 2021-09-21T09:35:31Z Line #3. from detectron2.config import get_cfg remove |
View / edit / reply to this conversation on ReviewNB acocac commented on 2021-09-21T09:35:32Z Line #17. cfg.MODEL.WEIGHTS = '/home/jovyan/detectron2_live/train_test/output/model_final.pth'
change to:
cfg.MODEL.WEIGHTS = config['model'] + '/model_final.pth'
|
Done View entire conversation on ReviewNB |
v4 of the notebook now uploaded with desired changes and some minor amendments to mapping - added code to save the interactive map. |
It seems there are some version problems with recent pytorch and detectron2 installed via !python -m pip install 'git+https://github.com/facebookresearch/detectron2.git'. I would suggest to add an extra line above ## install detectron2:
# install pytorch !pip -q install torch==1.8.0 !pip -q install torchvision==0.9.0
View entire conversation on ReviewNB |
(: View entire conversation on ReviewNB |
View / edit / reply to this conversation on ReviewNB acocac commented on 2021-09-23T14:57:34Z It seems there are some version problems with recent pytorch and detectron2 installed via !python -m pip install 'git+https://github.com/facebookresearch/detectron2.git'. I would suggest to add an extra line above ## install detectron2:
# install pytorch !pip -q install torch==1.8.0 !pip -q install torchvision==0.9.0 shmh40 commented on 2021-10-09T11:58:10Z Done |
View / edit / reply to this conversation on ReviewNB acocac commented on 2021-09-23T14:57:34Z Line #10. plot_rgb = int_arr.astype('uint8').hvplot.rgb(
It might worth to investigate how you can change the info displayed in the hover.... can we add some info from the polygons e.g. probability? shmh40 commented on 2021-10-09T12:33:00Z Done! |
View / edit / reply to this conversation on ReviewNB acocac commented on 2021-09-23T14:57:35Z It might be a good to mention why you export as HTML and not PNG. For instance, you can say:
Let's export the combined map to a HTML file, this allows to keep the interactive plotting in a separate window. shmh40 commented on 2021-10-09T11:57:42Z Done |
@shmh40 thanks for implementing the suggestions. I just made a minor comments. |
Done View entire conversation on ReviewNB |
1 similar comment
Done View entire conversation on ReviewNB |
Made final changes, and added function to see confidence score in hvplot. Good to go! |
Done! View entire conversation on ReviewNB |
All changes complete! |
…ble and legend hover RGG image
…ptions, fix heading levels
Thanks @shmh40, it was great to have your contribution for the forest domain. I hope you learnt some useful python packages for handling geospatial datasets. I made some minor style adjustments to the notebook and now it's good to go (: |
To do: