Spaces:
Running
on
Zero
Running
on
Zero
fix some nits
#2
by
pandora-s
- opened
app.py
CHANGED
|
@@ -159,7 +159,7 @@ def llm_stream_image_text(image_bytes: bytes):
|
|
| 159 |
kwargs = {
|
| 160 |
'input_ids': input_ids.to(model.device),
|
| 161 |
'attention_mask': attention_mask.to(model.device),
|
| 162 |
-
'max_new_tokens':
|
| 163 |
}
|
| 164 |
if 'pixel_values' in tokenized and len(tokenized.pixel_values) > 0:
|
| 165 |
pixel_values = torch.tensor(tokenized.pixel_values[0], dtype=model.dtype).unsqueeze(0).to(model.device)
|
|
@@ -420,7 +420,7 @@ def gr_submit_guess(round_id: str, lat: float, lng: float, username: str, reques
|
|
| 420 |
.replace('__GMAPS_KEY__', GOOGLE_MAPS_API_KEY or '')
|
| 421 |
return popup_html, result_text, rnd['lat'], rnd['lng'], score
|
| 422 |
|
| 423 |
-
def extract_coords_from_text(text: str)
|
| 424 |
import re
|
| 425 |
m = re.search(r"\[ANSWER\]\s*([+-]?\d+(?:\.\d+)?)\s*,\s*([+-]?\d+(?:\.\d+)?)\s*\[/ANSWER\]", text, re.IGNORECASE)
|
| 426 |
if not m:
|
|
@@ -430,8 +430,7 @@ def extract_coords_from_text(text: str) -> Optional[Dict[str, float]]:
|
|
| 430 |
lng = float(m.group(2))
|
| 431 |
return {'lat': lat, 'lng': lng}
|
| 432 |
except Exception:
|
| 433 |
-
return
|
| 434 |
-
|
| 435 |
|
| 436 |
def geocode_text_to_coords(query: str) -> Optional[Dict[str, float]]:
|
| 437 |
if not GOOGLE_MAPS_API_KEY:
|
|
|
|
| 159 |
kwargs = {
|
| 160 |
'input_ids': input_ids.to(model.device),
|
| 161 |
'attention_mask': attention_mask.to(model.device),
|
| 162 |
+
'max_new_tokens': 80_000,
|
| 163 |
}
|
| 164 |
if 'pixel_values' in tokenized and len(tokenized.pixel_values) > 0:
|
| 165 |
pixel_values = torch.tensor(tokenized.pixel_values[0], dtype=model.dtype).unsqueeze(0).to(model.device)
|
|
|
|
| 420 |
.replace('__GMAPS_KEY__', GOOGLE_MAPS_API_KEY or '')
|
| 421 |
return popup_html, result_text, rnd['lat'], rnd['lng'], score
|
| 422 |
|
| 423 |
+
def extract_coords_from_text(text: str):
|
| 424 |
import re
|
| 425 |
m = re.search(r"\[ANSWER\]\s*([+-]?\d+(?:\.\d+)?)\s*,\s*([+-]?\d+(?:\.\d+)?)\s*\[/ANSWER\]", text, re.IGNORECASE)
|
| 426 |
if not m:
|
|
|
|
| 430 |
lng = float(m.group(2))
|
| 431 |
return {'lat': lat, 'lng': lng}
|
| 432 |
except Exception:
|
| 433 |
+
return {'lat': 0, 'lng': 0} # instead of defaulting to geocode it will return 0 as default when failing
|
|
|
|
| 434 |
|
| 435 |
def geocode_text_to_coords(query: str) -> Optional[Dict[str, float]]:
|
| 436 |
if not GOOGLE_MAPS_API_KEY:
|