Skip to content

Commit

Permalink
Improve exception handling for LangSAM GUI
Browse files Browse the repository at this point in the history
  • Loading branch information
giswqs committed Jun 28, 2023
1 parent b344e66 commit c4e4bb3
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions samgeo/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -2496,18 +2496,22 @@ def segment_button_click(change):
filename = os.path.join(
out_dir, f"{layer_name}_{random_string()}.tif"
)
sam.predict(
sam.source,
text_prompt.value,
box_slider.value,
text_slider.value,
output=filename,
)
sam.output = filename
if m.find_layer(layer_name) is not None:
m.remove_layer(m.find_layer(layer_name))
if m.find_layer(f"{layer_name}_rect") is not None:
m.remove_layer(m.find_layer(f"{layer_name} Regularized"))
try:
sam.predict(
sam.source,
text_prompt.value,
box_slider.value,
text_slider.value,
output=filename,
)
sam.output = filename
if m.find_layer(layer_name) is not None:
m.remove_layer(m.find_layer(layer_name))
if m.find_layer(f"{layer_name}_rect") is not None:
m.remove_layer(m.find_layer(f"{layer_name} Regularized"))
except Exception as e:
output.clear_output()
print(e)
if os.path.exists(filename):
try:
m.add_raster(
Expand Down

0 comments on commit c4e4bb3

Please sign in to comment.