Shilpaj commited on
Commit
28e50c7
·
verified ·
1 Parent(s): 74fa5e8

Fix: GPU usage on spaces

Browse files
Files changed (1) hide show
  1. app.py +3 -5
app.py CHANGED
@@ -8,6 +8,7 @@ Date: Feb 26, 2025
8
  import os
9
  import torch
10
  import gradio as gr
 
11
  from tqdm.auto import tqdm
12
  import numpy as np
13
  from PIL import Image
@@ -16,10 +17,7 @@ from utils import (
16
  vignette_loss, get_concept_embedding, load_concept_library, image_grid
17
  )
18
 
19
- # Hugging Face Space configuration
20
- # Use @space decorator to configure the Space
21
- # This will set the Space to use zero GPU resources
22
- @gr.Blocks.add_decorator
23
  def space(demo, **kwargs):
24
  demo.queue(concurrency_count=1, max_size=10)
25
  return demo
@@ -246,7 +244,7 @@ def generate_style_grid(prompt, seed=42, num_inference_steps=30, guidance_scale=
246
  return grid
247
 
248
  # Define Gradio interface
249
- @space
250
  def create_demo():
251
  with gr.Blocks(title="Guided Stable Diffusion with Styles") as demo:
252
  gr.Markdown("# Guided Stable Diffusion with Styles")
 
8
  import os
9
  import torch
10
  import gradio as gr
11
+ import spaces
12
  from tqdm.auto import tqdm
13
  import numpy as np
14
  from PIL import Image
 
17
  vignette_loss, get_concept_embedding, load_concept_library, image_grid
18
  )
19
 
20
+ @spaces.GPU(enable_queue=True)
 
 
 
21
  def space(demo, **kwargs):
22
  demo.queue(concurrency_count=1, max_size=10)
23
  return demo
 
244
  return grid
245
 
246
  # Define Gradio interface
247
+ @space.GPU(enable_queue=True)
248
  def create_demo():
249
  with gr.Blocks(title="Guided Stable Diffusion with Styles") as demo:
250
  gr.Markdown("# Guided Stable Diffusion with Styles")