Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -28,12 +28,16 @@ def load_model(model_name):
|
|
28 |
model_path = models[model_name]
|
29 |
if torch.cuda.is_available():
|
30 |
torch.cuda.max_memory_allocated(device=device)
|
31 |
-
pipe = DiffusionPipeline.from_pretrained(model_path, torch_dtype=torch.float16, variant="fp16"
|
32 |
pipe.enable_xformers_memory_efficient_attention()
|
33 |
else:
|
34 |
-
pipe = DiffusionPipeline.from_pretrained(model_path
|
35 |
pipe = pipe.to(device)
|
36 |
|
|
|
|
|
|
|
|
|
37 |
pipelines[model_name] = pipe
|
38 |
return pipe
|
39 |
|
@@ -49,13 +53,13 @@ def infer(model_name, prompt, negative_prompt, seed, randomize_seed, width, heig
|
|
49 |
generator = torch.Generator().manual_seed(seed)
|
50 |
|
51 |
image = pipe(
|
52 |
-
prompt
|
53 |
-
negative_prompt
|
54 |
-
guidance_scale
|
55 |
-
num_inference_steps
|
56 |
-
width
|
57 |
-
height
|
58 |
-
generator
|
59 |
).images[0]
|
60 |
|
61 |
return image
|
|
|
28 |
model_path = models[model_name]
|
29 |
if torch.cuda.is_available():
|
30 |
torch.cuda.max_memory_allocated(device=device)
|
31 |
+
pipe = DiffusionPipeline.from_pretrained(model_path, torch_dtype=torch.float16, variant="fp16")
|
32 |
pipe.enable_xformers_memory_efficient_attention()
|
33 |
else:
|
34 |
+
pipe = DiffusionPipeline.from_pretrained(model_path)
|
35 |
pipe = pipe.to(device)
|
36 |
|
37 |
+
# Disable NSFW filters if the pipeline supports it
|
38 |
+
if hasattr(pipe, 'safety_checker'):
|
39 |
+
pipe.safety_checker = None
|
40 |
+
|
41 |
pipelines[model_name] = pipe
|
42 |
return pipe
|
43 |
|
|
|
53 |
generator = torch.Generator().manual_seed(seed)
|
54 |
|
55 |
image = pipe(
|
56 |
+
prompt=prompt,
|
57 |
+
negative_prompt=negative_prompt,
|
58 |
+
guidance_scale=guidance_scale,
|
59 |
+
num_inference_steps=num_inference_steps,
|
60 |
+
width=width,
|
61 |
+
height=height,
|
62 |
+
generator=generator
|
63 |
).images[0]
|
64 |
|
65 |
return image
|