Spaces:
Runtime error
Runtime error
Saqib commited on
Update modules/app.py
Browse files119 unmodified lines12012112212312412512612712812913013113213313413513613713813914014114214314414512312412529 unmodified lines155156157181182183184185186187188189190191192193194195158196197159160161119 unmodified lines if not image_url: raise HTTPException(status_code=400, detail="image_url not found in request") def extract_coordinates(text): # Split the text into lines lines = text.split('\n') # Iterate through each line to find the one that contains the coordinates for line in lines: try: if line.startswith("Coordinates:"): # Remove the label and split by comma coords = line.replace("Coordinates:", "").strip() lat, lon = coords.split(',') # Further split by space to isolate numerical values latitude = float(lat.split('°')[0].strip()) longitude = float(lon.split('°')[0].strip()) return latitude, longitude except Exception as e: print("Error:", e) return None # Return None if no coordinates are found return None
headers = { 'accept': '*/*',29 unmodified lines if response.status != 200: return f"Failed to upload image: HTTP {response.status}" json_response = await response.json() if 'message' in json_response: json_response['message'] = json_response['message'].strip() coordinates = extract_coordinates(json_response['message'])
if coordinates: latitude, longitude = coordinates google_maps = f"https://www.google.com/maps/search/?api=1&query={latitude},{longitude}" json_response['message'] += f"\n\nView on Google Maps: {google_maps}" if img2location_name in json_response['message'].lower(): raise HTTPException(status_code=400, detail="We are not allowed to process this image. Please try another one.")
return json_response return json_response raise ValueError(f"Unexpected response: {json_response}")
@app.post("/pixart-sigma")async def pixart_sigma(request: Request):modules/app.py+1-40