From 3a8e2c437b85ac00ba671b2ea8d4313c0bda3d38 Mon Sep 17 00:00:00 2001 From: Millicent Harding Date: Wed, 28 Feb 2024 16:52:51 +0000 Subject: [PATCH 1/2] changes_to_run_python_3.11_and_mac_osx --- .DS_Store | Bin 0 -> 8196 bytes README.md | 11 ++++++++--- data/.DS_Store | Bin 0 -> 6148 bytes data/test/.DS_Store | Bin 0 -> 6148 bytes model/.DS_Store | Bin 0 -> 6148 bytes requirements.txt | 18 +++++++++--------- scripts/inference.py | 14 +++++++------- scripts/run.py | 17 +++++++++-------- scripts/run_tools.py | 3 +++ scripts/run_with_multiple_plot_centres.py | 9 +++++---- tools/.DS_Store | Bin 0 -> 6148 bytes 11 files changed, 41 insertions(+), 31 deletions(-) create mode 100644 .DS_Store create mode 100644 data/.DS_Store create mode 100644 data/test/.DS_Store create mode 100644 model/.DS_Store create mode 100644 tools/.DS_Store diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..76194b49b7a694f701163a260a331a35b6884584 GIT binary patch literal 8196 zcmeHM&2Q5%6o2lTHD#LA10Ox1FeFZu=-38KyL4T-aUuu~e3YcAx@bvUH61-nlX8ZC zfx{3Iw@Dljnly2PJL13z{)S0hxbhr(t&@HXi7^fEtL&d+zvuY+_%9h?&j$k&!-~L&WBlmAEDiw>vsfJqmJ6(aXb7wbj5uNo3gM=R+?0qA zgK%@KH-uhAV8oG|0};Uo5qBmcLLu?pv41002U6jva>amRV3+|GyJx`x3%X#*@w?sj z+^}0Ne<7KvtTvs~b$v#EWUkYm*|oZxVb$t9U{`l3_3Xp4W#4m~y?Wv78V$OZ8#Fty zf$KC;<>7rdaA>beHv=b(ZB5>w=kxh`p}4iRR4$i{#T(1pC1Y#(8Y?ec-`>va=PqAe zxl`Zp{D3~=E)ek;fZ3Ew&t-qS*1XxEew*o>dH4Fe+~(6-O?<1+=XNjct?YhWO}0A| z+uQ3>-}@1o4tRWOb^?zEEv#eX)W8Rd95=z6$Z+ltGOQmf!;(i%*zjyz11U#k>a#oN z*OD~IIaH6Ir@KCB*PG4SNqEE1j-;{z=RAvDkj7uvW{!->o21UBm8&Bc+~IRHp)uG1qcswIYo8e3l6{J6)~e(<7?|Rn6j}U# zYy9{B#wM60J_O)({|`ef8>q@` mDgq;pSc7un9|HPs_3HeOCxE@~CWXaN()p{-|0F&C#??;^eI$ke literal 0 HcmV?d00001 diff --git a/README.md b/README.md index cf885c9..1b95689 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,13 @@ This may be improved in future versions, as it should be easily fixed with addit **A video showing the outputs of the tool is provided here: https://youtu.be/rej5Bu57AqM** +## My contributions + +I have edited this code to update it and have solved some of the bugs that have cropped up for other users e.g. incompatible package installations/TypeErrors. This has been done on a Mac Studio M2 ultra and I used all 24 CPU cores for this on the CPU only setting. My TLS was also 74 million+ points a scan so I have not tested minimum numbers of points. The code now runs on python 3.11.7. + +I might adapt the training data for European Arctic specific contexts, as per my research interests, as the original data relates to western Australia. I am collecting TLS data myself over summer 2024 in the European Arctic and may update the training data so that this is useable for large scale plot cleaning/metric extraction for forestry in these contexts. + +The only slight bug is it looks for the tools and model.pth files in /x/x/x/FSCT/model or /tools. The way I got around this was to simply make another folder called FSCT and copy the file/folder in there so it would find it where it expected as the folder when I download from FSCT is called FSCT-main. I used VS code, pip3, and a conda environment. ## Installation @@ -26,7 +33,7 @@ In Anaconda Prompt, type the following (replacing the path to FSCT and your desi ```shell cd PATH_TO_FSCT-MAIN_DIRECTORY -conda create --name YOUR_ENVIRONMENT_NAME_HERE python==3.9 +conda create --name YOUR_ENVIRONMENT_NAME_HERE conda activate YOUR_ENVIRONMENT_NAME_HERE conda install pip pip install -r requirements.txt @@ -34,8 +41,6 @@ pip install -r requirements.txt This should hopefully install all required packages for you. These are the instructions for Windows 10 and Linux. -I have not tested this on Mac. If someone with a Mac tests this and -it works (or doesn't), please let me know! If you have any difficulties or find any bugs, please get in touch and I will try to help you get it going. Suggestions for improvements are greatly appreciated. diff --git a/data/.DS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a+eR~o~+yrMVY6geqh2$g%-sM1H!;n z2Aa0n;r)N_@AvX|+$sYX_*--o literal 0 HcmV?d00001 diff --git a/model/.DS_Store b/model/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..5008ddfcf53c02e82d7eee2e57c38e5672ef89f6 GIT binary patch literal 6148 zcmeH~Jr2S!425mzP>H1@V-^m;4Wg<&0T*E43hX&L&p$$qDprKhvt+--jT7}7np#A3 zem<@ulZcFPQ@L2!n>{z**++&mCkOWA81W14cNZlEfg7;MkzE(HCqgga^y>{tEnwC%0;vJ&^%eQ zLs35+`xjp>T0= 2. num_cpu_cores=0, # Number of CPU cores you want to use. If you run out of RAM, lower this. 0 means ALL cores. - use_CPU_only=False, # Set to True if you do not have an Nvidia GPU, or if you don't have enough vRAM. + use_CPU_only=True, # Set to True if you do not have an Nvidia GPU, or if you don't have enough vRAM. # Optional settings - Generally leave as they are. - slice_thickness=0.15, # If your point cloud resolution is a bit low (and only if the stem segmentation is still reasonably accurate), try increasing this to 0.2. + slice_thickness=0.10, # If your point cloud resolution is a bit low (and only if the stem segmentation is still reasonably accurate), try increasing this to 0.2. # If your point cloud is really dense, you may get away with 0.1. slice_increment=0.05, # The smaller this is, the better your results will be, however, this increases the run time. sort_stems=1, # If you don't need the sorted stem points, turning this off speeds things up. @@ -38,7 +39,7 @@ tree_base_cutoff_height=5, # A tree must have a cylinder measurement below this height above the DTM to be kept. This filters unsorted branches from being called individual trees. generate_output_point_cloud=1, # Turn on if you would like a semantic and instance segmented point cloud. This mode will override the "sort_stems" setting if on. # If you activate "tree aware plot cropping mode", this function will use it. - ground_veg_cutoff_height=3, # Any vegetation points below this height are considered to be understory and are not assigned to individual trees. + ground_veg_cutoff_height=1, # Any vegetation points below this height are considered to be understory and are not assigned to individual trees. veg_sorting_range=1.5, # Vegetation points can be, at most, this far away from a cylinder horizontally to be matched to a particular tree. stem_sorting_range=1, # Stem points can be, at most, this far away from a cylinder in 3D to be matched to a particular tree. taper_measurement_height_min=0, # Lowest height to measure diameter for taper output. diff --git a/scripts/run_tools.py b/scripts/run_tools.py index feee797..603374a 100644 --- a/scripts/run_tools.py +++ b/scripts/run_tools.py @@ -7,6 +7,9 @@ import tkinter as tk import tkinter.filedialog as fd import os +import numpy +numpy.float = numpy.float64 +numpy.int = numpy.int_ def FSCT( diff --git a/scripts/run_with_multiple_plot_centres.py b/scripts/run_with_multiple_plot_centres.py index c8fc5ed..713f6fd 100644 --- a/scripts/run_with_multiple_plot_centres.py +++ b/scripts/run_with_multiple_plot_centres.py @@ -7,8 +7,9 @@ This script is an example of how to provide multiple different plot centres with your input point clouds. """ point_clouds_to_process = [ - ["E:/your_point_cloud1.las", [your_plot_centre_X_coord, your_plot_centre_Y_coord], your_plot_radius], - ["E:/your_point_cloud2.las", [your_plot_centre_X_coord, your_plot_centre_Y_coord], your_plot_radius], + ["/Volumes/bqlg43/prs/MILLIE PRS/PHD/TLS/DATA/LAS/RS67_Day_2.las", [-0.6055721435546870, -1.54360369873047], 20], + ["/Volumes/bqlg43/prs/MILLIE PRS/PHD/TLS/DATA/LAS/RS66.las", [-1.512628479, -2.375072144], 20], + ["/Volumes/bqlg43/prs/MILLIE PRS/PHD/TLS/DATA/LAS/RS65.las", [-0.786155029, -0.856148163], 20], ] for point_cloud_filename, plot_centre, plot_radius in point_clouds_to_process: @@ -19,7 +20,7 @@ plot_radius_buffer=0, batch_size=18, num_cpu_cores=0, - use_CPU_only=False, + use_CPU_only=True, # Optional settings - Generally leave as they are. slice_thickness=0.15, # If your point cloud resolution is a bit low (and only if the stem segmentation is still reasonably accurate), try increasing this to 0.2. @@ -35,7 +36,7 @@ generate_output_point_cloud=1, # Turn on if you would like a semantic and instance segmented point cloud. This mode will override the "sort_stems" setting if on. # If you activate "tree aware plot cropping mode", this function will use it. - ground_veg_cutoff_height=3, + ground_veg_cutoff_height=2, # Any vegetation points below this height are considered to be understory and are not assigned to individual trees. veg_sorting_range=1.5, # Vegetation points can be, at most, this far away from a cylinder horizontally to be matched to a particular tree. diff --git a/tools/.DS_Store b/tools/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..dd86fa0b629713411742729ccda11989e1111afb GIT binary patch literal 6148 zcmeHKu};H447J-z6m{uXwwu^Hv4$#qL3aX45tV321nR(+Phsab_%NRBQz1=*#DXZY zCHq|*`_6e6#W^D4#db9(niA0%DmXZWIUsUhv?GJ)k(;b@6m&}kt?7=kPP9AzA_KB_ z6YN$-HN9Z(KKC!%+|QRqRn}TIzg_f4mQ|YOn<__y%y&I|c)$EEdi8_odi|w}fxM@5 zLXWhil5)IfPxRcb^X$AE(No{vJY{vTuDz&MJ;PV2$Hf_N2AqLoV*ou{WIQo+>kK#p z&cKcV`91`wU=p!0)K3SD9sz(OxK%LLe>7ka2QZ1)7{UW#O9fgg$0G(?I{YEVB@r7# zODEQqF;85X;|Yazb@+pZ6DNjlodIW{&A`wur_%qg`p^IEB)@V7oPmGE0FTmTy1*mF x-r9LM>9qlR0~L|D#&DN{fwp4AN-Lg0Rp1XY045O|LwF$mBcL?6aRz>sfe$U6Oi%y- literal 0 HcmV?d00001 From d4fd512faf9eb1d6c2ebfe30135ca511f2ae2993 Mon Sep 17 00:00:00 2001 From: Millicent Harding Date: Wed, 28 Feb 2024 16:53:30 +0000 Subject: [PATCH 2/2] changes to make code usable for all --- scripts/run.py | 2 +- scripts/run_with_multiple_plot_centres.py | 6 +----- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/scripts/run.py b/scripts/run.py index e6953f7..8bb8adf 100644 --- a/scripts/run.py +++ b/scripts/run.py @@ -16,7 +16,7 @@ """ # point_clouds_to_process = directory_mode() # point_clouds_to_process = ['full_path_to_your_point_cloud.las', 'full_path_to_your_second_point_cloud.las', etc.] - point_clouds_to_process = ["/Volumes/prs/MILLIE PRS/PHD/TLS/DATA/LAS/Hamsterly/merged.las"] + point_clouds_to_process = directory_mode() for point_cloud_filename in point_clouds_to_process: parameters = dict( point_cloud_filename = point_cloud_filename, diff --git a/scripts/run_with_multiple_plot_centres.py b/scripts/run_with_multiple_plot_centres.py index 713f6fd..908e63d 100644 --- a/scripts/run_with_multiple_plot_centres.py +++ b/scripts/run_with_multiple_plot_centres.py @@ -6,11 +6,7 @@ """ This script is an example of how to provide multiple different plot centres with your input point clouds. """ - point_clouds_to_process = [ - ["/Volumes/bqlg43/prs/MILLIE PRS/PHD/TLS/DATA/LAS/RS67_Day_2.las", [-0.6055721435546870, -1.54360369873047], 20], - ["/Volumes/bqlg43/prs/MILLIE PRS/PHD/TLS/DATA/LAS/RS66.las", [-1.512628479, -2.375072144], 20], - ["/Volumes/bqlg43/prs/MILLIE PRS/PHD/TLS/DATA/LAS/RS65.las", [-0.786155029, -0.856148163], 20], - ] + point_clouds_to_process = [] for point_cloud_filename, plot_centre, plot_radius in point_clouds_to_process: parameters = dict(