umgefahren commited on
Commit ·
83c3d9c
1
Parent(s): 07e315a
Progress bar
Browse files
main.py
CHANGED
|
@@ -53,19 +53,22 @@ generate_tree_images stores the cutout tree images in a separate folder
|
|
| 53 |
"""
|
| 54 |
|
| 55 |
|
| 56 |
-
def greet(image_path: str):
|
| 57 |
current_directory = os.getcwd()
|
| 58 |
|
| 59 |
output_directory = os.path.join(current_directory, "outputs")
|
| 60 |
if not os.path.exists(output_directory):
|
| 61 |
os.makedirs(output_directory)
|
| 62 |
|
|
|
|
| 63 |
run_detectree2(image_path, store_path=output_directory)
|
|
|
|
| 64 |
|
| 65 |
processed_output_df = postprocess(output_directory + '/detectree2_delin.geojson', output_directory + '/processed_delin')
|
| 66 |
|
| 67 |
processed_geojson = output_directory + '/processed_delin.geojson'
|
| 68 |
|
|
|
|
| 69 |
generate_tree_images(processed_geojson, image_path)
|
| 70 |
|
| 71 |
output_folder = './tree_images'
|
|
@@ -85,6 +88,8 @@ def greet(image_path: str):
|
|
| 85 |
processed_output_df['species'] = all_top_3_list
|
| 86 |
|
| 87 |
final_output_path = 'result'
|
|
|
|
|
|
|
| 88 |
export_geojson(processed_output_df, final_output_path)
|
| 89 |
|
| 90 |
with rasterio.open(image_path) as src:
|
|
@@ -100,6 +105,8 @@ def greet(image_path: str):
|
|
| 100 |
# Enable interactive mode
|
| 101 |
# plt.ion()
|
| 102 |
|
|
|
|
|
|
|
| 103 |
# Plotting
|
| 104 |
fig, ax = plt.subplots(figsize=(10, 10))
|
| 105 |
|
|
|
|
| 53 |
"""
|
| 54 |
|
| 55 |
|
| 56 |
+
def greet(image_path: str, progress=gr.Progress()):
|
| 57 |
current_directory = os.getcwd()
|
| 58 |
|
| 59 |
output_directory = os.path.join(current_directory, "outputs")
|
| 60 |
if not os.path.exists(output_directory):
|
| 61 |
os.makedirs(output_directory)
|
| 62 |
|
| 63 |
+
progress(0, desc="Running detectree2")
|
| 64 |
run_detectree2(image_path, store_path=output_directory)
|
| 65 |
+
progress(0.1, desc="Postprocessing")
|
| 66 |
|
| 67 |
processed_output_df = postprocess(output_directory + '/detectree2_delin.geojson', output_directory + '/processed_delin')
|
| 68 |
|
| 69 |
processed_geojson = output_directory + '/processed_delin.geojson'
|
| 70 |
|
| 71 |
+
progress(0.2, desc="Generating tree images")
|
| 72 |
generate_tree_images(processed_geojson, image_path)
|
| 73 |
|
| 74 |
output_folder = './tree_images'
|
|
|
|
| 88 |
processed_output_df['species'] = all_top_3_list
|
| 89 |
|
| 90 |
final_output_path = 'result'
|
| 91 |
+
|
| 92 |
+
progress(0.3, desc="Exporting geojson")
|
| 93 |
export_geojson(processed_output_df, final_output_path)
|
| 94 |
|
| 95 |
with rasterio.open(image_path) as src:
|
|
|
|
| 105 |
# Enable interactive mode
|
| 106 |
# plt.ion()
|
| 107 |
|
| 108 |
+
progress(0.4, desc="Plotting")
|
| 109 |
+
|
| 110 |
# Plotting
|
| 111 |
fig, ax = plt.subplots(figsize=(10, 10))
|
| 112 |
|