Update app.py
Browse files
app.py
CHANGED
@@ -1,6 +1,10 @@
|
|
1 |
import gradio as gr
|
2 |
from model_pipelines import load_pipelines, generate_all
|
3 |
from grace_eval import compute_sample_scores, plot_radar
|
|
|
|
|
|
|
|
|
4 |
|
5 |
pipes = load_pipelines()
|
6 |
|
@@ -14,14 +18,16 @@ def show_leaderboard(prompt):
|
|
14 |
return "radar.png"
|
15 |
|
16 |
with gr.Blocks() as demo:
|
17 |
-
gr.Markdown("# 图像生成模型对比实验")
|
18 |
|
19 |
with gr.Tab("Arena"):
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
|
|
|
|
25 |
btn.click(compare, inputs=prompt, outputs=[out1, out2, out3])
|
26 |
|
27 |
with gr.Tab("Leaderboard"):
|
|
|
1 |
import gradio as gr
|
2 |
from model_pipelines import load_pipelines, generate_all
|
3 |
from grace_eval import compute_sample_scores, plot_radar
|
4 |
+
import torch
|
5 |
+
|
6 |
+
# 强制使用CPU
|
7 |
+
torch.backends.cuda.is_available = lambda: False
|
8 |
|
9 |
pipes = load_pipelines()
|
10 |
|
|
|
18 |
return "radar.png"
|
19 |
|
20 |
with gr.Blocks() as demo:
|
21 |
+
gr.Markdown("# 图像生成模型对比实验 (CPU模式)")
|
22 |
|
23 |
with gr.Tab("Arena"):
|
24 |
+
with gr.Row():
|
25 |
+
prompt = gr.Textbox(label="请输入生成文本", scale=4)
|
26 |
+
btn = gr.Button("生成图像", scale=1)
|
27 |
+
with gr.Row():
|
28 |
+
out1 = gr.Image(label="StableDiffusion v1.5")
|
29 |
+
out2 = gr.Image(label="Openjourney v4")
|
30 |
+
out3 = gr.Image(label="LDM 256")
|
31 |
btn.click(compare, inputs=prompt, outputs=[out1, out2, out3])
|
32 |
|
33 |
with gr.Tab("Leaderboard"):
|