Configuration#
This document explains the options, knobs, and environment variables that you can configure in STAR.
1. CLI Reference (python -m semantic_img_comp.main)#
This chapter lists the flags that you can set on the encoder/decoder application or container.
Argument |
Type / choices |
Default |
Applies to |
Description |
|---|---|---|---|---|
|
|
required |
both |
Which side of the pipeline to run. Each role starts the legacy batch TCP mode and the REST service concurrently. |
|
path |
|
both |
YAML configuration file. In the container the default is |
|
path |
|
encoder |
Input image directory or a |
|
path |
|
both |
Output root for logs, reconstructions, and masks. |
|
string |
|
both |
Encoder: hostname of the decoder to connect to. Decoder: bind address. |
|
int |
|
both |
TCP port. |
|
float ≥ 0 |
|
encoder |
Target send rate in frames/s; |
|
float ≥ 0 |
|
encoder |
Emulated input source data rate in Mbps. |
|
float ≥ 0 |
|
encoder |
Hard-stop the image feeder after this many seconds. |
|
path |
|
encoder |
Annotations JSON file. |
|
path |
|
encoder |
Directory of YOLO-style |
|
flag (alias |
off |
encoder |
Encode background only; also forces |
|
|
|
encoder |
Edge detector used by mask-aware codecs. |
|
URL |
none |
encoder |
Base URL of the decoder’s REST service to forward encoded payloads to, e.g., |
|
string |
|
both |
Bind address for the REST service side. |
|
int |
|
both |
Bind port for the REST service side. |
|
int |
|
decoder |
Maximum decoded frames retained per stream (REST service side) before the oldest is evicted. |
CLI values always override the corresponding YAML keys. Exit codes: 0 success, 2 bad
arguments / missing paths, 1 runtime error or interrupt.
2. Multi-Directory Input Catalogs#
--input can point to a YAML catalog file that lists several image directories. Sampling mode
is controlled by io.input_catalog_sampling (uniform by default; set proportional to
weight by each directory’s remaining image count).
Example input_catalog.yaml:
input_dirs:
- /app/data/Ground EO Images
- /app/data/Ground LWIR Images
- /app/data/Helicopter Images
random_seed: 7
Then modify the encoder configuration in docker-compose.yaml to include the following:
volumes:
- "$(pwd)/data/:/app/data"
...
command: --role encoder --input /app/data/input_catalog.yaml --host decoder --port 5000 --decoder-url http://decoder:8000
3. Input Data Rate Limiting (Optional)#
The encoder simulates a bandwidth-constrained image source by controlling how fast input images are fed into the pipeline.
Via CLI:
command: --role encoder --host decoder --port 5000 --decoder-url http://decoder:8000 --target-input-rate-mbps 1.1 --run-duration-sec 120
Via configuration file (configs/default.yaml):
image_feeder:
target_input_rate_mbps: 1.1 # null or omit to disable
run_duration_sec: 120 # 2 minutes; null or omit to run until all images are sent
How it works: a dedicated feeder thread releases images into a queue at the configured rate, fully decoupled from how long the encoder takes to process them:
Feeder Thread (producer) Encoder Loop (consumer, main thread)
──────────────────────── ─────────────────────────────────────
Release image 1 immediately → get() → encode+send (may be slow)
Sleep (img1_bytes×8 / Mbps) ...
Release image 2 → get() → encode+send
Sleep (img2_bytes×8 / Mbps) ...
[stop after run_duration_sec] hard-stop: socket closed, queue dropped
Sleep duration per image =
(file_bytes × 8) / (target_Mbps × 1e6)secondsIf the encoder is slower than the configured rate, images queue up (backlog grows), and the pipeline manager reacts to that backlog
If the encoder is faster, it blocks on the queue waiting for the next image
Encoder performance has no effect on the input arrival rate
Once
run_duration_secexpires, the encoder hard-stops: the TCP socket is closed immediately and any images still waiting in the queue are droppedSet either key to
null(or omit it) to disable the corresponding limitSet
image_feeder.log_feeder_events: trueto emitfeeder_rate_limitedandfeeder_enqueuedevents (the latter includes the currentqueue_backlog);frame_sentevents always includequeue_backlogat send time, andfeeder_duration_limit_reached/duration_limit_forced_stopreport the released and dropped image counts
4. Thread Tuning in Docker Compose (Optional)#
The image sets defaults for the CPU thread pools used by OpenMP/MKL/BLAS/NumExpr (and
AVIF_JOBS). You can override them at runtime without rebuilding the image:
environment:
OMP_NUM_THREADS: 4
MKL_NUM_THREADS: 4
OPENBLAS_NUM_THREADS: 4
NUMEXPR_NUM_THREADS: 4
Quick guidance:
Lower values (1–2): better for tight CPU limits / reduced contention
Higher values (4+): may improve throughput on larger CPUs
Per-deployment tuning: benchmark your encoder/decoder workload
Common Configuration Knobs#
configs/default.yaml is the single source of truth for runtime behavior. The
pipeline-manager and codec keys are covered in Pipeline manager and
Codec Methods Supported by the Application;
the tables below explain the everyday app and io settings you are most likely to change.
CLI flags always win over YAML values.
Logging and Console Output#
Key |
Default |
What it does |
|---|---|---|
|
|
Verbosity of the Python logger: |
|
|
Whether log records also go to the console. When |
|
|
Controls only |
|
|
Adds per-image |
app.log_level and io.print_runtime_logs are independent: the level decides what is
recorded, print_runtime_logs decides whether you also see it in the terminal.
Input Feed and Run Duration#
Key |
Default |
What it does |
|---|---|---|
|
|
Emulates a bandwidth-constrained image source. A feeder thread releases each image after |
|
|
Stops the feeder after N seconds, then hard-stops: the socket closes immediately and queued images are dropped. Useful for bounded benchmark runs. Set to |
|
|
Input image directory, or a YAML catalog listing several directories. Relative to the current working directory. CLI: |
|
|
Only used with a YAML catalog: |
|
empty |
Supply existing detections instead of running YOLO. |
Outputs and Visualization#
Key |
Default |
What it does |
|---|---|---|
|
|
Root for |
|
|
Gates whether the decoder writes reconstructed images at all. With |
|
|
Overlays detected object boxes on the saved reconstructions. Only has an effect when |
TCP Client Identity#
Key |
Default |
What it does |
|---|---|---|
|
|
[encoder] Sent to the decoder at the start of the TCP connection (one-time handshake) and used by the decoder for saved filenames ( |
Compute#
Key |
Default |
What it does |
|---|---|---|
|
|
Torch device for detection, e.g., |
|
|
YOLO inference resolution. Larger values see small objects better at higher cost; the pipeline manager may override tiling per image via |
Pipeline Manager#
src/semantic_img_comp/encoder/pipeline_manager.py (EncoderPipelineManager) is the adaptive
control loop of the encoder. It is consulted once per image, before encoding, and returns
a PipelineContext describing how that specific frame should be encoded. It is used by both
the direct path and the semantic bridge.
1. Queue-pressure tiers. The manager watches the backlog of the input queue and degrades
the pipeline gracefully as pressure builds (thresholds from
pipeline_manager.queue_backlog_threshold_1/2/3, defaults 5 / 10 / 15):
Queue backlog |
Background |
Objects |
|---|---|---|
|
normal |
normal |
|
fast |
normal |
|
fast |
fast |
|
fast |
object detection skipped |
2. Hysteresis. To avoid oscillating between tiers on a noisy queue, an entered state
persists until the backlog drops below a lower exit threshold — skip_obj_hysteresis_exit
(default (t2+t3)/2) for the skip-object state, and fast_full_hysteresis_exit (default
(t1+t2)/2) for the fast-background/fast-object state.
3. Adaptive compression-rate tuning. After a warmup period
(adaptive_compression_rate_warmup_frames), the manager compares the aggregate compression
rate achieved so far against the rate configured for the active compression level and nudges
the per-frame target accordingly. Averaging is either moving_average or ema
(adaptive_compression_rate_method, with adaptive_compression_rate_ema_alpha). The result
is clamped by adaptive_compression_rate_target_margin_ratio around the level-selected rate,
hard-capped by adaptive_compression_rate_max, and can be boosted with
adaptive_compression_rate_boost_factor.
4. Per-image tiling. When detection is active and
max(image_dim) > large_dim_tile_threshold_px (default 1280), the manager forces
tile_size=640 / tile_overlap=10 for that frame only.
The manager applies its decisions with apply_pipeline_config() and always reverts them with
restore_config() after the frame, so configuration mutations never leak across frames.
Codec Methods Supported by the Application#
The encoder/decoder pipeline mixes perceptual codecs, compact low-bit codecs, and symbolic
codecs. The names below are the ones used internally by the application and are exactly those
declared in configs/default.yaml.
Codec |
Used for |
Notes |
|---|---|---|
|
background / object |
Full-color AV1 Image File Format (AVIF); highest fidelity, highest cost. Declared in |
|
background (level 1) |
Monochrome AVIF at AVIF quality |
|
background (level 1), objects (levels 1 and 2) |
Monochrome AVIF at AVIF quality |
|
available |
Monochrome AVIF at AVIF quality |
|
available |
Mask-aware 2/8-bit monochrome codec. |
|
background (level 2), objects (level 2) |
Aggressive 2-bit monochrome codec for very small payload budgets. |
|
available |
Mask-aware 1-bit codec that transmits only edge/structure. |
|
available |
Skeleton / line-segment codec (tuned by the |
|
available |
Polygon-silhouette codec (tuned by the |
|
objects (level 2) |
Symbolic codec: transmits a class symbol and pose instead of pixels, for categories listed in |
AVIF quality for the three mono-avif-* variants is set by encoder.avif_mono_quality_map.
In practice:
AVIF codecs preserve the most visual detail but cost the most bytes.
Low-bit codecs (
mono-2bit,mono-mask-1bit) are far more bandwidth-efficient, at the cost of texture.Mask/structure codecs (
mono-28bit,mono-mask-1bit,mono-skel-v1,mono-shape-v1) are useful when preserving structure or edges matters more than photorealistic texture.airplane-symbol-v1is the cheapest option: a few bytes per object.
Including or Excluding Codecs#
Codec selection is per compression level and independent for background and objects, via
the img_process.encoders_tag_{bg,objs}_level_{1,2} maps. These are the only codec-selection
inputs used at runtime; the shared img_process.encoders_tag map is kept for backward
compatibility and to define the global codec-name → numeric-ID mapping carried in the payload.
Active configuration in configs/default.yaml:
img_process:
encoders_tag_bg_level_1:
mono-avif-high: 1
mono-avif-mid: 2
encoders_tag_objs_level_1:
mono-avif-mid: 2
encoders_tag_bg_level_2:
mono-2bit: 5
encoders_tag_objs_level_2:
mono-avif-mid: 2
mono-2bit: 5
airplane-symbol-v1: 10
How to use it:
Include a codec: add its name (with its ID from
encoders_tag) to the relevant level map.Exclude a codec: remove or comment out its entry.
Control fallback order: codecs are tried in the order listed; the last configured codec acts as the final fallback if earlier ones do not meet the byte budget.
Keep IDs unique and stable: the numeric ID is what the decoder reads from the payload, so the encoder and decoder must agree on the mapping.
Level selection:
pipeline_manager.compression_level(1→level_1,2→level_2) picks the active pair of maps; scaling ranges come from the matchingimg_process.*_level_1/*_level_2keys, and target rates fromencoder.compression_levels.
5. OpenAPI HTTP Specification#
To get the specification for HTTP endpoints in JSON format, run the following commands:
curl -fsS http://localhost:8001/openapi.json -o encoder-openapi.json
curl -fsS http://localhost:8002/openapi.json -o decoder-openapi.json
To use HTTP endpoints, you have to create a stream on the encoder:
curl -X PUT http://localhost:8001/v1/streams/mystream \
-H "Content-Type: application/json" \
-d '{"compression_level": 2}'
and then send an image to that stream:
$ curl -X POST --data-binary @data/sample_001.jpeg http://localhost:8001/v1/streams/mystream/frames
{"status":"accepted","stream_id":"mystream"}
To see metrics, such as the processing time for each step and the compression rate, check the logs in the encoder application/container. To get the compressed image, send the following request to the decoder:
curl http://localhost:8002/v1/streams/mystream/frames/1 -o frame1.jpg
6. Container Health Check#
Both the encoder and decoder images expose a status endpoint on port 5999 (which is not
exposed by default and is used only by the container), served in-process by
semantic_img_comp.healthcheck.start_status_server() (started once at startup in main.py):
curl http://localhost:5999/
# {"is_alive": true, "http_ready": true, "tcp_ready": true}
Field |
Meaning |
|---|---|
|
The status server itself is up and serving (process is running). |
|
The REST service ( |
|
The legacy batch TCP listener ( |