Spaces:
Runtime error
Runtime error
Update app.py
#1
by
devlim
- opened
app.py
CHANGED
@@ -1,36 +1,15 @@
|
|
1 |
import gradio as gr
|
2 |
import torch
|
3 |
-
from diffusers import StableDiffusionPipeline
|
4 |
-
from safetensors.torch import load_file
|
5 |
-
import os
|
6 |
|
7 |
-
|
8 |
-
|
|
|
|
|
9 |
|
10 |
-
#
|
11 |
-
|
12 |
-
try:
|
13 |
-
# safetensors ํ์ผ ๋ก๋
|
14 |
-
state_dict = load_file(model_file)
|
15 |
-
# ๋ชจ๋ธ ์ด๊ธฐํ
|
16 |
-
model = StableDiffusionPipeline.from_pretrained(model_id, use_auth_token=use_auth_token)
|
17 |
-
# ๋ชจ๋ธ์ state_dict ๋ก๋
|
18 |
-
model.model.load_state_dict(state_dict)
|
19 |
-
return model
|
20 |
-
except Exception as e:
|
21 |
-
print(f"Error loading model: {e}")
|
22 |
-
return None
|
23 |
-
|
24 |
-
# ์ฌ๋ฐ๋ฅธ ๋ชจ๋ธ ID๋ก ์ค์
|
25 |
-
model_id = "stabilityai/stable-diffusion-2"
|
26 |
-
model_file = "./Traditional_Korean_Painting_Model_2.safetensors" # ๋ฃจํธ ๋๋ ํ ๋ฆฌ์ ์๋ ํ์ผ ๊ฒฝ๋ก ์ค์
|
27 |
|
28 |
-
pipe = load_safetensors_model(model_id, model_file, use_auth_token=HUGGINGFACE_TOKEN)
|
29 |
-
if pipe:
|
30 |
-
pipe = pipe.to("cuda" if torch.cuda.is_available() else "cpu")
|
31 |
-
print("Model loaded successfully")
|
32 |
-
else:
|
33 |
-
print("Failed to load the model")
|
34 |
|
35 |
def generate_image(prompt):
|
36 |
if not pipe:
|
|
|
1 |
import gradio as gr
|
2 |
import torch
|
3 |
+
from diffusers import StableDiffusionPipeline, EulerDiscreteScheduler
|
|
|
|
|
4 |
|
5 |
+
model_id = "gagong/Traditional-Korean-Painting-Model-v2.0"
|
6 |
+
scheduler = EulerDiscreteScheduler.from_pretrained(model_id, subfolder="scheduler")
|
7 |
+
pipe = StableDiffusionPipeline.from_pretrained(model_id, scheduler=scheduler, torch_dtype=torch.float16)
|
8 |
+
pipe = pipe.to("cuda")
|
9 |
|
10 |
+
# prompt = "a photo of an astronaut riding a horse on mars"
|
11 |
+
# image = pipe(prompt).images[0]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
|
|
|
|
|
|
|
|
|
|
|
|
|
13 |
|
14 |
def generate_image(prompt):
|
15 |
if not pipe:
|