not-lain commited on
Commit
5ca83bb
1 Parent(s): ac03925

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -3
app.py CHANGED
@@ -3,12 +3,12 @@ import cv2
3
  import numpy as np
4
  from loadimg import load_img
5
  import gradio as gr
6
- import spaces
7
  import torch
8
 
9
  model = AnimeSegmentation.from_pretrained("skytnt/anime-seg")
10
 
11
- device = "cuda"
12
  model.eval()
13
  model.to(device)
14
  img_size = model._hub_mixin_config["img_size"]
@@ -37,7 +37,7 @@ def get_mask(model, input_img, use_amp=True, s=640):
37
  pred = cv2.resize(pred, (w0, h0))[:, :, np.newaxis]
38
  return pred
39
 
40
- @spaces.GPU
41
  def process(img):
42
  path = load_img(img,output_type="str")
43
  img = cv2.cvtColor(cv2.imread(path, cv2.IMREAD_COLOR), cv2.COLOR_BGR2RGB)
 
3
  import numpy as np
4
  from loadimg import load_img
5
  import gradio as gr
6
+ # import spaces
7
  import torch
8
 
9
  model = AnimeSegmentation.from_pretrained("skytnt/anime-seg")
10
 
11
+ device = "cuda" if torch.cuda.is_available() else "cpu"
12
  model.eval()
13
  model.to(device)
14
  img_size = model._hub_mixin_config["img_size"]
 
37
  pred = cv2.resize(pred, (w0, h0))[:, :, np.newaxis]
38
  return pred
39
 
40
+ # @spaces.GPU
41
  def process(img):
42
  path = load_img(img,output_type="str")
43
  img = cv2.cvtColor(cv2.imread(path, cv2.IMREAD_COLOR), cv2.COLOR_BGR2RGB)