Update app.py
Browse files
app.py
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
from transformers import pipeline, WhisperProcessor, WhisperForConditionalGeneration
|
| 3 |
-
from diffusers import
|
| 4 |
import torch
|
| 5 |
|
| 6 |
# 使用BART模型生成文本描述
|
|
@@ -12,13 +12,11 @@ def generate_prompt(description: str) -> str:
|
|
| 12 |
return prompt
|
| 13 |
|
| 14 |
# 加载 ByteDance/SDXL-Lightning 模型
|
| 15 |
-
|
| 16 |
-
sdxl_pipeline.to("cpu") # 使用 CPU
|
| 17 |
-
|
| 18 |
def generate_image(prompt: str):
|
| 19 |
# 根据提示生成图像
|
| 20 |
-
|
| 21 |
-
|
| 22 |
|
| 23 |
# 使用Whisper模型进行语音转文本
|
| 24 |
processor = WhisperProcessor.from_pretrained("openai/whisper-large")
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
from transformers import pipeline, WhisperProcessor, WhisperForConditionalGeneration
|
| 3 |
+
from diffusers import DiffusionPipeline
|
| 4 |
import torch
|
| 5 |
|
| 6 |
# 使用BART模型生成文本描述
|
|
|
|
| 12 |
return prompt
|
| 13 |
|
| 14 |
# 加载 ByteDance/SDXL-Lightning 模型
|
| 15 |
+
pipe = DiffusionPipeline.from_pretrained("ByteDance/SDXL-Lightning")
|
|
|
|
|
|
|
| 16 |
def generate_image(prompt: str):
|
| 17 |
# 根据提示生成图像
|
| 18 |
+
prompt = "Astronaut in a jungle, cold color palette, muted colors, detailed, 8k"
|
| 19 |
+
image = pipe(prompt).images[0]
|
| 20 |
|
| 21 |
# 使用Whisper模型进行语音转文本
|
| 22 |
processor = WhisperProcessor.from_pretrained("openai/whisper-large")
|