Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
Update app.py
Browse files
app.py
CHANGED
|
@@ -284,6 +284,14 @@ class Engine(object):
|
|
| 284 |
def load_images_and_coordinates(self, csv_file):
|
| 285 |
# Load the CSV
|
| 286 |
df = pd.read_csv(csv_file)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 287 |
# Put image with id 732681614433401 on the top and then all the rest below
|
| 288 |
df['id'] = df['id'].astype(str)
|
| 289 |
df = pd.concat([df[df['id'] == '495204901603170'], df[df['id'] != '495204901603170']])
|
|
@@ -416,7 +424,7 @@ class Engine(object):
|
|
| 416 |
)
|
| 417 |
# You: } \green{OSV-Bot: GeoScore: XX, distance: XX
|
| 418 |
|
| 419 |
-
self.cache(self.index
|
| 420 |
return self.get_figure(), result_text, df
|
| 421 |
|
| 422 |
def next_image(self):
|
|
@@ -472,8 +480,9 @@ class Engine(object):
|
|
| 472 |
# Function to save the game state
|
| 473 |
def cache(self, index, score, distance, location, time_elapsed):
|
| 474 |
with scheduler.lock:
|
|
|
|
| 475 |
os.makedirs(join(JSON_DATASET_DIR, self.tag), exist_ok=True)
|
| 476 |
-
with open(join(JSON_DATASET_DIR, self.tag, f'{
|
| 477 |
json.dump({"lat": location[0], "lon": location[1], "time": time_elapsed, "user": self.tag}, f)
|
| 478 |
f.write('\n')
|
| 479 |
|
|
|
|
| 284 |
def load_images_and_coordinates(self, csv_file):
|
| 285 |
# Load the CSV
|
| 286 |
df = pd.read_csv(csv_file)
|
| 287 |
+
|
| 288 |
+
# order
|
| 289 |
+
self.order = np.arange(len(df))
|
| 290 |
+
np.random.shuffle(self.order) # Shuffle the order array
|
| 291 |
+
|
| 292 |
+
# Reorder the DataFrame based on the shuffled order
|
| 293 |
+
df = df.iloc[self.order].reset_index(drop=True)
|
| 294 |
+
|
| 295 |
# Put image with id 732681614433401 on the top and then all the rest below
|
| 296 |
df['id'] = df['id'].astype(str)
|
| 297 |
df = pd.concat([df[df['id'] == '495204901603170'], df[df['id'] != '495204901603170']])
|
|
|
|
| 424 |
)
|
| 425 |
# You: } \green{OSV-Bot: GeoScore: XX, distance: XX
|
| 426 |
|
| 427 |
+
self.cache(self.index, score, distance, (click_lat, click_lon), time_elapsed)
|
| 428 |
return self.get_figure(), result_text, df
|
| 429 |
|
| 430 |
def next_image(self):
|
|
|
|
| 480 |
# Function to save the game state
|
| 481 |
def cache(self, index, score, distance, location, time_elapsed):
|
| 482 |
with scheduler.lock:
|
| 483 |
+
order_id = self.order[index] + 1
|
| 484 |
os.makedirs(join(JSON_DATASET_DIR, self.tag), exist_ok=True)
|
| 485 |
+
with open(join(JSON_DATASET_DIR, self.tag, f'{order_id}.json'), 'w') as f:
|
| 486 |
json.dump({"lat": location[0], "lon": location[1], "time": time_elapsed, "user": self.tag}, f)
|
| 487 |
f.write('\n')
|
| 488 |
|