George Krupenchenkov commited on
Commit
6d56d5a
·
1 Parent(s): 30b3a4c

hw changes

Browse files
Files changed (1) hide show
  1. app.py +10 -5
app.py CHANGED
@@ -1,21 +1,22 @@
 
 
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
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
21
  MAX_IMAGE_SIZE = 1024
@@ -23,6 +24,7 @@ MAX_IMAGE_SIZE = 1024
23
 
24
  # @spaces.GPU #[uncomment to use ZeroGPU]
25
  def infer(
 
26
  prompt,
27
  negative_prompt,
28
  seed,
@@ -32,11 +34,14 @@ def infer(
32
  guidance_scale,
33
  num_inference_steps,
34
  progress=gr.Progress(track_tqdm=True),
 
35
  ):
36
  if randomize_seed:
37
  seed = random.randint(0, MAX_SEED)
38
 
39
  generator = torch.Generator().manual_seed(seed)
 
 
40
 
41
  image = pipe(
42
  prompt=prompt,
 
1
+ import random
2
+
3
  import gradio as gr
4
  import numpy as np
5
+ import torch
6
 
7
  # import spaces #[uncomment to use ZeroGPU]
8
  from diffusers import DiffusionPipeline
 
9
 
10
  device = "cuda" if torch.cuda.is_available() else "cpu"
11
+ # model_repo_id = "stabilityai/sdxl-turbo" # Replace to the model you would like to use
12
 
13
  if torch.cuda.is_available():
14
  torch_dtype = torch.float16
15
  else:
16
  torch_dtype = torch.float32
17
 
18
+ # pipe = DiffusionPipeline.from_pretrained(model_repo_id, torch_dtype=torch_dtype)
19
+ # pipe = pipe.to(device)
20
 
21
  MAX_SEED = np.iinfo(np.int32).max
22
  MAX_IMAGE_SIZE = 1024
 
24
 
25
  # @spaces.GPU #[uncomment to use ZeroGPU]
26
  def infer(
27
+ model_repo_id,
28
  prompt,
29
  negative_prompt,
30
  seed,
 
34
  guidance_scale,
35
  num_inference_steps,
36
  progress=gr.Progress(track_tqdm=True),
37
+
38
  ):
39
  if randomize_seed:
40
  seed = random.randint(0, MAX_SEED)
41
 
42
  generator = torch.Generator().manual_seed(seed)
43
+ pipe = DiffusionPipeline.from_pretrained(model_repo_id, torch_dtype=torch_dtype)
44
+ pipe = pipe.to(device)
45
 
46
  image = pipe(
47
  prompt=prompt,