Skip to content

Commit b05ebea

Browse files
committed
Merge branch 'main' of https://github.com/EvolvingLMMs-Lab/OneVision-Encoder into anxiang_v2
2 parents 51de0a4 + e21c177 commit b05ebea

5 files changed

Lines changed: 479 additions & 58 deletions

File tree

README.md

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -301,27 +301,11 @@ cd eval_encoder
301301
Then run the following command:
302302

303303
```bash
304-
torchrun --nproc_per_node=8 --master_port=29512 attentive_probe_codec.py \
305-
--eval_freq 1 \
306-
--default_lr_list 0.0001 \
307-
--batch_size 4 \
308-
--default_weight_decay 0 \
309-
--dali_py_num_workers 8 \
310-
--model_family ov_encoder_codec \
311-
--dataset diving48 \
312-
--model_weight lmms-lab-encoder/onevision-encoder-large \
313-
--model_name ov_encoder_large \
314-
--embedding_size 1024 \
315-
--default_epoch 30 \
316-
--K_keep 2048 \
317-
--num_frames 64 \
318-
--mv_compensate median
319-
304+
bash shells_eval_ap/eval_ov_encoder_large_2kpatches_codec.sh
320305
```
321306

322307
**Codec-Specific Parameters:**
323308
- `K_keep`: Number of patches to keep.
324-
- `mv_compensate`: Motion vector compensation method (e.g., `median`).
325309
- `cache_dir` (optional): Directory for cached codec patches. Use this to specify where codec-selected patches are stored/loaded when you want to persist or reuse them.
326310

327311
#### Shared Parameters

