Spaces:
Runtime error
Runtime error
ttengwang
commited on
Commit
·
73cef8f
1
Parent(s):
eabdb1c
faster cropping
Browse files
captioner/base_captioner.py
CHANGED
|
@@ -15,14 +15,9 @@ def boundary(inputs):
|
|
| 15 |
inputs = inputs.reshape(-1)
|
| 16 |
lens = len(inputs)
|
| 17 |
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 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 |
|