@@ -42,9 +42,11 @@ def from_config(config):
42
42
"KLMS" : LMSDiscreteScheduler ,
43
43
}
44
44
45
+ EMBEDDINGS = [(x .split ("." )[0 ], "/embeddings/" + x ) for x in os .listdir ("/embeddings/" )]
46
+ EMBEDDING_TOKENS = [x [0 ] for x in EMBEDDINGS ]
47
+ EMBEDDING_PATHS = [x [1 ] for x in EMBEDDINGS ]
45
48
46
-
47
- MODEL_ID = "pagebrain/$MODEL_NAME"
49
+ MODEL_ID = "pagebrain/realistic-vision-v5-1"
48
50
MODEL_CACHE = "diffusers-cache"
49
51
SAFETY_MODEL_ID = "CompVis/stable-diffusion-safety-checker"
50
52
@@ -67,23 +69,24 @@ def run_safety_checker(self, image):
67
69
def setup (self ):
68
70
"""Load the model into memory to make running multiple predictions efficient"""
69
71
self .safety_checker = StableDiffusionSafetyChecker .from_pretrained (
70
- ". /model/safety_checker" ,
72
+ "/model/safety_checker" ,
71
73
# cache_dir=MODEL_CACHE,
72
74
local_files_only = True ,
73
75
torch_dtype = torch .float16 ,
74
76
).to ("cuda" )
75
77
76
- self .feature_extractor = CLIPImageProcessor .from_pretrained (". /model/feature_extractor" )
78
+ self .feature_extractor = CLIPImageProcessor .from_pretrained ("/model/feature_extractor" )
77
79
78
80
print ("Loading txt2img pipeline..." )
79
81
self .txt2img_pipe = StableDiffusionPipeline .from_pretrained (
80
- ". /model/" ,
82
+ "/model/" ,
81
83
# cache_dir=MODEL_CACHE,
82
84
local_files_only = True ,
83
85
use_safetensors = True ,
84
86
safety_checker = None ,
85
87
requires_safety_checker = False
86
88
)
89
+ self .txt2img_pipe .load_textual_inversion (EMBEDDING_PATHS , token = EMBEDDING_TOKENS , local_files_only = True )
87
90
self .txt2img_pipe .to ("cuda" )
88
91
89
92
print ("Loading img2img pipeline..." )
@@ -124,7 +127,7 @@ def predict(
124
127
default = None ,
125
128
),
126
129
negative_prompt : str = Input (
127
- description = "Specify things to not see in the output" ,
130
+ description = "Specify things to not see in the output. Supported embeddings: " + ", " . join ( EMBEDDING_TOKENS ) ,
128
131
default = None ,
129
132
),
130
133
image : Path = Input (
0 commit comments