Paras Shah
commited on
Commit
·
0d17b56
1
Parent(s):
a5adaeb
Add latest model and error control
Browse files- checkpoints/best_model.pth +1 -1
- utils.py +6 -4
checkpoints/best_model.pth
CHANGED
@@ -1,3 +1,3 @@
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:
|
3 |
size 21010087
|
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:5c4ffde314c0e590d8a4263c36acc4307c8035b343b27292f4de9fb871e6cfae
|
3 |
size 21010087
|
utils.py
CHANGED
@@ -40,7 +40,10 @@ def remove_noise(points, eps=0.05, min_samples=10):
|
|
40 |
"""
|
41 |
clustering = DBSCAN(eps=eps, min_samples=min_samples).fit(points)
|
42 |
labels = clustering.labels_
|
43 |
-
|
|
|
|
|
|
|
44 |
return points[largest_cluster]
|
45 |
|
46 |
def calculate_dbh(points, dbh_height=1.3, height_buffer=0.1, eps=0.05, min_samples=10):
|
@@ -95,9 +98,8 @@ def calc_canopy_volume(points, threshold, height, z_min):
|
|
95 |
Returns:
|
96 |
canopy_volume, canopy_points
|
97 |
'''
|
98 |
-
|
99 |
-
|
100 |
-
canopy_points = canopy_points[canopy_points[:, 2] >= z_threshold]
|
101 |
clustering = DBSCAN(eps=1.0, min_samples=10).fit(canopy_points[:, :3])
|
102 |
labels = clustering.labels_
|
103 |
canopy_points = canopy_points[labels != -1]
|
|
|
40 |
"""
|
41 |
clustering = DBSCAN(eps=eps, min_samples=min_samples).fit(points)
|
42 |
labels = clustering.labels_
|
43 |
+
try:
|
44 |
+
largest_cluster = labels == np.argmax(np.bincount(labels[labels >= 0]))
|
45 |
+
except Exception:
|
46 |
+
raise RuntimeError("Error in DBH calculation")
|
47 |
return points[largest_cluster]
|
48 |
|
49 |
def calculate_dbh(points, dbh_height=1.3, height_buffer=0.1, eps=0.05, min_samples=10):
|
|
|
98 |
Returns:
|
99 |
canopy_volume, canopy_points
|
100 |
'''
|
101 |
+
z_threshold = z_min + (threshold / 100) * height
|
102 |
+
canopy_points = points[points[:, 2] >= z_threshold]
|
|
|
103 |
clustering = DBSCAN(eps=1.0, min_samples=10).fit(canopy_points[:, :3])
|
104 |
labels = clustering.labels_
|
105 |
canopy_points = canopy_points[labels != -1]
|