AI Slop Code RIsk Monitor

facebookresearch/sam2

The repository provides code for running inference with the Meta Segment Anything Model 2 (SAM 2), links for downloading the trained model checkpoints, and example notebooks that show how to use the model.

7.3 Moderate pattern signal View on GitHub

Maintenance and Governance Review

This report summarizes scanner evidence for facebookresearch/sam2, a Jupyter Notebook project with 19,984 GitHub stars. SynthScan examined 40,255 lines of code across 294 source files, recording 222 pattern matches distributed across 15 syntactic categories. The legacy adjusted pattern signal is 7.3 (Moderate pattern signal); it is not an authorship estimate.

Use the findings to ask whether maintainers can explain intent, verify dependencies, simplify unnecessary scaffolding, and focus review effort. Risk Payload v1 adds ownership, supply-chain, over-engineering, and review-effort vectors when available. These are prompts for human verification, not probabilities, security findings, or measured maintenance costs.

7.3
Adjusted Signal
7.3
Raw Pattern Score
100%
Time Factor
2026-05-30
Last Push
20.0K
Stars
Jupyter Notebook
Language
40.3K
Lines of Code
294
Files
222
Pattern Hits
2026-10-12
Scan Date
0.02
HC Hit Rate

Risk Review · v3

Use each vector to guide manual verification of the underlying findings.

Cognitive Ownership Risk 22.5/100 · LOW

Can maintainers explain intent, assumptions, and trade-offs? 173 finding(s).

Hallucinated Dependency & Supply Chain Risk 1.6/100 · LOW

Are imports declared and package/API names verified? 13 finding(s).

Agent Over-Engineering Ratio 19.2/100 · LOW

Are wrappers, guards, and repeated structures necessary? 132 finding(s).

PR Review Velocity Impact 30.0/100 · MEDIUM

Which changes need focused human review? 222 finding(s).

What These Metrics Mean

Adjusted Signal
Legacy pattern score normalized per 1,000 scanned lines and multiplied by the repository-level time factor. It is not an estimate of AI authorship.
Raw Pattern Score
Sum of severity- and context-weighted pattern findings before applying the time factor.
Time Factor
A coarse multiplier based on repository last-push metadata. It does not identify when individual code was written.
Pattern Hits
Count of configured pattern findings. Review each location and surrounding code before acting.
HC Hit Rate
High- and critical-severity findings per scanned file. Severity is a configured detector weight, not proof of a vulnerability or authorship.
Lines / Files
Scan coverage denominators used by the legacy normalized score.

Pattern-Signal History

This chart tracks the legacy adjusted pattern score across scan runs. Changes can reflect source changes, scan coverage, or detector/scoring versions; they do not measure AI adoption or prove that a team refactored code. Compare runs only when their scoring versions are compatible. The dashed line tracks the raw pattern-hit count.

Severity Breakdown

Groups findings by configured severity weight. Severity is not a confidence estimate, security rating, or proof that a package is missing. Verify imports against the project's manifests and inspect each finding in its local design context.

CRITICAL 0HIGH 7MEDIUM 15LOW 200

Directory Score Breakdown

This horizontal bar chart shows where configured pattern scores accumulate across directories. Treat the bars as locations to inspect, not as evidence of authorship or code quality. Use the file-level findings to decide whether a directory needs a focused ownership, dependency, complexity, or review check.

Pattern Findings

The scanner identified 222 distinct pattern matches across 15 syntactic categories. Each entry below represents a discrete location in the source code where the engine recorded a detector match to inspect in context. Expand any category row to inspect the individual file paths, line numbers, code snippets, and the lexical context (CODE, COMMENT, or STRING) in which each match was detected.

Reading the findings table: The Severity column indicates the configured finding weight (CRITICAL / HIGH / MEDIUM / LOW). The Context column identifies whether the match occurred inside executable code, an inline comment, or a string literal — legacy comment-context matches receive a ×1.5 score weight. The ⚡ bolt icon marks clustered matches: three or more patterns within a 10-line window, each receiving an additional ×1.5 density multiplier under the legacy scoring model.

