pengdaqian commited on
Commit
2241ae1
1 Parent(s): 65c3ba9
Files changed (2) hide show
  1. app.py +8 -5
  2. model.py +9 -2
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
- pipe = get_sd_tiny()
47
- other_pipe = get_sd_small()
 
48
 
49
 
50
  def get_pipe(width: int, height: int):
51
  if width == 512 and height == 512:
52
- return pipe
 
 
53
  else:
54
- return other_pipe
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 get_sd_small():
32
  model_id = 'OFA-Sys/small-stable-diffusion-v0'
33
  scheduler = DPMSolverMultistepScheduler.from_pretrained(model_id, subfolder="scheduler")
34
- pipe = OVStableDiffusionPipeline.from_pretrained("OFA-Sys/small-stable-diffusion-v0", compile=False)
 
 
 
 
 
 
 
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