jeremyLE-Ekimetrics commited on
Commit
851dbaf
·
1 Parent(s): 17ef3ec

addedtitle

Browse files
Files changed (3) hide show
  1. biomap/helper.py +5 -2
  2. biomap/streamlit_app.py +1 -1
  3. biomap/utils.py +5 -2
biomap/helper.py CHANGED
@@ -63,7 +63,8 @@ def inference_on_location(model, longitude=2.98, latitude=48.81, start_date=2020
63
 
64
  images = [np.asarray(img) for img in imgs]
65
  labeled_imgs = [np.asarray(img) for img in labeled_imgs]
66
- fig = plot_imgs_labels(dates, images, labeled_imgs, scores_details, scores)
 
67
  # fig.save("test.png")
68
  return fig
69
 
@@ -96,7 +97,9 @@ def inference_on_location_and_month(model, longitude = 2.98, latitude = 48.81, s
96
  score, score_details = compute_biodiv_score(outputs[0]["linear_preds"].detach().numpy())
97
  logging.info(f"Calculated Biodiversity Score : {score}")
98
  img, label, labeled_img = transform_to_pil(outputs[0])
99
- fig = plot_image([start_date], [np.asarray(img)], [np.asarray(labeled_img)], [score_details], [score])
 
 
100
  return fig
101
 
102
 
 
63
 
64
  images = [np.asarray(img) for img in imgs]
65
  labeled_imgs = [np.asarray(img) for img in labeled_imgs]
66
+ title=f"TimeLapse at location {tuple(location)} between {start_date} and {end_date}"
67
+ fig = plot_imgs_labels(dates, images, labeled_imgs, scores_details, scores, title=title)
68
  # fig.save("test.png")
69
  return fig
70
 
 
97
  score, score_details = compute_biodiv_score(outputs[0]["linear_preds"].detach().numpy())
98
  logging.info(f"Calculated Biodiversity Score : {score}")
99
  img, label, labeled_img = transform_to_pil(outputs[0])
100
+
101
+ title=f"Prediction at location {tuple(location)} at {start_date}"
102
+ fig = plot_image([start_date], [np.asarray(img)], [np.asarray(labeled_img)], [score_details], [score],title=title)
103
  return fig
104
 
105
 
biomap/streamlit_app.py CHANGED
@@ -19,7 +19,7 @@ MIN_YEAR = 2018
19
  MAX_YEAR = 2024
20
 
21
  FOLIUM_WIDTH = 925
22
- FOLIUM_HEIGHT = 600
23
 
24
 
25
  st.set_page_config(layout="wide")
 
19
  MAX_YEAR = 2024
20
 
21
  FOLIUM_WIDTH = 925
22
+ FOLIUM_HEIGHT = 500
23
 
24
 
25
  st.set_page_config(layout="wide")
biomap/utils.py CHANGED
@@ -82,7 +82,7 @@ def compute_biodiv_score(class_image):
82
  }
83
  return score, score_details
84
 
85
- def plot_image(months, imgs, imgs_label, nb_values, scores):
86
  fig2 = px.imshow(np.array(imgs), animation_frame=0, binary_string=True)
87
  fig3 = px.imshow(np.array(imgs_label), animation_frame=0, binary_string=True)
88
 
@@ -146,9 +146,11 @@ def plot_image(months, imgs, imgs_label, nb_values, scores):
146
  },)
147
  fig.update_xaxes(row=1, col=2, visible=False)
148
  fig.update_yaxes(row=1, col=2, visible=False)
 
 
149
  return fig
150
 
151
- def plot_imgs_labels(months, imgs, imgs_label, nb_values, scores) :
152
  fig2 = px.imshow(np.array(imgs), animation_frame=0, binary_string=True)
153
  fig3 = px.imshow(np.array(imgs_label), animation_frame=0, binary_string=True)
154
 
@@ -323,6 +325,7 @@ def plot_imgs_labels(months, imgs, imgs_label, nb_values, scores) :
323
 
324
 
325
  fig.update_layout(margin=dict(b=0, r=0))
 
326
  return fig
327
 
328
 
 
82
  }
83
  return score, score_details
84
 
85
+ def plot_image(months, imgs, imgs_label, nb_values, scores, title="Single Date"):
86
  fig2 = px.imshow(np.array(imgs), animation_frame=0, binary_string=True)
87
  fig3 = px.imshow(np.array(imgs_label), animation_frame=0, binary_string=True)
88
 
 
146
  },)
147
  fig.update_xaxes(row=1, col=2, visible=False)
148
  fig.update_yaxes(row=1, col=2, visible=False)
149
+ fig.update_layout(title=title, title_x=0.5)
150
+
151
  return fig
152
 
153
+ def plot_imgs_labels(months, imgs, imgs_label, nb_values, scores, title="TimeLapse") :
154
  fig2 = px.imshow(np.array(imgs), animation_frame=0, binary_string=True)
155
  fig3 = px.imshow(np.array(imgs_label), animation_frame=0, binary_string=True)
156
 
 
325
 
326
 
327
  fig.update_layout(margin=dict(b=0, r=0))
328
+ fig.update_layout(title=title, title_x=0.5)
329
  return fig
330
 
331