Update app.py
Browse files
app.py
CHANGED
@@ -4,7 +4,7 @@ from transformers import pipeline
|
|
4 |
from gtts import gTTS
|
5 |
import torch
|
6 |
import os
|
7 |
-
|
8 |
# ----------------------------
|
9 |
# 1. 图像描述生成函数
|
10 |
# ----------------------------
|
@@ -54,14 +54,9 @@ def load_image_generator():
|
|
54 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
55 |
|
56 |
# 导入 StableDiffusionPipeline
|
57 |
-
from diffusers import StableDiffusionPipeline
|
58 |
-
|
59 |
# 对于 GPU,采用 fp16 精度以加速推理;否则使用默认精度
|
60 |
torch_dtype = torch.float16 if device == "cuda" else torch.float32
|
61 |
-
pipe =
|
62 |
-
"stabilityai/stable-diffusion-v1-5",
|
63 |
-
torch_dtype=torch_dtype
|
64 |
-
)
|
65 |
pipe = pipe.to(device)
|
66 |
return pipe
|
67 |
|
|
|
4 |
from gtts import gTTS
|
5 |
import torch
|
6 |
import os
|
7 |
+
from diffusers import DiffusionPipeline
|
8 |
# ----------------------------
|
9 |
# 1. 图像描述生成函数
|
10 |
# ----------------------------
|
|
|
54 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
55 |
|
56 |
# 导入 StableDiffusionPipeline
|
|
|
|
|
57 |
# 对于 GPU,采用 fp16 精度以加速推理;否则使用默认精度
|
58 |
torch_dtype = torch.float16 if device == "cuda" else torch.float32
|
59 |
+
pipe = DiffusionPipeline.from_pretrained("stable-diffusion-v1-5/stable-diffusion-v1-5")
|
|
|
|
|
|
|
60 |
pipe = pipe.to(device)
|
61 |
return pipe
|
62 |
|