Spaces:
Sleeping
Sleeping
Commit
·
d140f7d
1
Parent(s):
f11fb28
add small format fix
Browse files- benchmark.py +9 -2
- mapcrunch_controller.py +1 -1
- readme.md +3 -1
- select_regions.py +66 -0
benchmark.py
CHANGED
|
@@ -102,7 +102,8 @@ class MapGuesserBenchmark:
|
|
| 102 |
headless=self.headless,
|
| 103 |
) as bot:
|
| 104 |
for i, sample in enumerate(test_samples):
|
| 105 |
-
print(
|
|
|
|
| 106 |
try:
|
| 107 |
result = self.run_single_test_with_bot(bot, sample)
|
| 108 |
all_results.append(result)
|
|
@@ -114,7 +115,7 @@ class MapGuesserBenchmark:
|
|
| 114 |
dist_str = (
|
| 115 |
f"{distance:.1f} km" if distance is not None else "N/A"
|
| 116 |
)
|
| 117 |
-
print(f"
|
| 118 |
|
| 119 |
except KeyboardInterrupt:
|
| 120 |
raise
|
|
@@ -165,6 +166,12 @@ class MapGuesserBenchmark:
|
|
| 165 |
# **核心修复**: 从顶级的 "lat" 和 "lng" 键构造真实坐标字典
|
| 166 |
true_coords = {"lat": location_data.get("lat"), "lng": location_data.get("lng")}
|
| 167 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 168 |
distance_km = self.calculate_distance(true_coords, predicted_lat_lon)
|
| 169 |
|
| 170 |
is_success = distance_km is not None and distance_km <= SUCCESS_THRESHOLD_KM
|
|
|
|
| 102 |
headless=self.headless,
|
| 103 |
) as bot:
|
| 104 |
for i, sample in enumerate(test_samples):
|
| 105 |
+
print('########################################################')
|
| 106 |
+
print(f"📍 Sample {i + 1}/{len(test_samples)}")
|
| 107 |
try:
|
| 108 |
result = self.run_single_test_with_bot(bot, sample)
|
| 109 |
all_results.append(result)
|
|
|
|
| 115 |
dist_str = (
|
| 116 |
f"{distance:.1f} km" if distance is not None else "N/A"
|
| 117 |
)
|
| 118 |
+
print(f"{status} (Distance: {dist_str})")
|
| 119 |
|
| 120 |
except KeyboardInterrupt:
|
| 121 |
raise
|
|
|
|
| 166 |
# **核心修复**: 从顶级的 "lat" 和 "lng" 键构造真实坐标字典
|
| 167 |
true_coords = {"lat": location_data.get("lat"), "lng": location_data.get("lng")}
|
| 168 |
|
| 169 |
+
true_location = location_data["address"]
|
| 170 |
+
print(f"🔍 True location: {true_location}")
|
| 171 |
+
# print true coords
|
| 172 |
+
print(f"🔍 True coords: {true_coords}")
|
| 173 |
+
# print predicted coords
|
| 174 |
+
print(f"🔍 Predicted coords: {predicted_lat_lon}")
|
| 175 |
distance_km = self.calculate_distance(true_coords, predicted_lat_lon)
|
| 176 |
|
| 177 |
is_success = distance_km is not None and distance_km <= SUCCESS_THRESHOLD_KM
|
mapcrunch_controller.py
CHANGED
|
@@ -130,7 +130,7 @@ class MapCrunchController:
|
|
| 130 |
|
| 131 |
# 策略B:优先尝试通过JS直接设置场景,速度最快
|
| 132 |
if pano_id and pov:
|
| 133 |
-
print(f"✅ Loading location via JS Call: PanoID {pano_id[:10]}...")
|
| 134 |
self.driver.execute_script(
|
| 135 |
"window.panorama.setPano(arguments[0]);"
|
| 136 |
"window.panorama.setPov(arguments[1]);",
|
|
|
|
| 130 |
|
| 131 |
# 策略B:优先尝试通过JS直接设置场景,速度最快
|
| 132 |
if pano_id and pov:
|
| 133 |
+
# print(f"✅ Loading location via JS Call: PanoID {pano_id[:10]}...")
|
| 134 |
self.driver.execute_script(
|
| 135 |
"window.panorama.setPano(arguments[0]);"
|
| 136 |
"window.panorama.setPov(arguments[1]);",
|
readme.md
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
|
|
|
|
|
| 1 |
python main.py --mode data --samples 50 --urban --no-indoor
|
| 2 |
|
| 3 |
|
| 4 |
-
python main.py --mode benchmark --models gpt-4o
|
|
|
|
| 1 |
+
uv sync
|
| 2 |
+
|
| 3 |
python main.py --mode data --samples 50 --urban --no-indoor
|
| 4 |
|
| 5 |
|
| 6 |
+
python main.py --mode benchmark --models gpt-4o --samples 5
|
select_regions.py
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import pyautogui
|
| 2 |
+
from pynput import keyboard
|
| 3 |
+
import yaml
|
| 4 |
+
|
| 5 |
+
|
| 6 |
+
regions = [
|
| 7 |
+
"screen_top_left",
|
| 8 |
+
"screen_bot_right",
|
| 9 |
+
]
|
| 10 |
+
|
| 11 |
+
map_regions = [
|
| 12 |
+
"map_top_left",
|
| 13 |
+
"map_bot_right",
|
| 14 |
+
"confirm_button",
|
| 15 |
+
"kodiak",
|
| 16 |
+
"hobart",
|
| 17 |
+
]
|
| 18 |
+
|
| 19 |
+
next_round_button = "next_round_button"
|
| 20 |
+
|
| 21 |
+
coords = []
|
| 22 |
+
|
| 23 |
+
PRESS_KEY = "a"
|
| 24 |
+
|
| 25 |
+
|
| 26 |
+
def on_press(key):
|
| 27 |
+
try:
|
| 28 |
+
if key.char == PRESS_KEY:
|
| 29 |
+
x, y = pyautogui.position()
|
| 30 |
+
print(x, y)
|
| 31 |
+
coords.append([x, y])
|
| 32 |
+
return False
|
| 33 |
+
except AttributeError:
|
| 34 |
+
pass
|
| 35 |
+
|
| 36 |
+
|
| 37 |
+
def get_coords(players=1):
|
| 38 |
+
for region in regions:
|
| 39 |
+
print(f"Move the mouse to the {region} region and press 'a'.")
|
| 40 |
+
with keyboard.Listener(on_press=on_press) as keyboard_listener:
|
| 41 |
+
keyboard_listener.join(timeout=40)
|
| 42 |
+
|
| 43 |
+
for p in range(1, players+1):
|
| 44 |
+
for region in map_regions:
|
| 45 |
+
region = region + f"_{p}"
|
| 46 |
+
regions.append(region)
|
| 47 |
+
print(f"Move the mouse to the {region} region and press 'a'.")
|
| 48 |
+
with keyboard.Listener(on_press=on_press) as keyboard_listener:
|
| 49 |
+
keyboard_listener.join(timeout=40)
|
| 50 |
+
|
| 51 |
+
regions.append(next_round_button)
|
| 52 |
+
print(f"Move the mouse to the {next_round_button} region and press 'a'.")
|
| 53 |
+
with keyboard.Listener(on_press=on_press) as keyboard_listener:
|
| 54 |
+
keyboard_listener.join(timeout=40)
|
| 55 |
+
|
| 56 |
+
screen_regions = {reg: coord for reg, coord in zip(regions, coords)}
|
| 57 |
+
|
| 58 |
+
# save dict as a yaml file
|
| 59 |
+
with open("screen_regions.yaml", "w") as f:
|
| 60 |
+
yaml.dump(screen_regions, f)
|
| 61 |
+
|
| 62 |
+
return screen_regions
|
| 63 |
+
|
| 64 |
+
|
| 65 |
+
if __name__ == "__main__":
|
| 66 |
+
_ = get_coords(players=1)
|