Commit
·
44bb0fe
1
Parent(s):
6eb11be
Updated demo
Browse files
app.py
CHANGED
@@ -10,7 +10,7 @@ from functools import partial
|
|
10 |
from huggingface_hub import hf_hub_download
|
11 |
from terratorch.cli_tools import LightningInferenceModel
|
12 |
|
13 |
-
# pull files from hub
|
14 |
token = os.environ.get("HF_TOKEN", None)
|
15 |
config_path = hf_hub_download(repo_id="ibm-nasa-geospatial/Prithvi-EO-2.0-300M-BurnScars",
|
16 |
filename="burn_scars_config.yaml", token=token)
|
@@ -97,10 +97,9 @@ def predict_on_images(data_file: str | Path, config_path: str, checkpoint: str):
|
|
97 |
|
98 |
lightning_model.model.eval()
|
99 |
|
100 |
-
channels = [config_dict['data']['init_args']['
|
101 |
|
102 |
-
pred = run_model(input_data,
|
103 |
-
lightning_model.model, lightning_model.datamodule, img_size)
|
104 |
|
105 |
if input_data.mean() < 1:
|
106 |
input_data = input_data * 10000 # Scale to 0-10000
|
@@ -153,7 +152,7 @@ Some example images are provided at the end of this page.
|
|
153 |
predicted = gr.Image(image_mode='RGB', show_label=False, show_fullscreen_button=False)
|
154 |
overlay = gr.Image(image_mode='RGB', show_label=False, show_fullscreen_button=False)
|
155 |
|
156 |
-
gr.Markdown(value='\* White = burned; Black =
|
157 |
|
158 |
btn.click(fn=run_inference,
|
159 |
inputs=inp_file,
|
@@ -162,7 +161,7 @@ Some example images are provided at the end of this page.
|
|
162 |
with gr.Row():
|
163 |
gr.Examples(examples=[
|
164 |
os.path.join(os.path.dirname(__file__), "examples/subsetted_512x512_HLS.S30.T10SEH.2018190.v1.4_merged.tif"),
|
165 |
-
os.path.join(os.path.dirname(__file__), "examples/subsetted_512x512_HLS.S30.
|
166 |
os.path.join(os.path.dirname(__file__), "examples/subsetted_512x512_HLS.S30.T10SGF.2020217.v1.4_merged.tif")],
|
167 |
inputs=inp_file,
|
168 |
outputs=[original] + [predicted] + [overlay],
|
|
|
10 |
from huggingface_hub import hf_hub_download
|
11 |
from terratorch.cli_tools import LightningInferenceModel
|
12 |
|
13 |
+
# pull files from hub-
|
14 |
token = os.environ.get("HF_TOKEN", None)
|
15 |
config_path = hf_hub_download(repo_id="ibm-nasa-geospatial/Prithvi-EO-2.0-300M-BurnScars",
|
16 |
filename="burn_scars_config.yaml", token=token)
|
|
|
97 |
|
98 |
lightning_model.model.eval()
|
99 |
|
100 |
+
channels = [config_dict['data']['init_args']['output_bands'].index(b) for b in ["RED", "GREEN", "BLUE"]] # BGR -> RGB
|
101 |
|
102 |
+
pred = run_model(input_data, lightning_model.model, lightning_model.datamodule, img_size)
|
|
|
103 |
|
104 |
if input_data.mean() < 1:
|
105 |
input_data = input_data * 10000 # Scale to 0-10000
|
|
|
152 |
predicted = gr.Image(image_mode='RGB', show_label=False, show_fullscreen_button=False)
|
153 |
overlay = gr.Image(image_mode='RGB', show_label=False, show_fullscreen_button=False)
|
154 |
|
155 |
+
gr.Markdown(value='\* White = burned; Black = not burned')
|
156 |
|
157 |
btn.click(fn=run_inference,
|
158 |
inputs=inp_file,
|
|
|
161 |
with gr.Row():
|
162 |
gr.Examples(examples=[
|
163 |
os.path.join(os.path.dirname(__file__), "examples/subsetted_512x512_HLS.S30.T10SEH.2018190.v1.4_merged.tif"),
|
164 |
+
os.path.join(os.path.dirname(__file__), "examples/subsetted_512x512_HLS.S30.T10SFH.2018185.v1.4_merged.tif"),
|
165 |
os.path.join(os.path.dirname(__file__), "examples/subsetted_512x512_HLS.S30.T10SGF.2020217.v1.4_merged.tif")],
|
166 |
inputs=inp_file,
|
167 |
outputs=[original] + [predicted] + [overlay],
|
examples/{subsetted_512x512_HLS.S30.T10SFF.2018190.v1.4_merged.tif → subsetted_512x512_HLS.S30.T10SFH.2018185.v1.4_merged.tif}
RENAMED
File without changes
|