ttengwang commited on
Commit
73cef8f
1 Parent(s): eabdb1c

faster cropping

Browse files
Files changed (1) hide show
  1. captioner/base_captioner.py +3 -8
captioner/base_captioner.py CHANGED
@@ -15,14 +15,9 @@ def boundary(inputs):
15
  inputs = inputs.reshape(-1)
16
  lens = len(inputs)
17
 
18
- for i in range(lens):
19
- if inputs[i] != False:
20
- break
21
- for j in range(lens):
22
- if inputs[lens - 1 - j] != False:
23
- break
24
- start = i
25
- end = lens - 1 - j
26
  top = start // col
27
  bottom = end // col
28
 
 
15
  inputs = inputs.reshape(-1)
16
  lens = len(inputs)
17
 
18
+ start = np.argmax(inputs)
19
+ end = lens - 1 - np.argmax(np.flip(inputs))
20
+
 
 
 
 
 
21
  top = start // col
22
  bottom = end // col
23