mayhug commited on
Commit
747941d
·
1 Parent(s): 26d2f56

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -5
app.py CHANGED
@@ -6,7 +6,11 @@ from gradio import inputs, outputs
6
  from PIL import Image
7
  from torchvision import transforms
8
 
9
- model = torch.hub.load("RF5/danbooru-pretrained", "resnet50")
 
 
 
 
10
  model.eval()
11
 
12
  with open("./tags.json", "rt", encoding="utf-8") as f:
@@ -28,10 +32,6 @@ def main(input_image: Image.Image, threshold: float):
28
  0
29
  ) # create a mini-batch as expected by the model
30
 
31
- if torch.cuda.is_available():
32
- input_batch = input_batch.to("cuda")
33
- model.to("cuda")
34
-
35
  with torch.no_grad():
36
  output, *_ = model(input_batch)
37
 
 
6
  from PIL import Image
7
  from torchvision import transforms
8
 
9
+ model = torch.hub.load(
10
+ "RF5/danbooru-pretrained",
11
+ "resnet50",
12
+ map_location=torch.device("cpu"),
13
+ )
14
  model.eval()
15
 
16
  with open("./tags.json", "rt", encoding="utf-8") as f:
 
32
  0
33
  ) # create a mini-batch as expected by the model
34
 
 
 
 
 
35
  with torch.no_grad():
36
  output, *_ = model(input_batch)
37