Skip to content

Commit 2cc6946

Browse files
chyomin06fracape
authored andcommitted
[fix] default performance + image based split inference
1 parent 910e18a commit 2cc6946

File tree

3 files changed

+30
-19
lines changed

3 files changed

+30
-19
lines changed

compressai_vision/codecs/base.py

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -75,17 +75,25 @@ def encode(
7575
del bitstream_name # used in other codecs that write bitstream files
7676
del codec_output_dir # used in other codecs that write log files
7777

78+
mac_calculations = None # no NN-related complexity calculation
79+
7880
if remote_inference is True:
7981
org_fH = input["org_input_size"]["height"]
8082
org_fW = input["org_input_size"]["width"]
8183

8284
num_elements = org_fH * org_fW
8385
num_frames = len(input["file_names"])
8486

85-
return {
86-
"bytes": [num_elements] * num_frames,
87-
"bitstream": input,
88-
}
87+
enc_time = 0
88+
89+
return (
90+
{
91+
"bytes": [num_elements] * num_frames,
92+
"bitstream": input,
93+
},
94+
enc_time,
95+
mac_calculations,
96+
)
8997

9098
# for n-bit quantization error experiments
9199
max_lvl = ((2**self.nbit_quant) - 1) if self.nbit_quant != -1 else None
@@ -117,8 +125,6 @@ def encode(
117125
"bypass": time_measure() - start_time,
118126
}
119127

120-
mac_calculations = None # no NN-related complexity calculation
121-
122128
return (
123129
{
124130
"bytes": total_bytes,
@@ -140,14 +146,12 @@ def decode(
140146
del file_prefix # used in other codecs that write log files
141147
del codec_output_dir # used in other codecs that write log files
142148

143-
if remote_inference:
144-
assert "file_names" in input
145-
return input
146-
147149
dec_time = {"bypass": 0}
148-
149150
mac_calculations = None # no NN-related complexity calculation
150151

152+
if remote_inference:
153+
assert "file_names" in input
154+
151155
return input, dec_time, mac_calculations
152156

153157

compressai_vision/pipelines/remote_inference/image_remote_inference.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ def __call__(
102102
"org_input_size": org_img_size,
103103
}
104104

105-
res = self._compress(
105+
res, enc_time_details, _ = self._compress(
106106
codec,
107107
frame,
108108
self.codec_output_dir,
@@ -147,7 +147,8 @@ def __call__(
147147
timing["decode"].append((end - start))
148148

149149
start = time_measure()
150-
dec_d = {"file_name": dec_seq["file_names"][0]}
150+
# dec_d = {"file_name": dec_seq["file_names"][0]}
151+
dec_d = {"file_name": dec_seq[0]["file_names"][0]}
151152

152153
pred = vision_model.forward(org_map_func(dec_d))
153154
end = time_measure()

scripts/evaluation/default_vision_performances.sh

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ set -eu
77

88
ENTRY_CMD=$1
99
TESTDATA_DIR=$2
10+
DEVICE=$3
1011

1112
# List of entry cmds
1213
CMD_OPTS=("compressai-split-inference", "compressai-remote-inference")
@@ -21,7 +22,7 @@ fi
2122

2223
declare -A configs
2324

24-
configs["compressai-split-inference"]="eval_example"
25+
configs["compressai-split-inference"]="eval_split_inference_example"
2526
configs["compressai-remote-inference"]="eval_remote_inference_example"
2627

2728
CONF_NAME=${configs[${ENTRY_CMD}]}
@@ -54,7 +55,8 @@ ${ENTRY_CMD} --config-name=${CONF_NAME}.yaml \
5455
++evaluator.type=OIC-EVAL \
5556
++pipeline.nn_task_part1.load_features=False \
5657
++pipeline.nn_task_part1.dump_features=False \
57-
++pipeline.nn_task_part2.dump_features=False
58+
++pipeline.nn_task_part2.dump_features=False \
59+
++misc.device.nn_parts=${DEVICE}
5860

5961
# MPEGOIV6 - Segmentation with Mask RCNN
6062
${ENTRY_CMD} --config-name=${CONF_NAME}.yaml \
@@ -70,7 +72,8 @@ ${ENTRY_CMD} --config-name=${CONF_NAME}.yaml \
7072
++evaluator.type=OIC-EVAL \
7173
++pipeline.nn_task_part1.load_features=False \
7274
++pipeline.nn_task_part1.dump_features=False \
73-
++pipeline.nn_task_part2.dump_features=False
75+
++pipeline.nn_task_part2.dump_features=False \
76+
++misc.device.nn_parts=${DEVICE}
7477

7578
# SFU - Detection with Faster RCNN
7679
for SEQ in \
@@ -102,7 +105,8 @@ do
102105
++evaluator.type=COCO-EVAL \
103106
++pipeline.nn_task_part1.load_features=False \
104107
++pipeline.nn_task_part1.dump_features=False \
105-
++pipeline.nn_task_part2.dump_features=False
108+
++pipeline.nn_task_part2.dump_features=False \
109+
++misc.device.nn_parts=${DEVICE}
106110
done
107111

108112
# TVD - Object Tracking with JDE
@@ -127,7 +131,8 @@ do
127131
++evaluator.type=MOT-TVD-EVAL \
128132
++pipeline.nn_task_part1.load_features=False \
129133
++pipeline.nn_task_part1.dump_features=False \
130-
++pipeline.nn_task_part2.dump_features=False
134+
++pipeline.nn_task_part2.dump_features=False \
135+
++misc.device.nn_parts=${DEVICE}
131136
done
132137

133138
# HIEVE - Object Tracking with JDE
@@ -154,5 +159,6 @@ do
154159
++evaluator.type=MOT-HIEVE-EVAL \
155160
++pipeline.nn_task_part1.load_features=False \
156161
++pipeline.nn_task_part1.dump_features=False \
157-
++pipeline.nn_task_part2.dump_features=False
162+
++pipeline.nn_task_part2.dump_features=False \
163+
++misc.device.nn_parts=${DEVICE}
158164
done

0 commit comments

Comments
 (0)