Tramac commited on
Commit
68f7549
1 Parent(s): a6d50c2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -5
app.py CHANGED
@@ -1,3 +1,4 @@
 
1
  import spaces
2
  import gradio as gr
3
 
@@ -5,11 +6,13 @@ from diffusers import StableDiffusionPipeline
5
 
6
 
7
  repo = "Tramac/style-portrait-v1-5"
8
- pipeline = StableDiffusionPipeline.from_pretrained(
9
- repo,
10
- torch_dtype=torch.float16,
11
- variant="fp16"
12
- ).to("cuda")
 
 
13
 
14
  @spaces.GPU(enable_queue=True)
15
  def generate_image(prompt, neg_prompt):
 
1
+ import torch
2
  import spaces
3
  import gradio as gr
4
 
 
6
 
7
 
8
  repo = "Tramac/style-portrait-v1-5"
9
+ # Ensure model and scheduler are initialized in GPU-enabled function
10
+ if torch.cuda.is_available():
11
+ pipeline = StableDiffusionPipeline.from_pretrained(
12
+ repo,
13
+ torch_dtype=torch.float16,
14
+ variant="fp16"
15
+ ).to("cuda")
16
 
17
  @spaces.GPU(enable_queue=True)
18
  def generate_image(prompt, neg_prompt):