Spaces:
Running on CPU Upgrade

osv5m commited on
Commit
820baa3
1 Parent(s): 327ccc9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -2
app.py CHANGED
@@ -138,6 +138,9 @@ def inject_javascript(folium_map):
138
  """
139
  folium_map.get_root().html.add_child(Element(f'<script>{js}</script>'))
140
 
 
 
 
141
  def make_map_(name="map_name", id="1"):
142
  map = Map(location=BASE_LOCATION, zoom_start=1)
143
  map._name, map._id = name, id
@@ -471,7 +474,10 @@ if __name__ == "__main__":
471
  state['clicked'] = True
472
  image, text, df = state['engine'].click(float(lon), float(lat), country)
473
  df = df.sort_values(by='GeoScore', ascending=False)
474
- return gr.update(visible=False), gr.update(value=image, visible=True), gr.update(value=text, visible=True), gr.update(value=df, visible=True)
 
 
 
475
 
476
  def exit_(state):
477
  if state['engine'].index > 0:
@@ -487,7 +493,10 @@ if __name__ == "__main__":
487
  else:
488
  image, text = state['engine'].next_image()
489
  state['clicked'] = False
490
- return gr.update(value=make_map_(), visible=True), gr.update(visible=False), gr.update(value=image), gr.update(value=text), gr.update(visible=False), gr.update(), gr.update(visible=False), gr.update(value="-1"), gr.update(), gr.update(), gr.update()
 
 
 
491
  else:
492
  return gr.update(), gr.update(), gr.update(), gr.update(), gr.update(), gr.update(), gr.update(), gr.update(), gr.update(), gr.update(), gr.update()
493
 
 
138
  """
139
  folium_map.get_root().html.add_child(Element(f'<script>{js}</script>'))
140
 
141
+ def empty_map():
142
+ return Map(location=BASE_LOCATION, zoom_start=1)
143
+
144
  def make_map_(name="map_name", id="1"):
145
  map = Map(location=BASE_LOCATION, zoom_start=1)
146
  map._name, map._id = name, id
 
474
  state['clicked'] = True
475
  image, text, df = state['engine'].click(float(lon), float(lat), country)
476
  df = df.sort_values(by='GeoScore', ascending=False)
477
+ kargs = {}
478
+ if not MPL:
479
+ kargs = {'value': empty_map()}
480
+ return gr.update(visible=False, **kargs), gr.update(value=image, visible=True), gr.update(value=text, visible=True), gr.update(value=df, visible=True)
481
 
482
  def exit_(state):
483
  if state['engine'].index > 0:
 
493
  else:
494
  image, text = state['engine'].next_image()
495
  state['clicked'] = False
496
+ kargs = {}
497
+ if not MPL:
498
+ kargs = {'value': empty_map()}
499
+ return gr.update(value=make_map_(), visible=True), gr.update(visible=False, **kargs), gr.update(value=image), gr.update(value=text), gr.update(visible=False), gr.update(), gr.update(visible=False), gr.update(value="-1"), gr.update(), gr.update(), gr.update()
500
  else:
501
  return gr.update(), gr.update(), gr.update(), gr.update(), gr.update(), gr.update(), gr.update(), gr.update(), gr.update(), gr.update(), gr.update()
502