Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
Update app.py
Browse files
app.py
CHANGED
|
@@ -393,13 +393,14 @@ class Engine(object):
|
|
| 393 |
|
| 394 |
df = pd.DataFrame([self.get_model_average(who) for who in ['user', 'best', 'base']], columns=['who', 'GeoScore', 'Distance', 'Accuracy (country)']).round(2)
|
| 395 |
result_text = (
|
| 396 |
-
f"### GeoScore: <span style='color:blue'
|
| 397 |
round(score, 2),
|
| 398 |
-
round(self.df['score'].iloc[self.index+1], 2),
|
| 399 |
round(distance, 2),
|
|
|
|
| 400 |
round(self.df['distance'].iloc[self.index+1], 2)
|
| 401 |
)
|
| 402 |
)
|
|
|
|
| 403 |
|
| 404 |
self.cache(self.index+1, score, distance, (click_lat, click_lon), time_elapsed)
|
| 405 |
return self.get_figure(), result_text, df
|
|
@@ -427,14 +428,14 @@ class Engine(object):
|
|
| 427 |
avg_country_accuracy = self.df['accuracy_country_base'].iloc[i]
|
| 428 |
if all:
|
| 429 |
aux = [self.df['accuracy_city_base'].iloc[i], self.df['accuracy_area_base'].iloc[i], self.df['accuracy_region_base'].iloc[i]]
|
| 430 |
-
which = '
|
| 431 |
elif which == 'best':
|
| 432 |
avg_score = np.mean(self.df[['score']].iloc[:i])
|
| 433 |
avg_distance = np.mean(self.df[['distance']].iloc[:i])
|
| 434 |
avg_country_accuracy = self.df['accuracy_country'].iloc[i]
|
| 435 |
if all:
|
| 436 |
aux = [self.df['accuracy_city_base'].iloc[i], self.df['accuracy_area_base'].iloc[i], self.df['accuracy_region_base'].iloc[i]]
|
| 437 |
-
which = '
|
| 438 |
return [which, avg_score, avg_distance, avg_country_accuracy] + aux
|
| 439 |
|
| 440 |
def update_average_display(self):
|
|
@@ -474,7 +475,7 @@ if __name__ == "__main__":
|
|
| 474 |
import gradio as gr
|
| 475 |
def click(state, coords):
|
| 476 |
if coords == '-1' or state['clicked']:
|
| 477 |
-
return gr.update(), gr.update(), gr.update(), gr.update()
|
| 478 |
lat, lon, country = coords.split(',')
|
| 479 |
state['clicked'] = True
|
| 480 |
image, text, df = state['engine'].click(float(lon), float(lat), country)
|
|
@@ -502,7 +503,7 @@ if __name__ == "__main__":
|
|
| 502 |
kargs = {}
|
| 503 |
if not MPL:
|
| 504 |
kargs = {'value': empty_map()}
|
| 505 |
-
return gr.update(value=make_map_(), visible=True), gr.update(visible=False, **kargs), gr.update(value=image), gr.update(value=text, visible=True), gr.update(visible=
|
| 506 |
else:
|
| 507 |
return gr.update(), gr.update(), gr.update(), gr.update(), gr.update(), gr.update(), gr.update(), gr.update(), gr.update(), gr.update(), gr.update()
|
| 508 |
|
|
|
|
| 393 |
|
| 394 |
df = pd.DataFrame([self.get_model_average(who) for who in ['user', 'best', 'base']], columns=['who', 'GeoScore', 'Distance', 'Accuracy (country)']).round(2)
|
| 395 |
result_text = (
|
| 396 |
+
f"### GeoScore: <span style='color:blue'><emph>You</emph>GeoScore: %s, Distance: %s km</span> <span style='color:green'>GeoScore: %s, Distance: %s km</span>" % (
|
| 397 |
round(score, 2),
|
|
|
|
| 398 |
round(distance, 2),
|
| 399 |
+
round(self.df['score'].iloc[self.index+1], 2),
|
| 400 |
round(self.df['distance'].iloc[self.index+1], 2)
|
| 401 |
)
|
| 402 |
)
|
| 403 |
+
# You: } \green{OSV-Bot: GeoScore: XX, distance: XX
|
| 404 |
|
| 405 |
self.cache(self.index+1, score, distance, (click_lat, click_lon), time_elapsed)
|
| 406 |
return self.get_figure(), result_text, df
|
|
|
|
| 428 |
avg_country_accuracy = self.df['accuracy_country_base'].iloc[i]
|
| 429 |
if all:
|
| 430 |
aux = [self.df['accuracy_city_base'].iloc[i], self.df['accuracy_area_base'].iloc[i], self.df['accuracy_region_base'].iloc[i]]
|
| 431 |
+
which = 'Baseline-AI'
|
| 432 |
elif which == 'best':
|
| 433 |
avg_score = np.mean(self.df[['score']].iloc[:i])
|
| 434 |
avg_distance = np.mean(self.df[['distance']].iloc[:i])
|
| 435 |
avg_country_accuracy = self.df['accuracy_country'].iloc[i]
|
| 436 |
if all:
|
| 437 |
aux = [self.df['accuracy_city_base'].iloc[i], self.df['accuracy_area_base'].iloc[i], self.df['accuracy_region_base'].iloc[i]]
|
| 438 |
+
which = 'Plonk-AI'
|
| 439 |
return [which, avg_score, avg_distance, avg_country_accuracy] + aux
|
| 440 |
|
| 441 |
def update_average_display(self):
|
|
|
|
| 475 |
import gradio as gr
|
| 476 |
def click(state, coords):
|
| 477 |
if coords == '-1' or state['clicked']:
|
| 478 |
+
return gr.update(), gr.update(), gr.update(), gr.update(), gr.update(), gr.update()
|
| 479 |
lat, lon, country = coords.split(',')
|
| 480 |
state['clicked'] = True
|
| 481 |
image, text, df = state['engine'].click(float(lon), float(lat), country)
|
|
|
|
| 503 |
kargs = {}
|
| 504 |
if not MPL:
|
| 505 |
kargs = {'value': empty_map()}
|
| 506 |
+
return gr.update(value=make_map_(), visible=True), gr.update(visible=False, **kargs), gr.update(value=image), gr.update(value=text, visible=True), gr.update(value='', visible=True), gr.update(visible=False), gr.update(visible=False), gr.update(value="-1"), gr.update(), gr.update(), gr.update(visible=True)
|
| 507 |
else:
|
| 508 |
return gr.update(), gr.update(), gr.update(), gr.update(), gr.update(), gr.update(), gr.update(), gr.update(), gr.update(), gr.update(), gr.update()
|
| 509 |
|