Spaces:
Runtime error
Runtime error
import os | |
import gradio as gr | |
import googlemaps | |
from skimage import io | |
os.system('gdown https://drive.google.com/u/0/uc?id=18OCUIy7JQ2Ow_-cC5xn_hhDn-Bp45N1K') | |
os.system('unzip release-github-v1.zip') | |
os.system('mkdir config') | |
os.system('mv model config') | |
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=400x400&location={loc['lat']},{loc['lng']}&fov=80&heading=70&pitch=0&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=["image", "image", "image", "image"], | |
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=[ | |
"Kafka's Great Northern Way, Vancouver", | |
"Simon Fraser University", | |
"Duomo, Milano" | |
], | |
css=".footer{display:none !important}", | |
).launch() | |