Spaces:
No application file
No application file
Delete app.py
Browse files
app.py
DELETED
@@ -1,54 +0,0 @@
|
|
1 |
-
import gradio as gr
|
2 |
-
import torch
|
3 |
-
from baseline import run as run_baseline
|
4 |
-
|
5 |
-
# print(torch.cuda.is_available())
|
6 |
-
prompt_placeholder = "A painting of a dog eating hamburger."
|
7 |
-
|
8 |
-
html = f"""<h1>LLM Diffusion"""
|
9 |
-
|
10 |
-
|
11 |
-
def get_baseline_image(prompt, seed=0):
|
12 |
-
if prompt == "":
|
13 |
-
prompt = prompt_placeholder
|
14 |
-
|
15 |
-
scheduler_key = "dpm_scheduler"
|
16 |
-
num_inference_steps = 20
|
17 |
-
|
18 |
-
image_np = run_baseline(prompt, bg_seed=seed, scheduler_key=scheduler_key, num_inference_steps=num_inference_steps)
|
19 |
-
return [image_np]
|
20 |
-
|
21 |
-
|
22 |
-
with gr.Blocks(title="LLM Diffusion") as iface:
|
23 |
-
gr.HTML(html)
|
24 |
-
with gr.Tab("Our LLM Diffusion"):
|
25 |
-
with gr.Row():
|
26 |
-
with gr.Column(scale=1):
|
27 |
-
prompt = gr.Textbox(lines=2, label="Prompt for the overall image", placeholder=prompt_placeholder)
|
28 |
-
generate_btn = gr.Button("Generate", elem_classes="btn")
|
29 |
-
with gr.Column(scale=1):
|
30 |
-
output = gr.Textbox(lines=8, label="Details from LLM")
|
31 |
-
|
32 |
-
with gr.Row():
|
33 |
-
gallery = gr.Gallery(
|
34 |
-
label="Generated image", elem_id="gallery1", columns=[1], rows=[1], object_fit="contain", preview=True
|
35 |
-
)
|
36 |
-
|
37 |
-
|
38 |
-
with gr.Tab("Baseline: Stable Diffusion"):
|
39 |
-
with gr.Row():
|
40 |
-
with gr.Column(scale=1):
|
41 |
-
sd_prompt = gr.Textbox(lines=2, label="Prompt for baseline SD", placeholder=prompt_placeholder)
|
42 |
-
seed = gr.Slider(0, 10000, value=0, step=1, label="Seed")
|
43 |
-
generate_btn = gr.Button("Generate", elem_classes="btn")
|
44 |
-
# with gr.Column(scale=1):
|
45 |
-
# output = gr.Image(shape=(512, 512), elem_classes="img", elem_id="img")
|
46 |
-
with gr.Column(scale=1):
|
47 |
-
gallery = gr.Gallery(
|
48 |
-
label="Generated image", show_label=False, elem_id="gallery2", columns=[1], rows=[1], object_fit="contain", preview=True
|
49 |
-
)
|
50 |
-
generate_btn.click(fn=get_baseline_image, inputs=[sd_prompt, seed], outputs=gallery, api_name="baseline")
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
iface.launch(share=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|