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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
[global]
|
2 |
+
|
3 |
+
# By default, Streamlit displays a warning when a user sets both a widget
|
4 |
+
# default value in the function defining the widget and a widget value via
|
5 |
+
# the widget's key in `st.session_state`.
|
6 |
+
# If you'd like to turn off this warning, set this to True.
|
7 |
+
# Default: false
|
8 |
+
disableWidgetStateDuplicationWarning = false
|
9 |
+
|
10 |
+
# If True, will show a warning when you run a Streamlit-enabled script
|
11 |
+
# via "python my_script.py".
|
12 |
+
# Default: true
|
13 |
+
showWarningOnDirectExecution = true
|
14 |
+
|
15 |
+
|
16 |
+
[logger]
|
17 |
+
|
18 |
+
# Level of logging for Streamlit's internal logger: "error", "warning",
|
19 |
+
# "info", or "debug".
|
20 |
+
# Default: "info"
|
21 |
+
level = "info"
|
22 |
+
|
23 |
+
# String format for logging messages. If logger.datetimeFormat is set,
|
24 |
+
# logger messages will default to `%(asctime)s.%(msecs)03d %(message)s`. See
|
25 |
+
# Python's documentation for available attributes:
|
26 |
+
# https://docs.python.org/3/library/logging.html#formatter-objects
|
27 |
+
# Default: "%(asctime)s %(message)s"
|
28 |
+
messageFormat = "%(asctime)s %(levelname) -7s %(name)s: %(message)s"
|
29 |
+
|
30 |
+
|
31 |
+
[client]
|
32 |
+
|
33 |
+
# Controls whether uncaught app exceptions and deprecation warnings
|
34 |
+
# are displayed in the browser. By default, this is set to True and
|
35 |
+
# Streamlit displays app exceptions and associated tracebacks, and
|
36 |
+
# deprecation warnings, in the browser.
|
37 |
+
# If set to False, deprecation warnings and full exception messages
|
38 |
+
# will print to the console only. Exceptions will still display in the
|
39 |
+
# browser with a generic error message. For now, the exception type and
|
40 |
+
# traceback show in the browser also, but they will be removed in the
|
41 |
+
# future.
|
42 |
+
# Default: true
|
43 |
+
showErrorDetails = true
|
44 |
+
|
45 |
+
# Change the visibility of items in the toolbar, options menu,
|
46 |
+
# and settings dialog (top right of the app).
|
47 |
+
# Allowed values:
|
48 |
+
# * "auto" : Show the developer options if the app is accessed through
|
49 |
+
# localhost or through Streamlit Community Cloud as a developer.
|
50 |
+
# Hide them otherwise.
|
51 |
+
# * "developer" : Show the developer options.
|
52 |
+
# * "viewer" : Hide the developer options.
|
53 |
+
# * "minimal" : Show only options set externally (e.g. through
|
54 |
+
# Streamlit Community Cloud) or through st.set_page_config.
|
55 |
+
# If there are no options left, hide the menu.
|
56 |
+
# Default: "auto"
|
57 |
+
toolbarMode = "auto"
|
58 |
+
|
59 |
+
|
60 |
+
[runner]
|
61 |
+
|
62 |
+
# Allows you to type a variable or string by itself in a single line of
|
63 |
+
# Python code to write it to the app.
|
64 |
+
# Default: true
|
65 |
+
magicEnabled = true
|
66 |
+
|
67 |
+
# Handle script rerun requests immediately, rather than waiting for script
|
68 |
+
# execution to reach a yield point. This makes Streamlit much more
|
69 |
+
# responsive to user interaction, but it can lead to race conditions in
|
70 |
+
# apps that mutate session_state data outside of explicit session_state
|
71 |
+
# assignment statements.
|
72 |
+
# Default: true
|
73 |
+
fastReruns = true
|
74 |
+
|
75 |
+
# Raise an exception after adding unserializable data to Session State.
|
76 |
+
# Some execution environments may require serializing all data in Session
|
77 |
+
# State, so it may be useful to detect incompatibility during development,
|
78 |
+
# or when the execution environment will stop supporting it in the future.
|
79 |
+
# Default: false
|
80 |
+
enforceSerializableSessionState = false
|
81 |
+
|
82 |
+
|
83 |
+
[server]
|
84 |
+
|
85 |
+
# List of folders that should not be watched for changes.
|
86 |
+
# Relative paths will be taken as relative to the current working directory.
|
87 |
+
# Example: ['/home/user1/env', 'relative/path/to/folder']
|
88 |
+
# Default: []
|
89 |
+
folderWatchBlacklist = []
|
90 |
+
|
91 |
+
# Change the type of file watcher used by Streamlit, or turn it off
|
92 |
+
# completely.
|
93 |
+
# Allowed values:
|
94 |
+
# * "auto" : Streamlit will attempt to use the watchdog module, and
|
95 |
+
# falls back to polling if watchdog is not available.
|
96 |
+
# * "watchdog" : Force Streamlit to use the watchdog module.
|
97 |
+
# * "poll" : Force Streamlit to always use polling.
|
98 |
+
# * "none" : Streamlit will not watch files.
|
99 |
+
# Default: "auto"
|
100 |
+
fileWatcherType = "auto"
|
101 |
+
|
102 |
+
# Symmetric key used to produce signed cookies. If deploying on multiple
|
103 |
+
# replicas, this should be set to the same value across all replicas to ensure
|
104 |
+
# they all share the same secret.
|
105 |
+
# Default: randomly generated secret key.
|
106 |
+
cookieSecret = "a-random-key-appears-here"
|
107 |
+
|
108 |
+
# If false, will attempt to open a browser window on start.
|
109 |
+
# Default: false unless (1) we are on a Linux box where DISPLAY is unset, or
|
110 |
+
# (2) we are running in the Streamlit Atom plugin.
|
111 |
+
headless = false
|
112 |
+
|
113 |
+
# Automatically rerun script when the file is modified on disk.
|
114 |
+
# Default: false
|
115 |
+
runOnSave = true
|
116 |
+
|
117 |
+
# The address where the server will listen for client and browser
|
118 |
+
# connections. Use this if you want to bind the server to a specific address.
|
119 |
+
# If set, the server will only be accessible from this address, and not from
|
120 |
+
# any aliases (like localhost).
|
121 |
+
# Default: (unset)
|
122 |
+
address = ""
|
123 |
+
|
124 |
+
# The port where the server will listen for browser connections.
|
125 |
+
# Don't use port 3000 which is reserved for internal development.
|
126 |
+
# Default: 8501
|
127 |
+
port = 8501
|
128 |
+
|
129 |
+
# The base path for the URL where Streamlit should be served from.
|
130 |
+
# Default: ""
|
131 |
+
baseUrlPath = ""
|
132 |
+
|
133 |
+
# Enables support for Cross-Origin Resource Sharing (CORS) protection, for
|
134 |
+
# added security.
|
135 |
+
# Due to conflicts between CORS and XSRF, if `server.enableXsrfProtection` is
|
136 |
+
# on and `server.enableCORS` is off at the same time, we will prioritize
|
137 |
+
# `server.enableXsrfProtection`.
|
138 |
+
# Default: true
|
139 |
+
enableCORS = true
|
140 |
+
|
141 |
+
# Enables support for Cross-Site Request Forgery (XSRF) protection, for
|
142 |
+
# added security.
|
143 |
+
# Due to conflicts between CORS and XSRF, if `server.enableXsrfProtection` is
|
144 |
+
# on and `server.enableCORS` is off at the same time, we will prioritize
|
145 |
+
# `server.enableXsrfProtection`.
|
146 |
+
# Default: true
|
147 |
+
enableXsrfProtection = true
|
148 |
+
|
149 |
+
# Max size, in megabytes, for files uploaded with the file_uploader.
|
150 |
+
# Default: 200
|
151 |
+
maxUploadSize = 500
|
152 |
+
|
153 |
+
# Max size, in megabytes, of messages that can be sent via the WebSocket
|
154 |
+
# connection.
|
155 |
+
# Default: 200
|
156 |
+
maxMessageSize = 500
|
157 |
+
|
158 |
+
# Enables support for websocket compression.
|
159 |
+
# Default: false
|
160 |
+
enableWebsocketCompression = false
|
161 |
+
|
162 |
+
# Enable serving files from a `static` directory in the running app's
|
163 |
+
# directory.
|
164 |
+
# Default: false
|
165 |
+
enableStaticServing = false
|
166 |
+
|
167 |
+
# Server certificate file for connecting via HTTPS.
|
168 |
+
# Must be set at the same time as "server.sslKeyFile".
|
169 |
+
# ['DO NOT USE THIS OPTION IN A PRODUCTION ENVIRONMENT. It has not gone through
|
170 |
+
# security audits or performance tests. For the production environment, we
|
171 |
+
# recommend performing SSL termination by the load balancer or the reverse
|
172 |
+
# proxy.']
|
173 |
+
sslCertFile = ""
|
174 |
+
|
175 |
+
# Cryptographic key file for connecting via HTTPS.
|
176 |
+
# Must be set at the same time as "server.sslCertFile".
|
177 |
+
# ['DO NOT USE THIS OPTION IN A PRODUCTION ENVIRONMENT. It has not gone through
|
178 |
+
# security audits or performance tests. For the production environment, we
|
179 |
+
# recommend performing SSL termination by the load balancer or the reverse
|
180 |
+
# proxy.']
|
181 |
+
sslKeyFile = ""
|
182 |
+
|
183 |
+
|
184 |
+
[browser]
|
185 |
+
|
186 |
+
# Internet address where users should point their browsers in order to
|
187 |
+
# connect to the app. Can be IP address or DNS name and path.
|
188 |
+
# This is used to:
|
189 |
+
# - Set the correct URL for CORS and XSRF protection purposes.
|
190 |
+
# - Show the URL on the terminal
|
191 |
+
# - Open the browser
|
192 |
+
# Default: "localhost"
|
193 |
+
serverAddress = "localhost"
|
194 |
+
|
195 |
+
# Whether to send usage statistics to Streamlit.
|
196 |
+
# Default: true
|
197 |
+
gatherUsageStats = true
|
198 |
+
|
199 |
+
# Port where users should point their browsers in order to connect to the
|
200 |
+
# app.
|
201 |
+
# This is used to:
|
202 |
+
# - Set the correct URL for XSRF protection purposes.
|
203 |
+
# - Show the URL on the terminal (part of `streamlit run`).
|
204 |
+
# - Open the browser automatically (part of `streamlit run`).
|
205 |
+
# This option is for advanced use cases. To change the port of your app, use
|
206 |
+
# `server.Port` instead. Don't use port 3000 which is reserved for internal
|
207 |
+
# development.
|
208 |
+
# Default: whatever value is set in server.port.
|
209 |
+
serverPort = 8501
|
210 |
+
|
211 |
+
|
212 |
+
[mapbox]
|
213 |
+
|
214 |
+
# Configure Streamlit to use a custom Mapbox
|
215 |
+
# token for elements like st.pydeck_chart and st.map.
|
216 |
+
# To get a token for yourself, create an account at
|
217 |
+
# https://mapbox.com. It's free (for moderate usage levels)!
|
218 |
+
# Default: ""
|
219 |
+
token = ""
|
220 |
+
|
221 |
+
|
222 |
+
[theme]
|
223 |
+
|
224 |
+
# The preset Streamlit theme that your custom theme inherits from.
|
225 |
+
# One of "light" or "dark".
|
226 |
+
base = ""
|
227 |
+
|
228 |
+
# Primary accent color for interactive elements.
|
229 |
+
primaryColor = ""
|
230 |
+
|
231 |
+
# Background color for the main content area.
|
232 |
+
backgroundColor = ""
|
233 |
+
|
234 |
+
# Background color used for the sidebar and most interactive widgets.
|
235 |
+
secondaryBackgroundColor = ""
|
236 |
+
|
237 |
+
# Color used for almost all text.
|
238 |
+
textColor = ""
|
239 |
+
|
240 |
+
# Font family for all text in the app, except code blocks. One of "sans serif",
|
241 |
+
# "serif", or "monospace".
|
242 |
+
font = ""
|
app.py
CHANGED
@@ -12,8 +12,9 @@ from utils import calculate_dbh, calc_canopy_volume, CLASSES
|
|
12 |
from SingleTreePointCloudLoader import SingleTreePointCloudLoader
|
13 |
gc.enable()
|
14 |
|
|
|
15 |
with st.spinner("Loading PointNet++ model..."):
|
16 |
-
checkpoint = torch.load('checkpoints/best_model.pth', map_location=torch.device(
|
17 |
classifier = pn2.get_model(num_class=4, normal_channel=False)
|
18 |
classifier.load_state_dict(checkpoint['model_state_dict'])
|
19 |
classifier.eval()
|
@@ -27,8 +28,8 @@ uploaded_file = st.file_uploader(
|
|
27 |
)
|
28 |
Z_THRESHOLD = st.slider(
|
29 |
label="Z-Threshold(%)",
|
30 |
-
min_value=
|
31 |
-
max_value=
|
32 |
value=50,
|
33 |
step=1,
|
34 |
help="Please select a Z-Threshold for canopy volume calculation"
|
|
|
12 |
from SingleTreePointCloudLoader import SingleTreePointCloudLoader
|
13 |
gc.enable()
|
14 |
|
15 |
+
device = 'cuda' if torch.cuda.is_available() else 'cpu'
|
16 |
with st.spinner("Loading PointNet++ model..."):
|
17 |
+
checkpoint = torch.load('checkpoints/best_model.pth', map_location=torch.device(device))
|
18 |
classifier = pn2.get_model(num_class=4, normal_channel=False)
|
19 |
classifier.load_state_dict(checkpoint['model_state_dict'])
|
20 |
classifier.eval()
|
|
|
28 |
)
|
29 |
Z_THRESHOLD = st.slider(
|
30 |
label="Z-Threshold(%)",
|
31 |
+
min_value=10,
|
32 |
+
max_value=90,
|
33 |
value=50,
|
34 |
step=1,
|
35 |
help="Please select a Z-Threshold for canopy volume calculation"
|