Spaces:
Running
Running
switch to CPU
Browse files
app.py
CHANGED
@@ -1,17 +1,16 @@
|
|
1 |
import gradio as gr
|
2 |
-
import
|
3 |
from PIL import Image
|
4 |
from utils import WaifuScorer
|
5 |
|
6 |
SCORER = None
|
7 |
|
8 |
|
9 |
-
@spaces.GPU
|
10 |
def score_image(image: Image.Image) -> float:
|
11 |
global SCORER
|
12 |
if SCORER is None:
|
13 |
SCORER = WaifuScorer(
|
14 |
-
device='cuda',
|
15 |
verbose=True,
|
16 |
)
|
17 |
return SCORER([image])[0]
|
|
|
1 |
import gradio as gr
|
2 |
+
import torch
|
3 |
from PIL import Image
|
4 |
from utils import WaifuScorer
|
5 |
|
6 |
SCORER = None
|
7 |
|
8 |
|
|
|
9 |
def score_image(image: Image.Image) -> float:
|
10 |
global SCORER
|
11 |
if SCORER is None:
|
12 |
SCORER = WaifuScorer(
|
13 |
+
device='cuda' if torch.cuda.is_available() else 'cpu',
|
14 |
verbose=True,
|
15 |
)
|
16 |
return SCORER([image])[0]
|