Hyper-Verbose Identifiers87 hits · 87 pts
SeverityFileLineSnippetContext
LOW…mo/frontend/src/common/loading/UploadLoadingScreen.tsx49function UploadLoadingScreenChangeVideoTrigger({CODE
LOWdemo/frontend/src/common/utils/ImageUtils.ts16export function convertVideoFrameToImageData(CODE
LOW…ntend/src/common/components/MobileFirstClickBanner.tsx62function MobileVideoGalleryModalTrigger({CODE
LOW…components/options/MoreOptionsToolbarBottomActions.tsx29export default function MoreOptionsToolbarBottomActions({onTabChange}: Props) {CODE
LOW…common/components/video/VideoFilmstripWithPlayback.tsx41export default function VideoFilmstripWithPlayback() {CODE
LOW…ntend/src/common/components/video/editor/ImageUtils.ts16export function convertVideoFrameToImageData(CODE
LOW…src/common/components/video/editor/DemoVideoEditor.tsx194 async function handleOptimisticPointUpdate(newPoints: SegmentationPoint[]) {CODE
LOW…components/gallery/DefaultVideoGalleryModalTrigger.tsx20export default function DefaultVideoGalleryModalTrigger({CODE
LOW…rc/common/components/gallery/DemoVideoGalleryModal.tsx122 function handleOpenVideoGalleryModal() {CODE
LOW…common/components/toolbar/useListenToStreamingState.ts23export default function useListenToStreamingState(): {CODE
LOW…mon/components/toolbar/ToolbarBottomActionsWrapper.tsx34export default function ToolbarBottomActionsWrapper({CODE
LOW…components/annotations/ClearAllPointsInVideoButton.tsx37export default function ClearAllPointsInVideoButton({onRestart}: Props) {CODE
LOW…components/annotations/ObjectsToolbarBottomActions.tsx31export default function ObjectsToolbarBottomActions({onTabChange}: Props) {CODE
LOW…/components/annotations/MobileObjectsToolbarHeader.tsx20export default function MobileObjectsToolbarHeader() {CODE
LOW…mon/components/effects/EffectsToolbarBottomActions.tsx29export default function EffectsToolbarBottomActions({onTabChange}: Props) {CODE
LOW…mon/components/effects/EffectsToolbarBottomActions.tsx30 function handleSwitchToMoreOptionsTab() {CODE
LOW…mmon/components/session/useCloseSessionBeforeUnload.ts32export default function useCloseSessionBeforeUnload() {CODE
LOW…o/frontend/src/common/error/ErrorSerializationUtils.ts21export function registerSerializableConstructors() {CODE
LOWdemo/frontend/src/graphql/RelayEnvironmentProvider.tsx36export default function OnevisionRelayEnvironmentProvider({CODE
LOWdemo/backend/server/app.py90def gen_track_with_mask_stream(CODE
LOWdemo/backend/server/inference/predictor.py357 def cancel_propagate_in_video(CODE
LOWdemo/backend/server/data/schema.py246 def cancel_propagate_in_video(CODE
LOWdemo/backend/server/data/schema.py269def _get_start_sec_duration_sec(CODE
LOWtools/vos_inference.py249def vos_separate_inference_per_object(CODE
LOWsav_dataset/utils/sav_utils.py101 def get_frames_and_annotations(CODE
LOWtraining/train.py117def add_pythonpath_to_sys_path():CODE
LOWtraining/optimizer.py41 def _validate_optimizer_schedulers(self):CODE
LOWtraining/optimizer.py112def name_constraints_to_parameters(CODE
LOWtraining/optimizer.py131def map_scheduler_cfgs_to_param_groups(CODE
LOWtraining/optimizer.py172def validate_param_group_params(param_groups: List[Dict], model: nn.Module):CODE
LOWtraining/optimizer.py194def unix_module_cls_pattern_to_parameter_names(CODE
LOWtraining/optimizer.py227def unix_param_pattern_to_parameter_names(CODE
LOWtraining/optimizer.py253def _unix_pattern_to_parameter_names(CODE
LOWtraining/optimizer.py275def get_module_cls_to_param_names(CODE
LOWtraining/optimizer.py422def layer_decay_param_modifier(CODE
LOW⚡training/trainer.py253 def _infer_distributed_backend_if_none(self, distributed_conf, accelerator):CODE
LOW⚡training/trainer.py262 def _setup_torch_dist_and_backend(self, cuda_conf, distributed_conf) -> None:CODE
LOWtraining/trainer.py291 def _setup_ddp_distributed_training(self, distributed_conf, accelerator):CODE
LOWtraining/trainer.py422 def _load_resuming_checkpoint(self, ckpt_path: str):CODE
LOWtraining/trainer.py447 def is_intermediate_val_epoch(self, epoch):CODE
LOWtraining/trainer.py891 def _log_meters_and_save_best_ckpts(self, phases: List[str]):CODE
LOWtraining/trainer.py1033 def _log_loss_detailed_and_return_core_loss(self, loss, loss_str, step):CODE
LOWtraining/dataset/transforms.py37def get_size_with_aspect_ratio(image_size, size, max_size=None):CODE
LOWtraining/utils/train_utils.py52def register_omegaconf_resolvers():CODE
LOWtraining/utils/train_utils.py66def setup_distributed_backend(backend, timeout_mins):CODE
LOWtraining/utils/train_utils.py81def get_machine_local_and_dist_rank():CODE
LOWtraining/utils/train_utils.py130def is_dist_avail_and_initialized():CODE
LOWtraining/utils/distributed.py186def convert_to_distributed_tensor(tensor: torch.Tensor) -> Tuple[torch.Tensor, str]:CODE
LOWtraining/utils/distributed.py212def is_distributed_training_run() -> bool:CODE
LOW⚡training/utils/distributed.py383def init_distributed_data_parallel_model(CODE
LOWtraining/utils/distributed.py504def all_gather_batch_with_grad(tensors):CODE
LOWtraining/utils/distributed.py571def is_dist_avail_and_initialized():CODE
LOWtraining/utils/checkpoint_utils.py30def unix_pattern_to_parameter_names(CODE
LOWtraining/utils/checkpoint_utils.py47def filter_params_matching_unix_pattern(CODE
LOWtraining/utils/checkpoint_utils.py68def exclude_params_matching_unix_pattern(CODE
LOWtraining/utils/checkpoint_utils.py99def assert_skipped_parameters_are_frozen(model: nn.Module, patterns: List[str]):CODE
LOWtraining/utils/checkpoint_utils.py123def with_check_parameter_frozen(CODE
LOWtraining/utils/checkpoint_utils.py247def load_checkpoint_and_apply_kernels(STRING
LOWtraining/utils/checkpoint_utils.py297def check_load_state_dict_errors(STRING
LOWtraining/utils/checkpoint_utils.py330def load_state_dict_into_model(STRING
27 more matches not shown…
Deep Nesting24 hits · 24 pts
SeverityFileLineSnippetContext
LOWdemo/backend/server/inference/predictor.py270CODE
LOWtools/vos_inference.py249CODE
LOWsav_dataset/utils/sav_benchmark.py156CODE
LOWsav_dataset/utils/sav_benchmark.py316CODE
LOWsav_dataset/utils/sav_benchmark.py237CODE
LOWtraining/optimizer.py422CODE
LOWtraining/optimizer.py52CODE
LOWtraining/trainer.py583CODE
LOWtraining/trainer.py703CODE
LOWtraining/trainer.py891CODE
LOWtraining/dataset/transforms.py104CODE
LOWtraining/dataset/transforms.py272CODE
LOWtraining/dataset/transforms.py354CODE
LOWtraining/dataset/vos_dataset.py79CODE
LOWtraining/dataset/vos_sampler.py42CODE
LOWtraining/dataset/vos_segment_loader.py24CODE
LOWtraining/utils/train_utils.py29CODE
LOWsam2/sam2_video_predictor_legacy.py426CODE
LOWsam2/sam2_video_predictor.py480CODE
LOWsam2/sam2_video_predictor.py546CODE
LOWsam2/utils/amg.py46CODE
LOWsam2/utils/amg.py61CODE
LOWsam2/modeling/sam2_base.py497CODE
LOWsam2/modeling/backbones/hieradet.py301CODE
Excessive Try-Catch Wrapping16 hits · 22 pts
SeverityFileLineSnippetContext
LOWsetup.py104 except Exception as e:CODE
LOW⚡setup.py122 except Exception as e:CODE
LOW⚡setup.py129 except Exception as e:CODE
LOW⚡setup.py136 except Exception as e:CODE
LOWsetup.py148except Exception as e:CODE
MEDIUMsetup.py119def finalize_options(self):CODE
MEDIUMsetup.py126def build_extensions(self):CODE
MEDIUMsetup.py133def get_ext_filename(self, ext_name):CODE
LOWtraining/train.py37 except Exception as e:CODE
LOWtraining/train.py99 except Exception as e:CODE
LOWtraining/dataset/vos_dataset.py64 except Exception as e:CODE
LOWtraining/dataset/sam2_datasets.py61 except Exception as e:CODE
LOWsam2/utils/transforms.py105 except Exception as e:CODE
LOWsam2/utils/misc.py141 except Exception as e:CODE
LOWsam2/utils/misc.py326 except Exception as e:CODE
MEDIUMsam2/utils/misc.py137def _load_frames():CODE
Cross-File Repetition4 hits · 20 pts
SeverityFileLineSnippetContext
HIGHsam2/automatic_mask_generator.py0load a pretrained model from the hugging face hub. arguments: model_id (str): the hugging face repository id. **kwargs: STRING
HIGHsam2/sam2_video_predictor_legacy.py0load a pretrained model from the hugging face hub. arguments: model_id (str): the hugging face repository id. **kwargs: STRING
HIGHsam2/sam2_video_predictor.py0load a pretrained model from the hugging face hub. arguments: model_id (str): the hugging face repository id. **kwargs: STRING
HIGHsam2/sam2_image_predictor.py0load a pretrained model from the hugging face hub. arguments: model_id (str): the hugging face repository id. **kwargs: STRING
Verbosity Indicators13 hits · 20 pts
SeverityFileLineSnippetContext
LOWtraining/dataset/transforms.py423 # Step 1: downsize the images and paste them into a mosaicCOMMENT
LOWtraining/dataset/transforms.py467 # Step 2: downsize the masks and paste them into the target grid of the mosaicCOMMENT
LOWsam2/sam2_video_predictor_legacy.py1065 # Step 0: clear the input on those frames where this object id has point or mask inputCOMMENT
LOWsam2/sam2_video_predictor_legacy.py1080 # Step 1: Update the object id mapping (note that it must be done after Step 0,COMMENT
LOWsam2/sam2_video_predictor_legacy.py1094 # Step 2: For per-object tensor storage, we shift their obj_idx in the dict keys.COMMENT
LOWsam2/sam2_video_predictor_legacy.py1110 # Step 3: For packed tensor storage, we index the remaining ids and rebuild the per-object slices.COMMENT
LOWsam2/sam2_video_predictor_legacy.py1132 # Step 4: Further collect the outputs on those frames in `obj_input_frames_inds`, whichCOMMENT
LOWsam2/sam2_video_predictor.py890 # Step 0: clear the input on those frames where this object id has point or mask inputCOMMENT
LOWsam2/sam2_video_predictor.py905 # Step 1: Update the object id mapping (note that it must be done after Step 0,COMMENT
LOWsam2/sam2_video_predictor.py919 # Step 2: For per-object tensor storage, we shift their obj_idx in the dict keys.COMMENT
LOWsam2/sam2_video_predictor.py934 # Step 3: Further collect the outputs on those frames in `obj_input_frames_inds`, whichCOMMENT
LOWsam2/modeling/sam2_base.py521 # Step 1: condition the visual features of the current frame on previous memoriesCOMMENT
LOWsam2/modeling/sam2_base.py663 # Step 2: Concatenate the memories and forward through the transformer encoderCOMMENT
Structural Annotation Overuse13 hits · 20 pts
SeverityFileLineSnippetContext
LOWtraining/dataset/transforms.py423 # Step 1: downsize the images and paste them into a mosaicCOMMENT
LOWtraining/dataset/transforms.py467 # Step 2: downsize the masks and paste them into the target grid of the mosaicCOMMENT
LOWsam2/sam2_video_predictor_legacy.py1065 # Step 0: clear the input on those frames where this object id has point or mask inputCOMMENT
LOWsam2/sam2_video_predictor_legacy.py1080 # Step 1: Update the object id mapping (note that it must be done after Step 0,COMMENT
LOWsam2/sam2_video_predictor_legacy.py1094 # Step 2: For per-object tensor storage, we shift their obj_idx in the dict keys.COMMENT
LOWsam2/sam2_video_predictor_legacy.py1110 # Step 3: For packed tensor storage, we index the remaining ids and rebuild the per-object slices.COMMENT
LOWsam2/sam2_video_predictor_legacy.py1132 # Step 4: Further collect the outputs on those frames in `obj_input_frames_inds`, whichCOMMENT
LOWsam2/sam2_video_predictor.py890 # Step 0: clear the input on those frames where this object id has point or mask inputCOMMENT
LOWsam2/sam2_video_predictor.py905 # Step 1: Update the object id mapping (note that it must be done after Step 0,COMMENT
LOWsam2/sam2_video_predictor.py919 # Step 2: For per-object tensor storage, we shift their obj_idx in the dict keys.COMMENT
LOWsam2/sam2_video_predictor.py934 # Step 3: Further collect the outputs on those frames in `obj_input_frames_inds`, whichCOMMENT
LOWsam2/modeling/sam2_base.py521 # Step 1: condition the visual features of the current frame on previous memoriesCOMMENT
LOWsam2/modeling/sam2_base.py663 # Step 2: Concatenate the memories and forward through the transformer encoderCOMMENT
Decorative Section Separators6 hits · 18 pts
SeverityFileLineSnippetContext
MEDIUMtraining/scripts/sav_frame_extraction_submitit.py20 # ------------COMMENT
MEDIUMtraining/scripts/sav_frame_extraction_submitit.py22 # ------------COMMENT
MEDIUMtraining/scripts/sav_frame_extraction_submitit.py40 # ------------COMMENT
MEDIUMtraining/scripts/sav_frame_extraction_submitit.py42 # ------------COMMENT
MEDIUMtraining/scripts/sav_frame_extraction_submitit.py64 # ------------COMMENT
MEDIUMtraining/scripts/sav_frame_extraction_submitit.py66 # ------------COMMENT
Over-Commented Block14 hits · 14 pts
SeverityFileLineSnippetContext
LOW…ntend/src/common/components/video/VideoWorkerBridge.ts501 // listener: (ev: WorkerEventMap[K]) => unknown,COMMENT
LOW…ntend/src/common/components/video/VideoWorkerBridge.ts521 // }COMMENT
LOWtraining/__init__.py1# Copyright (c) Meta Platforms, Inc. and affiliates.COMMENT
LOWtraining/dataset/__init__.py1# Copyright (c) Meta Platforms, Inc. and affiliates.COMMENT
LOWtraining/utils/__init__.py1# Copyright (c) Meta Platforms, Inc. and affiliates.COMMENT
LOWtraining/model/__init__.py1# Copyright (c) Meta Platforms, Inc. and affiliates.COMMENT
LOWtraining/model/sam2.py41 # - if `rand_init_cond_frames` below is True, we randomly sample 1~num_init_cond_frames initial conditioning fraCOMMENT
LOWcheckpoints/download_ckpts.sh21# sam2_hiera_t_url="${SAM2_BASE_URL}/sam2_hiera_tiny.pt"COMMENT
LOWsam2/utils/__init__.py1# Copyright (c) Meta Platforms, Inc. and affiliates.COMMENT
LOWsam2/modeling/sam2_base.py41 # (instead of using the transformer encoder)COMMENT
LOWsam2/modeling/sam2_base.py61 memory_temporal_stride_for_eval=1,COMMENT
LOWsam2/modeling/__init__.py1# Copyright (c) Meta Platforms, Inc. and affiliates.COMMENT
LOWsam2/modeling/sam/__init__.py1# Copyright (c) Meta Platforms, Inc. and affiliates.COMMENT
LOWsam2/modeling/backbones/__init__.py1# Copyright (c) Meta Platforms, Inc. and affiliates.COMMENT
Unused Imports13 hits · 13 pts
SeverityFileLineSnippetContext
LOWdemo/backend/server/app.py22CODE
LOWdemo/backend/server/data/data_types.py6CODE
LOWdemo/backend/server/data/data_types.py12CODE
LOWdemo/backend/server/data/schema.py10CODE
LOWtraining/optimizer.py11CODE
LOWtraining/dataset/vos_raw_dataset.py8CODE
LOWtraining/dataset/vos_raw_dataset.py14CODE
LOWtraining/dataset/sam2_datasets.py9CODE
LOWtraining/utils/data_utils.py14CODE
LOWtraining/model/sam2.py13CODE
LOWtraining/model/sam2.py13CODE
LOWsam2/automatic_mask_generator.py127CODE
LOWsam2/sam2_video_predictor.py7CODE
Self-Referential Comments5 hits · 13 pts
SeverityFileLineSnippetContext
MEDIUMtraining/dataset/transforms.py274 # Create a color jitter transformation paramsCOMMENT
MEDIUMtraining/dataset/transforms.py359 # Create a random affine transformationCOMMENT
MEDIUMcheckpoints/download_ckpts.sh19# Define the URLs for SAM 2 checkpointsCOMMENT
MEDIUMcheckpoints/download_ckpts.sh39# Define the URLs for SAM 2.1 checkpointsCOMMENT
MEDIUMsam2/sam2_image_predictor.py185 """This function is very similar to predict(...), however it is used for batched mode, when the model is expecteSTRING
Modern Structural Boilerplate9 hits · 11 pts
SeverityFileLineSnippetContext
LOWdemo/backend/server/app_conf.py10logger = logging.getLogger(__name__)CODE
LOWdemo/backend/server/app.py27logger = logging.getLogger(__name__)CODE
LOWdemo/backend/server/inference/predictor.py40logger = logging.getLogger(__name__)CODE
LOWdemo/backend/server/data/store.py13def set_videos(videos: Dict[str, Video]) -> None:CODE
LOW⚡training/trainer.py257 def _setup_env_variables(self, env_variables_conf) -> None:CODE
LOW⚡training/trainer.py262 def _setup_torch_dist_and_backend(self, cuda_conf, distributed_conf) -> None:CODE
LOWtraining/dataset/sam2_datasets.py129 def _set_dataset_epoch(self, dataset, epoch: int) -> None:CODE
LOW⚡training/utils/distributed.py368def set_cuda_device_index(idx: int) -> None:CODE
LOW⚡training/utils/distributed.py374def set_cpu_device() -> None:CODE
Docstring Block Structure2 hits · 10 pts
SeverityFileLineSnippetContext
HIGHtraining/optimizer.py115Return parameters which match the intersection of parameter constraints. Note that this returns the parameters themSTRING
HIGHtraining/optimizer.py135Produce parameter groups corresponding to all the scheduler configs. Takes all the scheduler configs, each of whichSTRING
Redundant / Tautological Comments6 hits · 9 pts
SeverityFileLineSnippetContext
LOWtraining/trainer.py958 # Check if there are any duplicatesCOMMENT
LOWtraining/dataset/vos_raw_dataset.py90 # Check if it's not in excluded_filesCOMMENT
LOWtraining/dataset/vos_raw_dataset.py182 # Check if it's not in excluded_files and it existsCOMMENT
LOWsam2/build_sam.py17# Check if the user is running Python from the parent directory of the sam2 repoCOMMENT
LOWsam2/utils/amg.py242 # Check if boxes has a channel dimensionCOMMENT
LOWsam2/utils/amg.py251 # Check if points has a channel dimensionCOMMENT
AI Structural Patterns9 hits · 9 pts
SeverityFileLineSnippetContext
LOWtraining/trainer.py148CODE
LOWtraining/model/sam2.py26CODE
LOWsam2/automatic_mask_generator.py37CODE
LOWsam2/modeling/sam2_base.py23CODE
LOWsam2/modeling/sam/transformer.py248CODE
LOWsam2/modeling/sam/transformer.py311CODE
LOWsam2/modeling/sam/mask_decoder.py16CODE
LOWsam2/modeling/backbones/image_encoder.py42CODE
LOWsam2/modeling/backbones/hieradet.py174CODE
Empty Error Handlers1 hit · 5 pts
SeverityFileLineSnippetContext
HIGHtraining/dataset/vos_segment_loader.py19except:CODE