oskarastrom commited on
Commit
694b0df
·
1 Parent(s): 188a41c

Update detect_frames.py

Browse files
Files changed (1) hide show
  1. scripts/detect_frames.py +4 -14
scripts/detect_frames.py CHANGED
@@ -68,20 +68,7 @@ def detect(in_seq_dir, out_seq_dir, model, device, verbose):
68
 
69
  inference, image_shapes, width, height = do_detection(dataloader, model, device, verbose=verbose)
70
 
71
- print('converting tensor')
72
- inference_list = []
73
- with tqdm(total=len(inference), desc="...") as pbar:
74
- for tensor in inference:
75
- if isinstance(tensor, torch.Tensor):
76
- inference_list.append(tensor.cpu().tolist())
77
- else:
78
- inference_list.append(tensor)
79
- pbar.update(1)
80
- pbar.close()
81
-
82
- print('converted tensor')
83
  json_obj = {
84
- 'inference': inference_list,
85
  'image_shapes': image_shapes,
86
  'width': width,
87
  'height': height
@@ -90,7 +77,10 @@ def detect(in_seq_dir, out_seq_dir, model, device, verbose):
90
 
91
  with open(os.path.join(out_seq_dir, 'pred.json'), 'w') as f:
92
  json.dump(json_obj, f)
93
- print('saved')
 
 
 
94
 
95
  def argument_parser():
96
  parser = argparse.ArgumentParser()
 
68
 
69
  inference, image_shapes, width, height = do_detection(dataloader, model, device, verbose=verbose)
70
 
 
 
 
 
 
 
 
 
 
 
 
 
71
  json_obj = {
 
72
  'image_shapes': image_shapes,
73
  'width': width,
74
  'height': height
 
77
 
78
  with open(os.path.join(out_seq_dir, 'pred.json'), 'w') as f:
79
  json.dump(json_obj, f)
80
+ print('saved json')
81
+
82
+ torch.save(inference, 'inference.pt')
83
+ print('saved inference')
84
 
85
  def argument_parser():
86
  parser = argparse.ArgumentParser()