Dan Bochman commited on
Commit
91586d5
·
1 Parent(s): 9f57283

ZeroGPU: must import before any CUDA-related packages

Browse files
Files changed (1) hide show
  1. app.py +7 -7
app.py CHANGED
@@ -1,6 +1,13 @@
1
  import colorsys
2
  import os
3
 
 
 
 
 
 
 
 
4
  import gradio as gr
5
  import matplotlib.colors as mcolors
6
  import numpy as np
@@ -8,13 +15,6 @@ import torch
8
  from PIL import Image, ImageDraw, ImageFont
9
  from transformers import SegformerForSemanticSegmentation, SegformerImageProcessor
10
 
11
- # Handle spaces.GPU decorator for local vs HuggingFace execution
12
- try:
13
- import spaces
14
- GPU_DECORATOR = spaces.GPU
15
- except ImportError:
16
- GPU_DECORATOR = lambda func: func
17
-
18
  # ----------------- CONFIG ----------------- #
19
 
20
  ASSETS_DIR = os.path.join(os.path.dirname(__file__), "assets")
 
1
  import colorsys
2
  import os
3
 
4
+ # ZeroGPU: must import before any CUDA-related packages
5
+ try:
6
+ import spaces
7
+ GPU_DECORATOR = spaces.GPU
8
+ except ImportError:
9
+ GPU_DECORATOR = lambda func: func
10
+
11
  import gradio as gr
12
  import matplotlib.colors as mcolors
13
  import numpy as np
 
15
  from PIL import Image, ImageDraw, ImageFont
16
  from transformers import SegformerForSemanticSegmentation, SegformerImageProcessor
17
 
 
 
 
 
 
 
 
18
  # ----------------- CONFIG ----------------- #
19
 
20
  ASSETS_DIR = os.path.join(os.path.dirname(__file__), "assets")