Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from diffusers import DiffusionPipeline
|
3 |
+
|
4 |
+
# 加载模型
|
5 |
+
pipeline = DiffusionPipeline.from_pretrained("shuttleai/shuttle-3-diffusion-fp8")
|
6 |
+
|
7 |
+
# 定义生成函数
|
8 |
+
def generate_image(prompt):
|
9 |
+
image = pipeline(prompt).images[0]
|
10 |
+
return image
|
11 |
+
|
12 |
+
# 创建 Gradio 界面
|
13 |
+
interface = gr.Interface(
|
14 |
+
fn=generate_image,
|
15 |
+
inputs=gr.Textbox(label="输入提示词"),
|
16 |
+
outputs=gr.Image(label="生成的图像"),
|
17 |
+
title="Shuttle-3 Diffusion FP8 图像生成",
|
18 |
+
description="输入提示词,生成图像。"
|
19 |
+
)
|
20 |
+
|
21 |
+
# 启动应用
|
22 |
+
interface.launch()
|