zhangyang-0123 commited on
Commit
78ea680
·
1 Parent(s): ee69d30
Files changed (1) hide show
  1. app.py +11 -2
app.py CHANGED
@@ -1,13 +1,13 @@
1
  import gradio as gr
2
  import numpy as np
3
- import random
4
 
5
  import spaces # [uncomment to use ZeroGPU]
6
  from diffusers import DiffusionPipeline
7
  import torch
8
 
9
  device = "cuda" if torch.cuda.is_available() else "cpu"
10
- model_repo_id = "stabilityai/sdxl-turbo" # Replace to the model you would like to use
11
 
12
  if torch.cuda.is_available():
13
  torch_dtype = torch.float16
@@ -17,6 +17,15 @@ else:
17
  pipe = DiffusionPipeline.from_pretrained(model_repo_id, torch_dtype=torch_dtype)
18
  pipe = pipe.to(device)
19
 
 
 
 
 
 
 
 
 
 
20
  MAX_SEED = np.iinfo(np.int32).max
21
  MAX_IMAGE_SIZE = 1024
22
 
 
1
  import gradio as gr
2
  import numpy as np
3
+ from huggingface_hub import hf_hub_download
4
 
5
  import spaces # [uncomment to use ZeroGPU]
6
  from diffusers import DiffusionPipeline
7
  import torch
8
 
9
  device = "cuda" if torch.cuda.is_available() else "cpu"
10
+ model_repo_id = "stabilityai/stable-diffusion-xl-base-1.0" # Replace to the model you would like to use
11
 
12
  if torch.cuda.is_available():
13
  torch_dtype = torch.float16
 
17
  pipe = DiffusionPipeline.from_pretrained(model_repo_id, torch_dtype=torch_dtype)
18
  pipe = pipe.to(device)
19
 
20
+ # load pruned model
21
+ pruned_pipe = DiffusionPipeline.from_pretrained(model_repo_id, torch_dtype=torch_dtype)
22
+ pruned_pipe.transformer = torch.load(
23
+ hf_hub_download("zhangyang-0123/EcoDiffPrunedModels", "model/sdxl/sdxl.pkl"),
24
+ map_location="cpu",
25
+ torch_dtype=torch_dtype,
26
+ )
27
+ pruned_pipe = pruned_pipe.to(device)
28
+
29
  MAX_SEED = np.iinfo(np.int32).max
30
  MAX_IMAGE_SIZE = 1024
31