nikigoli commited on
Commit
0d06105
·
verified ·
1 Parent(s): 9d54457

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -8
app.py CHANGED
@@ -26,7 +26,7 @@ cwd = os.getcwd()
26
  print("Current working directory:", cwd)
27
 
28
  # Installing dependencies not in requirements.txt
29
- #@spaces.GPU
30
  def install_add_dependencies():
31
  print("inside install_add_dependencies")
32
  print(torch.cuda.is_available())
@@ -41,8 +41,8 @@ def build_custom_prompter():
41
 
42
  build_custom_prompter()
43
  from gradio_image_prompter import ImagePrompter
44
- print("torch version")
45
- print(torch.version.cuda)
46
  #install_add_dependencies()
47
 
48
  class AppSteps(Enum):
@@ -112,8 +112,9 @@ def get_args_parser():
112
  parser.add_argument("--amp", action="store_true", help="Train with mixed precision")
113
  return parser
114
 
115
- @spaces.GPU
116
  # Get counting model.
 
117
  def build_model_and_transforms(args):
118
  normalize = T.Compose(
119
  [T.ToTensor(), T.Normalize([0.485, 0.456, 0.406], [0.229, 0.224, 0.225])]
@@ -161,10 +162,11 @@ def build_model_and_transforms(args):
161
 
162
  parser = argparse.ArgumentParser("Counting Application", parents=[get_args_parser()])
163
  args = parser.parse_args()
164
- if torch.cuda.is_available():
165
- args.device = torch.device('cuda')
166
- else:
167
- args.device = torch.device('cpu')
 
168
  model, transform = build_model_and_transforms(args)
169
 
170
  examples = [
 
26
  print("Current working directory:", cwd)
27
 
28
  # Installing dependencies not in requirements.txt
29
+ @spaces.GPU
30
  def install_add_dependencies():
31
  print("inside install_add_dependencies")
32
  print(torch.cuda.is_available())
 
41
 
42
  build_custom_prompter()
43
  from gradio_image_prompter import ImagePrompter
44
+ #print("torch version")
45
+ #print(torch.version.cuda)
46
  #install_add_dependencies()
47
 
48
  class AppSteps(Enum):
 
112
  parser.add_argument("--amp", action="store_true", help="Train with mixed precision")
113
  return parser
114
 
115
+
116
  # Get counting model.
117
+ @spaces.GPU
118
  def build_model_and_transforms(args):
119
  normalize = T.Compose(
120
  [T.ToTensor(), T.Normalize([0.485, 0.456, 0.406], [0.229, 0.224, 0.225])]
 
162
 
163
  parser = argparse.ArgumentParser("Counting Application", parents=[get_args_parser()])
164
  args = parser.parse_args()
165
+ #if torch.cuda.is_available():
166
+ # args.device = torch.device('cuda')
167
+ #else:
168
+ # args.device = torch.device('cpu')
169
+ args.device = torch.device('cuda')
170
  model, transform = build_model_and_transforms(args)
171
 
172
  examples = [