change double for loop to list comprehension for upgrading speed
#21
by
changgyu
- opened
- modeling_hyperclovax.py +6 -6
modeling_hyperclovax.py
CHANGED
@@ -465,12 +465,12 @@ class HCXVisionForCausalLM(PreTrainedModel, GenerationMixin):
|
|
465 |
possible_resolutions = []
|
466 |
if config.anyres:
|
467 |
assert config.max_num_grids > 0
|
468 |
-
|
469 |
-
|
470 |
-
|
471 |
-
|
472 |
-
|
473 |
-
|
474 |
|
475 |
possible_resolutions = [
|
476 |
[ys * vision_config.image_size, xs * vision_config.image_size] for ys, xs in possible_resolutions
|
|
|
465 |
possible_resolutions = []
|
466 |
if config.anyres:
|
467 |
assert config.max_num_grids > 0
|
468 |
+
possible_resolutions = [
|
469 |
+
[i, j]
|
470 |
+
for i in range(1, config.max_num_grids + 1)
|
471 |
+
for j in range(1, (config.max_num_grids // i) + 1)
|
472 |
+
if not (i == 1 and j == 1 and not config.use_1x1_grid)
|
473 |
+
]
|
474 |
|
475 |
possible_resolutions = [
|
476 |
[ys * vision_config.image_size, xs * vision_config.image_size] for ys, xs in possible_resolutions
|