softwareweaver commited on
Commit
dfa11c0
·
1 Parent(s): 743b0b6

Multiple models

Browse files
Files changed (1) hide show
  1. app.py +15 -1
app.py CHANGED
@@ -9,6 +9,12 @@ import torch
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
14
  else:
@@ -17,11 +23,13 @@ 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
 
23
 
24
- # @spaces.GPU #[uncomment to use ZeroGPU]
25
  def infer(
26
  prompt,
27
  negative_prompt,
@@ -77,6 +85,12 @@ with gr.Blocks(css=css) as demo:
77
  container=False,
78
  )
79
 
 
 
 
 
 
 
80
  run_button = gr.Button("Run", scale=0, variant="primary")
81
 
82
  result = gr.Image(label="Result", show_label=False)
 
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
+ MODEL_CHOICES = [
13
+ "stabilityai/sdxl-turbo",
14
+ "stabilityai/sd-turbo",
15
+ "CompVis/stable-diffusion-v1-4",
16
+ ]
17
+
18
  if torch.cuda.is_available():
19
  torch_dtype = torch.float16
20
  else:
 
23
  pipe = DiffusionPipeline.from_pretrained(model_repo_id, torch_dtype=torch_dtype)
24
  pipe = pipe.to(device)
25
 
26
+ current_model_id = model_repo_id
27
+
28
  MAX_SEED = np.iinfo(np.int32).max
29
  MAX_IMAGE_SIZE = 1024
30
 
31
 
32
+ @spaces.GPU #[uncomment to use ZeroGPU]
33
  def infer(
34
  prompt,
35
  negative_prompt,
 
85
  container=False,
86
  )
87
 
88
+ model_dropdown = gr.Dropdown(
89
+ label="Diffusion model",
90
+ choices=MODEL_CHOICES,
91
+ value=model_repo_id,
92
+ )
93
+
94
  run_button = gr.Button("Run", scale=0, variant="primary")
95
 
96
  result = gr.Image(label="Result", show_label=False)