Update app.py
Browse files
app.py
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
import gradio as gr
|
2 |
from diffusers import StableDiffusion3Pipeline
|
3 |
import torch
|
4 |
-
|
5 |
from huggingface_hub import login
|
6 |
|
7 |
# 通过环境变量获取 Token
|
@@ -11,7 +11,15 @@ hf_token = os.getenv("HF_TOKEN")
|
|
11 |
login(token=hf_token)
|
12 |
|
13 |
# 加载模型
|
14 |
-
pipe = StableDiffusion3Pipeline.from_pretrained("prithivMLmods/SD3.5-Large-Photorealistic-LoRA",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
|
16 |
# 定义图像生成函数
|
17 |
def generate_image(prompt):
|
|
|
1 |
import gradio as gr
|
2 |
from diffusers import StableDiffusion3Pipeline
|
3 |
import torch
|
4 |
+
import os
|
5 |
from huggingface_hub import login
|
6 |
|
7 |
# 通过环境变量获取 Token
|
|
|
11 |
login(token=hf_token)
|
12 |
|
13 |
# 加载模型
|
14 |
+
pipe = StableDiffusion3Pipeline.from_pretrained("prithivMLmods/SD3.5-Large-Photorealistic-LoRA",
|
15 |
+
revision="main",
|
16 |
+
torch_dtype=torch.float16)
|
17 |
+
|
18 |
+
# 如果模型需要LoRA权重文件,可以手动加载
|
19 |
+
pipe.load_lora_weights("prithivMLmods/SD3.5-Large-Photorealistic-LoRA",
|
20 |
+
weight_name="Photorealistic-SD3.5-Large-LoRA.safetensors")
|
21 |
+
|
22 |
+
pipe.fuse_lora(lora_scale=1.0)
|
23 |
|
24 |
# 定义图像生成函数
|
25 |
def generate_image(prompt):
|