ethanNeuralImage commited on
Commit
47689a5
1 Parent(s): 9d408b4

sed device to cpu if cuda is not there

Browse files
Files changed (2) hide show
  1. app.py +1 -1
  2. models/stylegan2/op/fused_act.py +2 -1
app.py CHANGED
@@ -27,7 +27,7 @@ from PIL import Image
27
  opts_args = ['--no_fine_mapper']
28
  opts = GradioTestOptions().parse(opts_args)
29
  device = 'cuda' if torch.cuda.is_available() else 'cpu'
30
- opts.device= device if opts.device is None else opts.device
31
 
32
  mapper_dict = {
33
  'afro':'./pretrained_models/styleCLIP_mappers/afro_hairstyle.pt',
 
27
  opts_args = ['--no_fine_mapper']
28
  opts = GradioTestOptions().parse(opts_args)
29
  device = 'cuda' if torch.cuda.is_available() else 'cpu'
30
+ opts.device= device
31
 
32
  mapper_dict = {
33
  'afro':'./pretrained_models/styleCLIP_mappers/afro_hairstyle.pt',
models/stylegan2/op/fused_act.py CHANGED
@@ -5,6 +5,7 @@ from torch import nn
5
  from torch.nn import functional as F
6
 
7
  module_path = os.path.dirname(__file__)
 
8
 
9
 
10
 
@@ -22,7 +23,7 @@ class FusedLeakyReLU(nn.Module):
22
 
23
  def fused_leaky_relu(input, bias, negative_slope=0.2, scale=2 ** 0.5):
24
  rest_dim = [1] * (input.ndim - bias.ndim - 1)
25
- input = input.cuda()
26
  if input.ndim == 3:
27
  return (
28
  F.leaky_relu(
 
5
  from torch.nn import functional as F
6
 
7
  module_path = os.path.dirname(__file__)
8
+ device = 'cuda' if torch.cuda.is_available() else 'cpu'
9
 
10
 
11
 
 
23
 
24
  def fused_leaky_relu(input, bias, negative_slope=0.2, scale=2 ** 0.5):
25
  rest_dim = [1] * (input.ndim - bias.ndim - 1)
26
+ input = input.to(device)
27
  if input.ndim == 3:
28
  return (
29
  F.leaky_relu(