nikigoli commited on
Commit
9b4dec3
1 Parent(s): 31bd1d5

Put specifying args.device in main file instead of inside function

Browse files
Files changed (1) hide show
  1. app.py +4 -4
app.py CHANGED
@@ -103,10 +103,6 @@ def get_args_parser():
103
  @spaces.GPU
104
  # Get counting model.
105
  def build_model_and_transforms(args):
106
- if torch.cuda.is_available():
107
- args.device = torch.device('cpu')
108
- else:
109
- args.device = torch.device('cpu')
110
  normalize = T.Compose(
111
  [T.ToTensor(), T.Normalize([0.485, 0.456, 0.406], [0.229, 0.224, 0.225])]
112
  )
@@ -153,6 +149,10 @@ def build_model_and_transforms(args):
153
 
154
  parser = argparse.ArgumentParser("Counting Application", parents=[get_args_parser()])
155
  args = parser.parse_args()
 
 
 
 
156
  model, transform = build_model_and_transforms(args)
157
 
158
  examples = [
 
103
  @spaces.GPU
104
  # Get counting model.
105
  def build_model_and_transforms(args):
 
 
 
 
106
  normalize = T.Compose(
107
  [T.ToTensor(), T.Normalize([0.485, 0.456, 0.406], [0.229, 0.224, 0.225])]
108
  )
 
149
 
150
  parser = argparse.ArgumentParser("Counting Application", parents=[get_args_parser()])
151
  args = parser.parse_args()
152
+ if torch.cuda.is_available():
153
+ args.device = torch.device('cpu')
154
+ else:
155
+ args.device = torch.device('cpu')
156
  model, transform = build_model_and_transforms(args)
157
 
158
  examples = [