Spaces:
Paused
Paused
Commit
Β·
d79cd74
1
Parent(s):
c4ba210
udd mapcrunch version
Browse files
app.py
CHANGED
|
@@ -127,45 +127,77 @@ with st.sidebar:
|
|
| 127 |
"Samples to Test", 1, len(golden_labels), min(3, len(golden_labels))
|
| 128 |
)
|
| 129 |
else: # Online Mode
|
| 130 |
-
st.info("Enter a
|
| 131 |
|
| 132 |
-
# Add example
|
| 133 |
-
|
|
|
|
| 134 |
|
| 135 |
-
# Create
|
| 136 |
-
|
| 137 |
|
| 138 |
-
|
| 139 |
-
|
| 140 |
-
|
| 141 |
-
|
| 142 |
-
|
| 143 |
-
|
| 144 |
-
|
| 145 |
-
|
| 146 |
-
|
| 147 |
-
|
| 148 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 149 |
|
| 150 |
-
|
| 151 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 152 |
if mapcrunch_url:
|
| 153 |
-
|
| 154 |
-
|
| 155 |
-
|
| 156 |
-
|
| 157 |
-
|
| 158 |
-
|
| 159 |
-
|
| 160 |
-
|
| 161 |
-
|
| 162 |
-
|
| 163 |
-
|
| 164 |
-
|
| 165 |
-
|
| 166 |
-
|
|
|
|
|
|
|
| 167 |
st.stop()
|
| 168 |
-
|
|
|
|
|
|
|
|
|
|
| 169 |
model_choice = st.selectbox("Model", list(MODELS_CONFIG.keys()), index=list(MODELS_CONFIG.keys()).index(DEFAULT_MODEL))
|
| 170 |
steps_per_sample = st.slider("Max Steps", 1, 20, 10)
|
| 171 |
temperature = st.slider(
|
|
|
|
| 127 |
"Samples to Test", 1, len(golden_labels), min(3, len(golden_labels))
|
| 128 |
)
|
| 129 |
else: # Online Mode
|
| 130 |
+
st.info("Enter a URL to analyze a specific location")
|
| 131 |
|
| 132 |
+
# Add example URLs
|
| 133 |
+
example_google_url = "https://www.google.com/maps/@37.8728123,-122.2445339,3a,75y,3.36h,90t/data=!3m7!1e1!3m5!1s4DTABKOpCL6hdNRgnAHTgw!2e0!6shttps:%2F%2Fstreetviewpixels-pa.googleapis.com%2Fv1%2Fthumbnail%3Fcb_client%3Dmaps_sv.tactile%26w%3D900%26h%3D600%26pitch%3D0%26panoid%3D4DTABKOpCL6hdNRgnAHTgw%26yaw%3D3.3576431!7i13312!8i6656?entry=ttu"
|
| 134 |
+
example_mapcrunch_url = "http://www.mapcrunch.com/p/37.882284_-122.269626_293.91_-6.63_0"
|
| 135 |
|
| 136 |
+
# Create tabs for different URL types
|
| 137 |
+
input_tab1, input_tab2 = st.tabs(["Google Maps URL", "MapCrunch URL"])
|
| 138 |
|
| 139 |
+
google_url = ""
|
| 140 |
+
mapcrunch_url = ""
|
| 141 |
+
golden_labels = None
|
| 142 |
+
num_samples = None
|
| 143 |
+
|
| 144 |
+
with input_tab1:
|
| 145 |
+
url_col1, url_col2 = st.columns([3, 1])
|
| 146 |
+
with url_col1:
|
| 147 |
+
google_url = st.text_input(
|
| 148 |
+
"Google Maps URL",
|
| 149 |
+
placeholder="https://www.google.com/maps/@37.5851338,-122.1519467,9z?entry=ttu",
|
| 150 |
+
key="google_maps_url",
|
| 151 |
+
)
|
| 152 |
+
st.markdown(f"π‘ **Example Location:** [View in Google Maps]({example_google_url})")
|
| 153 |
+
if google_url:
|
| 154 |
+
mapcrunch_url_converted = convert_google_to_mapcrunch_url(google_url)
|
| 155 |
+
if mapcrunch_url_converted:
|
| 156 |
+
st.success(f"Converted to MapCrunch URL: {mapcrunch_url_converted}")
|
| 157 |
+
try:
|
| 158 |
+
golden_labels = [{
|
| 159 |
+
"id": "online",
|
| 160 |
+
"lat": float(re.search(r'@(-?\d+\.\d+),(-?\d+\.\d+)', google_url).group(1)),
|
| 161 |
+
"lng": float(re.search(r'@(-?\d+\.\d+),(-?\d+\.\d+)', google_url).group(2)),
|
| 162 |
+
"url": mapcrunch_url_converted
|
| 163 |
+
}]
|
| 164 |
+
num_samples = 1
|
| 165 |
+
except Exception as e:
|
| 166 |
+
st.error(f"Invalid Google Maps URL format: {str(e)}")
|
| 167 |
+
else:
|
| 168 |
+
st.error("Invalid Google Maps URL format")
|
| 169 |
|
| 170 |
+
with input_tab2:
|
| 171 |
+
st.markdown("π‘ **Example Location:**")
|
| 172 |
+
st.markdown(f"[View in MapCrunch]({example_mapcrunch_url})")
|
| 173 |
+
st.code(example_mapcrunch_url, language="text")
|
| 174 |
+
mapcrunch_url = st.text_input(
|
| 175 |
+
"MapCrunch URL",
|
| 176 |
+
placeholder=example_mapcrunch_url,
|
| 177 |
+
key="mapcrunch_url"
|
| 178 |
+
)
|
| 179 |
if mapcrunch_url:
|
| 180 |
+
try:
|
| 181 |
+
coords = mapcrunch_url.split('/')[-1].split('_')
|
| 182 |
+
lat, lon = float(coords[0]), float(coords[1])
|
| 183 |
+
golden_labels = [{
|
| 184 |
+
"id": "online",
|
| 185 |
+
"lat": lat,
|
| 186 |
+
"lng": lon,
|
| 187 |
+
"url": mapcrunch_url
|
| 188 |
+
}]
|
| 189 |
+
num_samples = 1
|
| 190 |
+
except Exception as e:
|
| 191 |
+
st.error(f"Invalid MapCrunch URL format: {str(e)}")
|
| 192 |
+
|
| 193 |
+
# Only stop if neither input is provided
|
| 194 |
+
if not google_url and not mapcrunch_url:
|
| 195 |
+
st.warning("Please enter a Google Maps URL or MapCrunch URL, or use the example above.")
|
| 196 |
st.stop()
|
| 197 |
+
if golden_labels is None or num_samples is None:
|
| 198 |
+
st.warning("Please enter a valid URL.")
|
| 199 |
+
st.stop()
|
| 200 |
+
|
| 201 |
model_choice = st.selectbox("Model", list(MODELS_CONFIG.keys()), index=list(MODELS_CONFIG.keys()).index(DEFAULT_MODEL))
|
| 202 |
steps_per_sample = st.slider("Max Steps", 1, 20, 10)
|
| 203 |
temperature = st.slider(
|