Suchinthana commited on
Commit
e3bfe63
·
1 Parent(s): 3f8a1af

headless selenium update

Browse files
Files changed (1) hide show
  1. app.py +11 -1
app.py CHANGED
@@ -13,6 +13,9 @@ from gradio_folium import Folium
13
  from diffusers import ControlNetModel, StableDiffusionControlNetInpaintPipeline
14
  import spaces
15
 
 
 
 
16
  # Initialize APIs
17
  openai_client = OpenAI(api_key=os.environ['OPENAI_API_KEY'])
18
  geolocator = Nominatim(user_agent="geoapi")
@@ -141,7 +144,14 @@ def save_map_image(geojson_data):
141
  geo_layer.add_to(m)
142
  bounds = get_bounds(geojson_data)
143
  m.fit_bounds(bounds)
144
- img_data = m._to_png(5)
 
 
 
 
 
 
 
145
  img = Image.open(io.BytesIO(img_data))
146
  img.save('map_image.png')
147
  return 'map_image.png'
 
13
  from diffusers import ControlNetModel, StableDiffusionControlNetInpaintPipeline
14
  import spaces
15
 
16
+ from selenium.webdriver.firefox.options import Options
17
+ from selenium import webdriver
18
+
19
  # Initialize APIs
20
  openai_client = OpenAI(api_key=os.environ['OPENAI_API_KEY'])
21
  geolocator = Nominatim(user_agent="geoapi")
 
144
  geo_layer.add_to(m)
145
  bounds = get_bounds(geojson_data)
146
  m.fit_bounds(bounds)
147
+
148
+ # Configure Selenium for headless operation
149
+ options = Options()
150
+ options.add_argument("--headless") # Enable headless mode
151
+ driver = webdriver.Firefox(options=options) # Ensure GeckoDriver is properly installed and in PATH
152
+ img_data = m._to_png(5, driver=driver)
153
+ driver.quit()
154
+
155
  img = Image.open(io.BytesIO(img_data))
156
  img.save('map_image.png')
157
  return 'map_image.png'