Spaces:
Runtime error
Runtime error
File size: 1,584 Bytes
2096159 4b2459f 4756ce1 4b2459f 4756ce1 4b2459f 4756ce1 4b2459f c557eb7 4b2459f 4756ce1 4b2459f c557eb7 4b2459f 4756ce1 c557eb7 4756ce1 c557eb7 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
import os
import gradio as gr
import googlemaps
from skimage import io
from inferences import ClimateGAN
API_KEY = os.environ.get("API_KEY")
gmaps = googlemaps.Client(key=API_KEY)
model = ClimateGAN(model_path="config/model/masker")
def predict(place):
geocode_result = gmaps.geocode(place)
loc = geocode_result[0]['geometry']['location']
static_map_url = f"https://maps.googleapis.com/maps/api/streetview?size=640x640&location={loc['lat']},{loc['lng']}&source=outdoor&key={API_KEY}"
img_np = io.imread(static_map_url)
flood, wildfire, smog = model.inference(img_np)
return img_np, flood, wildfire, smog
gr.Interface(
predict,
inputs=[
gr.inputs.Textbox(label="Address or place name")
],
outputs=[
gr.outputs.Image(type="numpy", label="Original image"),
gr.outputs.Image(type="numpy", label="Flooding"),
gr.outputs.Image(type="numpy", label="Wildfire"),
gr.outputs.Image(type="numpy", label="Smog"),
],
title="ClimateGAN",
description="Enter an address or place name, and ClimateGAN will generate images showing how the location could be impacted by flooding, wildfires, or smog.",
article="<p style='text-align: center'>This project is a clone of <a href='https://thisclimatedoesnotexist.com/'>ThisClimateDoesNotExist</a> | <a href='https://github.com/cc-ai/climategan'>ClimateGAN GitHub Repo</a></p>",
examples=[
"Vancouver Art Gallery",
"Chicago Bean",
"Duomo Siracusa"
],
css=".footer{display:none !important}",
).launch(cache_examples=True)
|