Spaces:
Runtime error
Runtime error
Commit
·
661f197
1
Parent(s):
5788d58
Remove perspective choice, add description
Browse files
app.py
CHANGED
|
@@ -9,17 +9,11 @@ API_KEY = os.environ.get("API_KEY")
|
|
| 9 |
gmaps = googlemaps.Client(key=API_KEY)
|
| 10 |
model = ClimateGAN(model_path="config/model/masker")
|
| 11 |
|
| 12 |
-
def predict(place
|
| 13 |
geocode_result = gmaps.geocode(place)
|
| 14 |
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
if perspective == "A":
|
| 18 |
-
address = geocode_result[0]['formatted_address']
|
| 19 |
-
static_map_url = f"https://maps.googleapis.com/maps/api/streetview?size=640x640&location={parse.quote(address)}&source=outdoor&key={API_KEY}"
|
| 20 |
-
else:
|
| 21 |
-
loc = geocode_result[0]['geometry']['location']
|
| 22 |
-
static_map_url = f"https://maps.googleapis.com/maps/api/streetview?size=640x640&location={loc['lat']},{loc['lng']}&source=outdoor&key={API_KEY}"
|
| 23 |
|
| 24 |
img_np = io.imread(static_map_url)
|
| 25 |
flood, wildfire, smog = model.inference(img_np)
|
|
@@ -30,7 +24,6 @@ gr.Interface(
|
|
| 30 |
predict,
|
| 31 |
inputs=[
|
| 32 |
gr.inputs.Textbox(label="Address or place name"),
|
| 33 |
-
gr.inputs.Radio(["A", "B"], label="Perspective")
|
| 34 |
],
|
| 35 |
outputs=[
|
| 36 |
gr.outputs.Image(type="numpy", label="Original image"),
|
|
@@ -38,13 +31,13 @@ gr.Interface(
|
|
| 38 |
gr.outputs.Image(type="numpy", label="Wildfire"),
|
| 39 |
gr.outputs.Image(type="numpy", label="Smog"),
|
| 40 |
],
|
| 41 |
-
title="ClimateGAN",
|
| 42 |
-
description="Enter an address or place name, and ClimateGAN will generate images showing how the location could be impacted by flooding, wildfires, or smog.
|
| 43 |
-
article="<p style='text-align: center'>This project is
|
| 44 |
examples=[
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
],
|
| 49 |
css=".footer{display:none !important}",
|
| 50 |
).launch(cache_examples=True)
|
|
|
|
| 9 |
gmaps = googlemaps.Client(key=API_KEY)
|
| 10 |
model = ClimateGAN(model_path="config/model/masker")
|
| 11 |
|
| 12 |
+
def predict(place):
|
| 13 |
geocode_result = gmaps.geocode(place)
|
| 14 |
|
| 15 |
+
address = geocode_result[0]['formatted_address']
|
| 16 |
+
static_map_url = f"https://maps.googleapis.com/maps/api/streetview?size=640x640&location={parse.quote(address)}&source=outdoor&key={API_KEY}"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
|
| 18 |
img_np = io.imread(static_map_url)
|
| 19 |
flood, wildfire, smog = model.inference(img_np)
|
|
|
|
| 24 |
predict,
|
| 25 |
inputs=[
|
| 26 |
gr.inputs.Textbox(label="Address or place name"),
|
|
|
|
| 27 |
],
|
| 28 |
outputs=[
|
| 29 |
gr.outputs.Image(type="numpy", label="Original image"),
|
|
|
|
| 31 |
gr.outputs.Image(type="numpy", label="Wildfire"),
|
| 32 |
gr.outputs.Image(type="numpy", label="Smog"),
|
| 33 |
],
|
| 34 |
+
title="ClimateGAN: Visualize Climate Change",
|
| 35 |
+
description="Climate change does not impact everyone equally. This Space shows the effects of the climate emergency, \"one address at a time\". Visit the original experience at <a href=\"https://thisclimatedoesnotexist.com/\">ThisClimateDoesNotExist.com</a>.<br>Enter an address or place name, and ClimateGAN will generate images showing how the location could be impacted by flooding, wildfires, or smog.",
|
| 36 |
+
article="<p style='text-align: center'>This project is an unofficial clone of <a href='https://thisclimatedoesnotexist.com/'>ThisClimateDoesNotExist</a> | <a href='https://github.com/cc-ai/climategan'>ClimateGAN GitHub Repo</a></p>",
|
| 37 |
examples=[
|
| 38 |
+
"Vancouver Art Gallery",
|
| 39 |
+
"Chicago Bean",
|
| 40 |
+
"Duomo Siracusa",
|
| 41 |
],
|
| 42 |
css=".footer{display:none !important}",
|
| 43 |
).launch(cache_examples=True)
|