dataloader/ap_dataloader_dali_codec.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1060,8 +1060,8 @@ def get_dali_dataloader_codec(
10601060
center_prior: float = 0.3,
10611061
center_sigma: float = 0.35,
10621062
static_fallback: bool = False,
1063-
static_abs_thresh: float = 116.0,
1064-
static_rel_thresh: float = 0.55,
1063+
static_abs_thresh: float = 126.0,
1064+
static_rel_thresh: float = 0.38,
10651065
static_uniform_frames: int = 4,
10661066
) -> DALIWarper:
10671067
"""

eval_encoder/attentive_probe_codec.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -77,17 +77,17 @@ def parse_args() -> argparse.Namespace:
7777
help="Neighborhood size (odd >=3) for MV inconsistency (default: 3)")
7878
parser.add_argument("--res_use_grad", action="store_true",
7979
help="Use gradient-based residual energy instead of |res-128| (default: False)")
80-
parser.add_argument("--center_prior", type=float, default=0.0,
81-
help="Center Gaussian prior strength applied to fused energy map before top-k (0 disables) (default: 0.0)")
80+
parser.add_argument("--center_prior", type=float, default=0.3,
81+
help="Center Gaussian prior strength applied to fused energy map before top-k (0 disables) (default: 0.3)")
8282
parser.add_argument("--center_sigma", type=float, default=0.35,
8383
help="Center Gaussian sigma as a fraction of min(H,W) (default: 0.35)")
8484
# Static / low-motion fallback (hybrid: uniform few frames + remaining top-k)
8585
parser.add_argument("--static_fallback", type=int, default=1,
8686
help="Enable static-video hybrid fallback (1 enables, 0 disables) (default: 1)")
87-
parser.add_argument("--static_abs_thresh", type=float, default=2.0,
88-
help="Absolute low-energy threshold on patch mean intensity (~0..255) (default: 2.0)")
89-
parser.add_argument("--static_rel_thresh", type=float, default=0.15,
90-
help="Relative contrast threshold (0..1), smaller means flatter distribution (default: 0.15)")
87+
parser.add_argument("--static_abs_thresh", type=float, default=126,
88+
help="Absolute low-energy threshold on patch mean intensity (~0..255) (default: 126)")
89+
parser.add_argument("--static_rel_thresh", type=float, default=0.38,
90+
help="Relative contrast threshold (0..1), smaller means flatter distribution (default: 0.38)")
9191
parser.add_argument("--static_uniform_frames", type=int, default=4,
9292
help="Number of uniformly-picked frames used in hybrid fallback (default: 4)")
9393

eval_encoder/shells_eval_ap/common_codec.sh

Lines changed: 7 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -51,26 +51,6 @@ get_epochs() {
5151
fi
5252
}
5353

54-
# ============================================================================
55-
# Get codec parameters based on dataset name
56-
# Args: $1 - dataset name
57-
# Returns: Sets CODEC_MV_COMPENSATE, CODEC_STATIC_ABS_THRESH, CODEC_STATIC_REL_THRESH
58-
# ============================================================================
59-
get_codec_params() {
60-
local dataset="$1"
61-
if [[ "$dataset" == "diving48" || "$dataset" == "perception_test" ]]; then
62-
# Parameters for diving48 and perception_test
63-
CODEC_MV_COMPENSATE="similarity"
64-
CODEC_STATIC_ABS_THRESH="126"
65-
CODEC_STATIC_REL_THRESH="0.38"
66-
else
67-
# Parameters for other datasets
68-
CODEC_MV_COMPENSATE="similarity"
69-
CODEC_STATIC_ABS_THRESH="116"
70-
CODEC_STATIC_REL_THRESH="0.55"
71-
fi
72-
}
73-
7454
# ============================================================================
7555
# Run attentive_probe_codec evaluation
7656
# Required variables to set before calling:
@@ -81,16 +61,14 @@ get_codec_params() {
8161
# - EMBEDDING_SIZE: embedding dimension (optional, default 768)
8262
# - INPUT_SIZE: input size (optional, not passed if unset)
8363
# - NUM_FRAMES: number of frames (optional, not passed if unset)
84-
# - K_keep: number of top-K patches to keep (optional, default 2048)
8564
# - DATASETS: dataset array (optional, uses DEFAULT_DATASETS if unset/empty)
86-
# - REPORT_DIR_SUFFIX: report directory suffix (optional, e.g. "_64frames_codec")
65+
# - REPORT_DIR_SUFFIX: report directory suffix (optional, e.g. "_16frames")
8766
# ============================================================================
8867
run_attentive_probe_codec() {
8968
# Set default values
9069
MODEL_WEIGHT="${MODEL_WEIGHT:-NULL}"
9170
FRAMES_TOKEN_NUM="${FRAMES_TOKEN_NUM:-196}"
9271
EMBEDDING_SIZE="${EMBEDDING_SIZE:-768}"
93-
K_keep="${K_keep:-2048}"
9472
REPORT_DIR_SUFFIX="${REPORT_DIR_SUFFIX:-}"
9573

9674
# Use custom datasets or default datasets
@@ -99,18 +77,14 @@ run_attentive_probe_codec() {
9977
fi
10078

10179
# Build report directory
102-
BASE_REPORT_DIR="result_attentive_probe/${MODEL_FAMILY}/${MODEL_NAME}${REPORT_DIR_SUFFIX}"
80+
BASE_REPORT_DIR="result_attentive_probe_codec/${MODEL_FAMILY}/${MODEL_NAME}${REPORT_DIR_SUFFIX}"
10381

10482
# Loop through each dataset for testing
10583
for DATASET in "${DATASETS[@]}"; do
10684
BATCH_SIZE=$(get_batch_size "$DATASET")
10785
EPOCHS=$(get_epochs "$DATASET")
108-
109-
# Get codec-specific parameters for this dataset
110-
get_codec_params "$DATASET"
11186

11287
echo "DATASET=$DATASET, BATCH_SIZE=$BATCH_SIZE"
113-
echo "Codec params: mv_compensate=${CODEC_MV_COMPENSATE}, static_abs_thresh=${CODEC_STATIC_ABS_THRESH}, static_rel_thresh=${CODEC_STATIC_REL_THRESH}"
11488

11589
echo "========================================================"
11690
echo "Start testing dataset: ${DATASET}"
@@ -132,6 +106,11 @@ run_attentive_probe_codec() {
132106
EXTRA_ARGS="${EXTRA_ARGS} --num_frames ${NUM_FRAMES}"
133107
fi
134108

109+
# Add --mv_use_inconsistency for all datasets except diving48
110+
if [[ "$DATASET" != "diving48" ]]; then
111+
EXTRA_ARGS="${EXTRA_ARGS} --mv_use_inconsistency"
112+
fi
113+
135114
torchrun --nproc_per_node 8 --master_port 15555 \
136115
attentive_probe_codec.py \
137116
--eval_freq 1 \
@@ -147,11 +126,6 @@ run_attentive_probe_codec() {
147126
--save_report "${SAVE_DIR}" \
148127
--frames_token_num ${FRAMES_TOKEN_NUM} \
149128
--embedding_size ${EMBEDDING_SIZE} \
150-
--K_keep ${K_keep} \
151-
--mv_compensate ${CODEC_MV_COMPENSATE} \
152-
--static_abs_thresh ${CODEC_STATIC_ABS_THRESH} \
153-
--static_rel_thresh ${CODEC_STATIC_REL_THRESH} \
154-
--static_fallback 1 \
155129
${EXTRA_ARGS}
156130

157131
echo "Finished testing ${DATASET}"

0 commit comments

Comments
 (0)