Bordoglor commited on
Commit
3cb93df
·
verified ·
1 Parent(s): 5f00672

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -3
app.py CHANGED
@@ -23,7 +23,7 @@ MAX_IMAGE_SIZE = 1024
23
 
24
  # @spaces.GPU #[uncomment to use ZeroGPU]
25
  def infer(
26
- # model_name,
27
  prompt,
28
  negative_prompt,
29
  seed,
@@ -39,6 +39,16 @@ def infer(
39
 
40
  generator = torch.Generator().manual_seed(seed)
41
 
 
 
 
 
 
 
 
 
 
 
42
  image = pipe(
43
  prompt=prompt,
44
  negative_prompt=negative_prompt,
@@ -150,8 +160,8 @@ with gr.Blocks(css=css) as demo:
150
  triggers=[run_button.click, prompt.submit],
151
  fn=infer,
152
  inputs=[
153
- prompt,
154
  model,
 
155
  negative_prompt,
156
  seed,
157
  randomize_seed,
@@ -165,4 +175,3 @@ with gr.Blocks(css=css) as demo:
165
 
166
  if __name__ == "__main__":
167
  demo.launch()
168
-
 
23
 
24
  # @spaces.GPU #[uncomment to use ZeroGPU]
25
  def infer(
26
+ model,
27
  prompt,
28
  negative_prompt,
29
  seed,
 
39
 
40
  generator = torch.Generator().manual_seed(seed)
41
 
42
+ device = "cuda" if torch.cuda.is_available() else "cpu"
43
+
44
+ if torch.cuda.is_available():
45
+ torch_dtype = torch.float16
46
+ else:
47
+ torch_dtype = torch.float32
48
+
49
+ pipe = DiffusionPipeline.from_pretrained(model, torch_dtype=torch_dtype)
50
+ pipe = pipe.to(device)
51
+
52
  image = pipe(
53
  prompt=prompt,
54
  negative_prompt=negative_prompt,
 
160
  triggers=[run_button.click, prompt.submit],
161
  fn=infer,
162
  inputs=[
 
163
  model,
164
+ prompt,
165
  negative_prompt,
166
  seed,
167
  randomize_seed,
 
175
 
176
  if __name__ == "__main__":
177
  demo.launch()