patrickhul commited on
Commit
0bb2e75
1 Parent(s): 6c10dd3

remove demo file

Browse files
Files changed (1) hide show
  1. demo.py +0 -53
demo.py DELETED
@@ -1,53 +0,0 @@
1
- from diffusers import (
2
- StableDiffusionPipeline,
3
- PNDMScheduler,
4
- )
5
- from diffusers.models import AutoencoderKL
6
- import os
7
- import torch
8
-
9
- device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
10
-
11
- vae = AutoencoderKL.from_pretrained(
12
- "stabilityai/sd-vae-ft-ema", torch_dtype=torch.float32
13
- )
14
- common_config = {"beta_start": 0.00085, "beta_end": 0.012, "beta_schedule": "scaled_linear"}
15
- SCHEDULER = PNDMScheduler(**common_config, skip_prk_steps=True, steps_offset=1,)
16
- HF_API_TOKEN = os.getenv("HF_API_TOKEN")
17
- shared_pipe_kwargs = dict(
18
- vae=vae,
19
- torch_dtype=torch.float32,
20
- revision="fp16",
21
- use_auth_token=HF_API_TOKEN,
22
- scheduler=SCHEDULER,
23
- )
24
-
25
-
26
- base_sd_pipe = StableDiffusionPipeline.from_pretrained(
27
- "runwayml/stable-diffusion-v1-5", **shared_pipe_kwargs
28
- ).to(device)
29
-
30
- pai_model_dir = '.'
31
-
32
- playground_v1_model_dir = os.path.join(
33
- pai_model_dir, "snapshots/36c9e19103f6b897886fb019ebc4d8e86b566032"
34
- )
35
-
36
- pgv1_shared_pipe_kwargs = dict(
37
- vae=vae,
38
- torch_dtype=torch.float32,
39
- tokenizer=base_sd_pipe.tokenizer,
40
- feature_extractor=base_sd_pipe.feature_extractor,
41
- text_encoder=base_sd_pipe.text_encoder,
42
- scheduler=SCHEDULER,
43
- local_files_only=True,
44
- )
45
-
46
- pgv1_pipe = StableDiffusionPipeline.from_pretrained(
47
- playground_v1_model_dir,
48
- **pgv1_shared_pipe_kwargs,
49
- ).to(device)
50
-
51
- img = pgv1_pipe("Frog", num_inference_steps=30)
52
-
53
- img[0][0].save('frog.png')