Spaces:
Runtime error
Runtime error
pengdaqian
commited on
Commit
•
2241ae1
1
Parent(s):
65c3ba9
fix more
Browse files
app.py
CHANGED
@@ -4,7 +4,7 @@ import gradio as gr
|
|
4 |
from datasets import load_dataset
|
5 |
from PIL import Image
|
6 |
|
7 |
-
from model import get_sd_small, get_sd_tiny
|
8 |
from trans_google import google_translator
|
9 |
|
10 |
from i18n import i18nTranslator
|
@@ -43,15 +43,18 @@ samplers = [
|
|
43 |
rand = random.Random()
|
44 |
translator = google_translator()
|
45 |
|
46 |
-
|
47 |
-
|
|
|
48 |
|
49 |
|
50 |
def get_pipe(width: int, height: int):
|
51 |
if width == 512 and height == 512:
|
52 |
-
return
|
|
|
|
|
53 |
else:
|
54 |
-
return
|
55 |
|
56 |
|
57 |
def infer(prompt: str, negative: str, width: int, height: int, sampler: str, steps: int, seed: int, scale):
|
|
|
4 |
from datasets import load_dataset
|
5 |
from PIL import Image
|
6 |
|
7 |
+
from model import get_sd_small, get_sd_tiny, get_sd_every
|
8 |
from trans_google import google_translator
|
9 |
|
10 |
from i18n import i18nTranslator
|
|
|
43 |
rand = random.Random()
|
44 |
translator = google_translator()
|
45 |
|
46 |
+
tiny_pipe = get_sd_tiny()
|
47 |
+
small_pipe = get_sd_small()
|
48 |
+
every_pipe = get_sd_every()
|
49 |
|
50 |
|
51 |
def get_pipe(width: int, height: int):
|
52 |
if width == 512 and height == 512:
|
53 |
+
return tiny_pipe
|
54 |
+
elif width == 256 and height == 256:
|
55 |
+
return small_pipe
|
56 |
else:
|
57 |
+
return every_pipe
|
58 |
|
59 |
|
60 |
def infer(prompt: str, negative: str, width: int, height: int, sampler: str, steps: int, seed: int, scale):
|
model.py
CHANGED
@@ -28,10 +28,17 @@ def get_sd_21():
|
|
28 |
return pipe
|
29 |
|
30 |
|
31 |
-
def
|
32 |
model_id = 'OFA-Sys/small-stable-diffusion-v0'
|
33 |
scheduler = DPMSolverMultistepScheduler.from_pretrained(model_id, subfolder="scheduler")
|
34 |
-
pipe = OVStableDiffusionPipeline.from_pretrained("
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
35 |
pipe.compile()
|
36 |
return pipe
|
37 |
|
|
|
28 |
return pipe
|
29 |
|
30 |
|
31 |
+
def get_sd_every():
|
32 |
model_id = 'OFA-Sys/small-stable-diffusion-v0'
|
33 |
scheduler = DPMSolverMultistepScheduler.from_pretrained(model_id, subfolder="scheduler")
|
34 |
+
pipe = OVStableDiffusionPipeline.from_pretrained("OpenVINO/stable-diffusion-2-1-quantized", compile=False)
|
35 |
+
pipe.compile()
|
36 |
+
return pipe
|
37 |
+
|
38 |
+
|
39 |
+
def get_sd_small():
|
40 |
+
pipe = OVStableDiffusionPipeline.from_pretrained("OpenVINO/stable-diffusion-2-1-quantized", compile=False)
|
41 |
+
pipe.reshape(batch_size=1, height=256, width=256, num_images_per_prompt=1)
|
42 |
pipe.compile()
|
43 |
return pipe
|
44 |
|