robocan commited on
Commit
05501c8
·
verified ·
1 Parent(s): 14085cb

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -3
app.py CHANGED
@@ -80,20 +80,23 @@ def get_s2_cell_polygon(cell_id):
80
  vertices.append(vertices[0]) # Close the polygon
81
  return vertices
82
 
83
- # Function to generate Plotly map figure
84
  def create_map_figure(predictions, cell_ids):
85
  fig = go.Figure()
86
 
87
- for cell_id in cell_ids:
 
 
 
88
  cell_id = int(cell_id)
89
  polygon = get_s2_cell_polygon(cell_id)
90
  lats, lons = zip(*polygon)
 
91
  fig.add_trace(go.Scattermapbox(
92
  lat=lats,
93
  lon=lons,
94
  mode='lines',
95
  fill='toself',
96
- fillcolor='rgba(0, 0, 255, 0.2)',
97
  line=dict(color='blue'),
98
  name=f'Cell ID: {cell_id}'
99
  ))
@@ -114,6 +117,7 @@ def create_map_figure(predictions, cell_ids):
114
 
115
  return fig
116
 
 
117
  # Create label output function
118
  def create_label_output(predictions):
119
  results, cell_ids = predictions
@@ -125,6 +129,7 @@ def predict_and_plot(input_img):
125
  predictions = predict(input_img)
126
  return create_label_output(predictions)
127
 
 
128
  # Gradio app definition
129
  with gr.Blocks() as gradio_app:
130
  with gr.Column():
 
80
  vertices.append(vertices[0]) # Close the polygon
81
  return vertices
82
 
 
83
  def create_map_figure(predictions, cell_ids):
84
  fig = go.Figure()
85
 
86
+ # Assign colors based on rank
87
+ colors = ['rgba(0, 255, 0, 0.2)'] * 3 + ['rgba(255, 255, 0, 0.2)'] * 7
88
+
89
+ for rank, cell_id in enumerate(cell_ids):
90
  cell_id = int(cell_id)
91
  polygon = get_s2_cell_polygon(cell_id)
92
  lats, lons = zip(*polygon)
93
+ color = colors[rank]
94
  fig.add_trace(go.Scattermapbox(
95
  lat=lats,
96
  lon=lons,
97
  mode='lines',
98
  fill='toself',
99
+ fillcolor=color,
100
  line=dict(color='blue'),
101
  name=f'Cell ID: {cell_id}'
102
  ))
 
117
 
118
  return fig
119
 
120
+
121
  # Create label output function
122
  def create_label_output(predictions):
123
  results, cell_ids = predictions
 
129
  predictions = predict(input_img)
130
  return create_label_output(predictions)
131
 
132
+
133
  # Gradio app definition
134
  with gr.Blocks() as gradio_app:
135
  with gr.Column():