Update app.py
Browse files
app.py
CHANGED
|
@@ -1,3 +1,50 @@
|
|
|
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
|
| 3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import torch
|
| 2 |
+
from diffusers import StableDiffusionPipeline, DDIMScheduler
|
| 3 |
import gradio as gr
|
| 4 |
|
| 5 |
+
pipe = StableDiffusionPipeline.from_pretrained("MVRL/GeoSynth")
|
| 6 |
+
# scheduler = DDIMScheduler.from_pretrained("stabilityai/stable-diffusion-2-1-base")
|
| 7 |
+
# pipe.scheduler = scheduler
|
| 8 |
+
|
| 9 |
+
def process(prompt, n_prompt, num_samples, image_resolution, ddim_steps, scale, seed, eta):
|
| 10 |
+
generator = torch.manual_seed(seed)
|
| 11 |
+
output_images = pipe(prompt,
|
| 12 |
+
height=image_resolution,
|
| 13 |
+
width=image_resolution,
|
| 14 |
+
num_inference_steps=ddim_steps,
|
| 15 |
+
guidance_scale=scale,
|
| 16 |
+
negative_prompt=n_prompt,
|
| 17 |
+
num_images_per_prompt=num_samples,
|
| 18 |
+
eta=eta,
|
| 19 |
+
generator=generator,
|
| 20 |
+
).images
|
| 21 |
+
return output_images
|
| 22 |
+
|
| 23 |
+
block = gr.Blocks().queue()
|
| 24 |
+
with block:
|
| 25 |
+
with gr.Row():
|
| 26 |
+
gr.Markdown(
|
| 27 |
+
"""
|
| 28 |
+
# GeoSynth: Contextually-Aware High-Resolution Satellite Image Synthesis
|
| 29 |
+
Srikumar Sastry*, Subash Khanal, Aayush Dhakal, Nathan Jacobs (*Corresponding Author)<br>
|
| 30 |
+
"""
|
| 31 |
+
)
|
| 32 |
+
with gr.Row():
|
| 33 |
+
with gr.Column():
|
| 34 |
+
prompt = gr.Textbox(label="Prompt")
|
| 35 |
+
run_button = gr.Button(value="Run")
|
| 36 |
+
with gr.Accordion("Advanced options", open=True):
|
| 37 |
+
num_samples = gr.Slider(label="Images", minimum=1, maximum=12, value=1, step=1)
|
| 38 |
+
image_resolution = gr.Slider(label="Image Resolution", minimum=256, maximum=768, value=512, step=64)
|
| 39 |
+
ddim_steps = gr.Slider(label="Steps", minimum=1, maximum=100, value=20, step=1)
|
| 40 |
+
scale = gr.Slider(label="Guidance Scale", minimum=0.1, maximum=30.0, value=7.5, step=0.1)
|
| 41 |
+
seed = gr.Slider(label="Seed", minimum=-1, maximum=2147483647, step=1, randomize=True)
|
| 42 |
+
eta = gr.Number(label="eta (DDIM)", value=0.0)
|
| 43 |
+
n_prompt = gr.Textbox(label="Negative Prompt",
|
| 44 |
+
value='')
|
| 45 |
+
with gr.Column():
|
| 46 |
+
result_gallery = gr.Gallery(label='Output', show_label=False, elem_id="gallery")
|
| 47 |
+
ips = [prompt, n_prompt, num_samples, image_resolution, ddim_steps, scale, seed, eta]
|
| 48 |
+
run_button.click(fn=process, inputs=ips, outputs=[result_gallery])
|
| 49 |
+
|
| 50 |
+
block.launch()
|