HelloSun commited on
Commit
c80353d
·
verified ·
1 Parent(s): ca44ee8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +34 -1
app.py CHANGED
@@ -4,13 +4,23 @@ import random
4
  from diffusers import DiffusionPipeline
5
  from optimum.intel.openvino import OVStableDiffusionPipeline
6
  import torch
 
 
 
 
 
 
 
 
7
 
8
 
9
  model_id = "helenai/Linaqruf-anything-v3.0-ov"
 
 
10
 
11
  pipe = OVStableDiffusionPipeline.from_pretrained(model_id, compile=False)
12
  pipe.reshape( batch_size=1, height=256, width=256, num_images_per_prompt=1)
13
- pipe.scheduler = utils.get_scheduler(pipe.scheduler.config, "Euler a")
14
 
15
  pipe.compile()
16
 
@@ -34,12 +44,35 @@ def infer(prompt,negative_prompt):
34
  (((mutation))), ((mutilated)), (out of frame), ((poorly drawn face)), poorly drawn feet, \
35
  ((poorly drawn hands)), tiling, (too many fingers), ((ugly)), wierd colors, (((long neck))), \
36
  ugly, words, wrinkles, writing",
 
37
  width = 256,
38
  height = 256,
39
  ).images[0]
40
 
41
  return image
42
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
43
  examples = [
44
  "A cute kitten, Japanese cartoon style.",
45
  "A sweet family, dad stands next to mom, mom holds baby girl.",
 
4
  from diffusers import DiffusionPipeline
5
  from optimum.intel.openvino import OVStableDiffusionPipeline
6
  import torch
7
+ from typing import Callable, Dict, Optional, Tuple
8
+ from diffusers import (
9
+ DDIMScheduler,
10
+ DPMSolverMultistepScheduler,
11
+ DPMSolverSinglestepScheduler,
12
+ EulerAncestralDiscreteScheduler,
13
+ EulerDiscreteScheduler,
14
+ )
15
 
16
 
17
  model_id = "helenai/Linaqruf-anything-v3.0-ov"
18
+ num_inference_steps = 25
19
+ sampler = "Euler a"
20
 
21
  pipe = OVStableDiffusionPipeline.from_pretrained(model_id, compile=False)
22
  pipe.reshape( batch_size=1, height=256, width=256, num_images_per_prompt=1)
23
+ pipe.scheduler = get_scheduler(pipe.scheduler.config, sampler)
24
 
25
  pipe.compile()
26
 
 
44
  (((mutation))), ((mutilated)), (out of frame), ((poorly drawn face)), poorly drawn feet, \
45
  ((poorly drawn hands)), tiling, (too many fingers), ((ugly)), wierd colors, (((long neck))), \
46
  ugly, words, wrinkles, writing",
47
+ num_inference_steps=num_inference_steps,
48
  width = 256,
49
  height = 256,
50
  ).images[0]
51
 
52
  return image
53
 
54
+
55
+ def get_scheduler(scheduler_config: Dict, name: str) -> Optional[Callable]:
56
+ scheduler_factory_map = {
57
+ "DPM++ 2M Karras": lambda: DPMSolverMultistepScheduler.from_config(
58
+ scheduler_config, use_karras_sigmas=True
59
+ ),
60
+ "DPM++ SDE Karras": lambda: DPMSolverSinglestepScheduler.from_config(
61
+ scheduler_config, use_karras_sigmas=True
62
+ ),
63
+ "DPM++ 2M SDE Karras": lambda: DPMSolverMultistepScheduler.from_config(
64
+ scheduler_config, use_karras_sigmas=True, algorithm_type="sde-dpmsolver++"
65
+ ),
66
+ "Euler": lambda: EulerDiscreteScheduler.from_config(scheduler_config),
67
+ "Euler a": lambda: EulerAncestralDiscreteScheduler.from_config(
68
+ scheduler_config
69
+ ),
70
+ "DDIM": lambda: DDIMScheduler.from_config(scheduler_config),
71
+ }
72
+ return scheduler_factory_map.get(name, lambda: None)()
73
+
74
+
75
+
76
  examples = [
77
  "A cute kitten, Japanese cartoon style.",
78
  "A sweet family, dad stands next to mom, mom holds baby girl.",