Merunes commited on
Commit
faeda81
·
verified ·
1 Parent(s): 70d652d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -2
app.py CHANGED
@@ -7,14 +7,14 @@ 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
14
  else:
15
  torch_dtype = torch.float32
16
 
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
@@ -23,6 +23,7 @@ MAX_IMAGE_SIZE = 1024
23
 
24
  # @spaces.GPU #[uncomment to use ZeroGPU]
25
  def infer(
 
26
  prompt,
27
  negative_prompt,
28
  seed,
@@ -39,6 +40,7 @@ def infer(
39
  generator = torch.Generator().manual_seed(seed)
40
 
41
  image = pipe(
 
42
  prompt=prompt,
43
  negative_prompt=negative_prompt,
44
  guidance_scale=guidance_scale,
@@ -69,6 +71,10 @@ with gr.Blocks(css=css) as demo:
69
  gr.Markdown(" # Text-to-Image Gradio Template")
70
 
71
  with gr.Row():
 
 
 
 
72
  prompt = gr.Text(
73
  label="Prompt",
74
  show_label=False,
 
7
  import torch
8
 
9
  device = "cuda" if torch.cuda.is_available() else "cpu"
10
+ # model_id = "stabilityai/sdxl-turbo"
11
 
12
  if torch.cuda.is_available():
13
  torch_dtype = torch.float16
14
  else:
15
  torch_dtype = torch.float32
16
 
17
+ pipe = DiffusionPipeline.from_pretrained(model_id, torch_dtype=torch_dtype)
18
  pipe = pipe.to(device)
19
 
20
  MAX_SEED = np.iinfo(np.int32).max
 
23
 
24
  # @spaces.GPU #[uncomment to use ZeroGPU]
25
  def infer(
26
+ model_id = "CompVis/stable-diffusion-v1-4",
27
  prompt,
28
  negative_prompt,
29
  seed,
 
40
  generator = torch.Generator().manual_seed(seed)
41
 
42
  image = pipe(
43
+ model_id = model_id
44
  prompt=prompt,
45
  negative_prompt=negative_prompt,
46
  guidance_scale=guidance_scale,
 
71
  gr.Markdown(" # Text-to-Image Gradio Template")
72
 
73
  with gr.Row():
74
+ model_id = gr.Dropdown(
75
+ ["stabilityai/sdxl-turbo", "CompVis/stable-diffusion-v1-4"], label="Model", info="Select the model you would like to use"
76
+ )
77
+
78
  prompt = gr.Text(
79
  label="Prompt",
80
  show_label=False,