Rembg is a tool to remove images background
This report presents the forensic synthetic code analysis of danielgatis/rembg, a Python project with 24,506 GitHub stars. SynthScan v2.0 examined 6,083 lines of code across 56 source files, recording 151 pattern matches distributed across 8 syntactic categories. The overall adjusted score of 80.4 places this repository in the Strong AI signal band.
The scanner applied 160+ deterministic lexical heuristics, multi-line block detectors, abstract syntax tree depth profilers, and a cross-file Jaccard similarity matrix to construct a statistically normalised synthetic code estimate. All matches are individually weighted by severity coefficient and contextual multiplier before summation, and the resulting headline score is temporally discounted to account for the repository's development history relative to the commercial emergence of large language model coding tooling (November 2022 onward).
This chart maps the temporal evolution of the adjusted synthetic code score across successive scan runs. An upward trajectory indicates ongoing incorporation of AI-generated code or expanding LLM-assisted scaffolding; a stable or declining trajectory may reflect active human refactoring, code removal, or the adoption of stricter authorship policies. The dashed secondary line (right axis) independently tracks total raw pattern hit count, which can diverge from the normalised score when codebase size changes significantly between scans.
Classifies detected patterns by their diagnostic confidence and structural impact. CRITICAL patterns (coefficient 10) represent definitive synthetic signatures — hallucinated imports, explicit LLM attribution metadata — virtually never produced by human authors. HIGH (5) indicates strong structural tells such as cross-file repetition or cross-linguistic idioms. MEDIUM (2) covers recognisable conversational padding and AI-specific vocabulary. LOW (1) captures subtle indicators like tautological comments and generic boilerplate that require density to carry independent signal.
This horizontal bar chart decomposes the repository's raw synthetic code score by top-level directory, allowing you to pinpoint precisely which modules or components carry the highest AI authorship density. Directories with disproportionately high scores relative to their size warrant targeted manual review: concentrated AI signatures often trace back to mass-generated configuration layers, auto-ported test suites, LLM-scaffolded boilerplate classes, or entire subsystems authored under heavy copilot assistance. Use this view to prioritise your human code-review effort.
The scanner identified 151 distinct pattern matches across 8 syntactic categories. Each entry below represents a discrete location in the source code where the engine recorded a statistically significant AI authorship indicator. 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 diagnostic confidence level (CRITICAL / HIGH / MEDIUM / LOW). The Context column identifies whether the match occurred inside executable code, an inline comment, or a string literal — comment-context matches receive a ×1.5 weight because LLMs systematically over-annotate. The ⚡ bolt icon marks clustered matches: three or more patterns within a 10-line window, each receiving an additional ×1.5 density multiplier as dense clusters constitute far stronger evidence of synthetic authorship than isolated hits.
| Severity | File | Line | Snippet | Context |
|---|---|---|---|---|
| HIGH | rembg/session_factory.py | 16 | Create a new session object based on the specified model name. This function searches for the session class ba | STRING |
| HIGH | rembg/sessions/u2net_custom.py | 15 | Initialize a new U2netCustomSession object. Parameters: model_name (str): The name of the | STRING |
| HIGH | rembg/sessions/u2net_custom.py | 34 | Predict the segmentation mask for the input image. Parameters: img (PILImage): The input i | STRING |
| HIGH | rembg/sessions/u2net_custom.py | 67 | Download the model files. Parameters: *args: Additional positional arguments. | STRING |
| HIGH | rembg/sessions/u2net_custom.py | 81 | Get the name of the model. Parameters: *args: Additional positional arguments. | STRING |
| HIGH | rembg/sessions/withoutbg.py | 34 | Initialize a WithoutBgSession. Does not call BaseSession.__init__ because no local ONNX model is used. | STRING |
| HIGH | rembg/sessions/withoutbg.py | 60 | Predict the alpha mask for the input image via the withoutBG API. Parameters: img (PILImag | STRING |
| HIGH | rembg/sessions/u2net_cloth_seg.py | 59 | Predict the cloth category of an image. This method takes an image as input and predicts the cloth cat | STRING |
| HIGH | rembg/sessions/birefnet_portrait.py | 15 | Downloads the BiRefNet-Portrait model file from a specific URL and saves it. Parameters: * | STRING |
| HIGH | rembg/sessions/birefnet_portrait.py | 46 | Returns the name of the BiRefNet-Portrait session. Parameters: *args: Additional positiona | STRING |
| HIGH | rembg/sessions/birefnet_general.py | 21 | Predicts the output masks for the input image using the inner session. Parameters: img (PI | STRING |
| HIGH | rembg/sessions/birefnet_general.py | 54 | Downloads the BiRefNet-General model file from a specific URL and saves it. Parameters: *a | STRING |
| HIGH | rembg/sessions/birefnet_general.py | 85 | Returns the name of the BiRefNet-General session. Parameters: *args: Additional positional | STRING |
| HIGH | rembg/sessions/u2net_human_seg.py | 18 | Predicts human segmentation masks for the input image. Parameters: img (PILImage): The inp | STRING |
| HIGH | rembg/sessions/u2net_human_seg.py | 51 | Downloads the U2Net model weights. Parameters: *args: Variable length argument list. | STRING |
| HIGH | rembg/sessions/u2net_human_seg.py | 82 | Returns the name of the U2Net model. Parameters: *args: Variable length argument list. | STRING |
| HIGH | rembg/sessions/ben_custom.py | 63 | Download the model files. Parameters: *args: Additional positional arguments. | STRING |
| HIGH | rembg/sessions/ben_custom.py | 77 | Get the name of the model. Parameters: *args: Additional positional arguments. | STRING |
| HIGH | rembg/sessions/dis_anime.py | 18 | Use a pre-trained model to predict the object in the given image. Parameters: img (PILImag | STRING |
| HIGH | rembg/sessions/dis_anime.py | 49 | Download the pre-trained models. Parameters: *args: Variable length argument list. | STRING |
| HIGH | rembg/sessions/dis_anime.py | 80 | Get the name of the pre-trained model. Parameters: *args: Variable length argument list. | STRING |
| HIGH | rembg/sessions/dis_custom.py | 62 | Download the model files. Parameters: *args: Additional positional arguments. | STRING |
| HIGH | rembg/sessions/dis_custom.py | 76 | Get the name of the model. Parameters: *args: Additional positional arguments. | STRING |
| HIGH | rembg/sessions/birefnet_general_lite.py | 15 | Downloads the BiRefNet-General-Lite model file from a specific URL and saves it. Parameters: | STRING |
| HIGH | rembg/sessions/birefnet_general_lite.py | 46 | Returns the name of the BiRefNet-General-Lite session. Parameters: *args: Additional posit | STRING |
| HIGH | rembg/sessions/birefnet_hrsod.py | 15 | Downloads the BiRefNet-HRSOD model file from a specific URL and saves it. Parameters: *arg | STRING |
| HIGH | rembg/sessions/birefnet_hrsod.py | 46 | Returns the name of the BiRefNet-HRSOD session. Parameters: *args: Additional positional a | STRING |
| HIGH | rembg/sessions/dis_general_use.py | 45 | Downloads the pre-trained model file. This class method downloads the pre-trained model file from a sp | STRING |
| HIGH | rembg/sessions/dis_general_use.py | 78 | Returns the name of the model. This class method returns the name of the model. Parameters: | STRING |
| HIGH | rembg/sessions/birefnet_massive.py | 15 | Downloads the BiRefNet-Massive model file from a specific URL and saves it. Parameters: *a | STRING |
| HIGH | rembg/sessions/birefnet_massive.py | 46 | Returns the name of the BiRefNet-Massive session. Parameters: *args: Additional positional | STRING |
| HIGH | rembg/sessions/birefnet_dis.py | 15 | Downloads the BiRefNet-DIS model file from a specific URL and saves it. Parameters: *args: | STRING |
| HIGH | rembg/sessions/birefnet_dis.py | 46 | Returns the name of the BiRefNet-DIS session. Parameters: *args: Additional positional arg | STRING |
| HIGH | rembg/sessions/sam.py | 172 | Predict masks for an input image. This function takes an image as input and performs various preproces | STRING |
| HIGH | rembg/sessions/sam.py | 300 | Class method to download ONNX model files. This method is responsible for downloading two ONNX model f | STRING |
| HIGH | rembg/sessions/sam.py | 391 | Class method to return a string value. This method returns the string value 'sam'. Parameters | STRING |
| HIGH | rembg/sessions/u2net.py | 18 | Predicts the output masks for the input image using the inner session. Parameters: img (PI | STRING |
| HIGH | rembg/sessions/u2net.py | 51 | Downloads the U2net model file from a specific URL and saves it. Parameters: *args: Additi | STRING |
| HIGH | rembg/sessions/u2net.py | 82 | Returns the name of the U2net session. Parameters: *args: Additional positional arguments. | STRING |
| HIGH | rembg/sessions/silueta.py | 16 | Predict the mask of the input image. This method takes an image as input, preprocesses it, and perform | STRING |
| HIGH | rembg/sessions/silueta.py | 51 | Download the pre-trained model file. This method downloads the pre-trained model file from a specified | STRING |
| HIGH | rembg/sessions/silueta.py | 84 | Return the name of the model. This method returns the name of the Silueta model. Parameters: | STRING |
| HIGH | rembg/sessions/bria_rmbg.py | 18 | Predicts the output masks for the input image using the inner session. Parameters: img (PI | STRING |
| HIGH | rembg/sessions/bria_rmbg.py | 51 | Downloads the BRIA-RMBG 2.0 model file from a specific URL and saves it. Parameters: *args | STRING |
| HIGH | rembg/sessions/bria_rmbg.py | 82 | Returns the name of the Bria-rmbg session. Parameters: *args: Additional positional argume | STRING |
| HIGH | rembg/sessions/birefnet_cod.py | 15 | Downloads the BiRefNet-COD model file from a specific URL and saves it. Parameters: *args: | STRING |
| HIGH | rembg/sessions/birefnet_cod.py | 46 | Returns the name of the BiRefNet-COD session. Parameters: *args: Additional positional arg | STRING |
| HIGH | rembg/commands/p_command.py | 216 | Command-line interface (CLI) program for performing background removal on images in a folder. This program tak | STRING |
| HIGH | rembg/commands/i_command.py | 103 | Click command line interface function to process an input file based on the provided options. This function is | STRING |
| HIGH | rembg/commands/b_command.py | 112 | Command-line interface for processing images by removing the background using a specified model and generating a ma | STRING |
| Severity | File | Line | Snippet | Context |
|---|---|---|---|---|
| HIGH | rembg/sessions/u2net_custom.py | 0 | download the model files. parameters: *args: additional positional arguments. **kwargs: additional keyword arguments. re | STRING |
| HIGH | rembg/sessions/ben_custom.py | 0 | download the model files. parameters: *args: additional positional arguments. **kwargs: additional keyword arguments. re | STRING |
| HIGH | rembg/sessions/dis_custom.py | 0 | download the model files. parameters: *args: additional positional arguments. **kwargs: additional keyword arguments. re | STRING |
| HIGH | rembg/sessions/u2net_custom.py | 0 | get the name of the model. parameters: *args: additional positional arguments. **kwargs: additional keyword arguments. r | STRING |
| HIGH | rembg/sessions/ben_custom.py | 0 | get the name of the model. parameters: *args: additional positional arguments. **kwargs: additional keyword arguments. r | STRING |
| HIGH | rembg/sessions/dis_custom.py | 0 | get the name of the model. parameters: *args: additional positional arguments. **kwargs: additional keyword arguments. r | STRING |
| HIGH | rembg/sessions/birefnet_portrait.py | 0 | downloads the birefnet-cod model file from a specific url and saves it. parameters: *args: additional positional argumen | STRING |
| HIGH | rembg/sessions/birefnet_general.py | 0 | downloads the birefnet-cod model file from a specific url and saves it. parameters: *args: additional positional argumen | STRING |
| HIGH | rembg/sessions/birefnet_general_lite.py | 0 | downloads the birefnet-cod model file from a specific url and saves it. parameters: *args: additional positional argumen | STRING |
| HIGH | rembg/sessions/birefnet_hrsod.py | 0 | downloads the birefnet-cod model file from a specific url and saves it. parameters: *args: additional positional argumen | STRING |
| HIGH | rembg/sessions/birefnet_massive.py | 0 | downloads the birefnet-cod model file from a specific url and saves it. parameters: *args: additional positional argumen | STRING |
| HIGH | rembg/sessions/birefnet_dis.py | 0 | downloads the birefnet-cod model file from a specific url and saves it. parameters: *args: additional positional argumen | STRING |
| HIGH | rembg/sessions/u2net.py | 0 | downloads the birefnet-cod model file from a specific url and saves it. parameters: *args: additional positional argumen | STRING |
| HIGH | rembg/sessions/bria_rmbg.py | 0 | downloads the birefnet-cod model file from a specific url and saves it. parameters: *args: additional positional argumen | STRING |
| HIGH | rembg/sessions/birefnet_cod.py | 0 | downloads the birefnet-cod model file from a specific url and saves it. parameters: *args: additional positional argumen | STRING |
| HIGH | rembg/sessions/birefnet_portrait.py | 0 | returns the name of the birefnet-cod session. parameters: *args: additional positional arguments. **kwargs: additional k | STRING |
| HIGH | rembg/sessions/birefnet_general.py | 0 | returns the name of the birefnet-cod session. parameters: *args: additional positional arguments. **kwargs: additional k | STRING |
| HIGH | rembg/sessions/birefnet_general_lite.py | 0 | returns the name of the birefnet-cod session. parameters: *args: additional positional arguments. **kwargs: additional k | STRING |
| HIGH | rembg/sessions/birefnet_hrsod.py | 0 | returns the name of the birefnet-cod session. parameters: *args: additional positional arguments. **kwargs: additional k | STRING |
| HIGH | rembg/sessions/birefnet_massive.py | 0 | returns the name of the birefnet-cod session. parameters: *args: additional positional arguments. **kwargs: additional k | STRING |
| HIGH | rembg/sessions/birefnet_dis.py | 0 | returns the name of the birefnet-cod session. parameters: *args: additional positional arguments. **kwargs: additional k | STRING |
| HIGH | rembg/sessions/u2net.py | 0 | returns the name of the birefnet-cod session. parameters: *args: additional positional arguments. **kwargs: additional k | STRING |
| HIGH | rembg/sessions/bria_rmbg.py | 0 | returns the name of the birefnet-cod session. parameters: *args: additional positional arguments. **kwargs: additional k | STRING |
| HIGH | rembg/sessions/birefnet_cod.py | 0 | returns the name of the birefnet-cod session. parameters: *args: additional positional arguments. **kwargs: additional k | STRING |
| HIGH | rembg/sessions/birefnet_general.py | 0 | predicts the output masks for the input image using the inner session. parameters: img (pilimage): the input image. *arg | STRING |
| HIGH | rembg/sessions/u2net.py | 0 | predicts the output masks for the input image using the inner session. parameters: img (pilimage): the input image. *arg | STRING |
| HIGH | rembg/sessions/bria_rmbg.py | 0 | predicts the output masks for the input image using the inner session. parameters: img (pilimage): the input image. *arg | STRING |
| HIGH | rembg/sessions/ben_custom.py | 0 | predicts the mask image for the input image. this method takes a pilimage object as input and returns a list of pilimage | STRING |
| HIGH | rembg/sessions/dis_custom.py | 0 | predicts the mask image for the input image. this method takes a pilimage object as input and returns a list of pilimage | STRING |
| HIGH | rembg/sessions/dis_general_use.py | 0 | predicts the mask image for the input image. this method takes a pilimage object as input and returns a list of pilimage | STRING |
| Severity | File | Line | Snippet | Context |
|---|---|---|---|---|
| LOW | tests/test_decontaminate.py | 60 | def test_decontaminate_removes_background_color_fringing(): | CODE |
| LOW | tests/test_decontaminate.py | 79 | def test_decontaminate_preserves_alpha(): | CODE |
| LOW | tests/test_decontaminate.py | 89 | def test_decontaminate_leaves_opaque_pixels_alone(): | CODE |
| LOW⚡ | tests/test_model_home.py | 17 | def test_defaults_to_dot_rembg(clean_env): | CODE |
| LOW⚡ | tests/test_model_home.py | 21 | def test_rembg_home_env_wins_over_default(clean_env): | CODE |
| LOW⚡ | tests/test_model_home.py | 26 | def test_xdg_data_home_has_no_leading_dot(clean_env): | CODE |
| LOW⚡ | tests/test_model_home.py | 32 | def test_legacy_env_still_takes_precedence(clean_env): | CODE |
| LOW | tests/test_model_home.py | 43 | def test_model_dir_is_per_model(clean_env): | CODE |
| LOW | tests/test_model_home.py | 48 | def test_resolve_existing_prefers_new_layout(clean_env, tmp_path): | CODE |
| LOW | tests/test_model_home.py | 59 | def test_resolve_existing_falls_back_to_legacy(clean_env, tmp_path): | CODE |
| LOW | tests/test_model_home.py | 71 | def test_resolve_existing_returns_none_when_absent(clean_env, tmp_path): | CODE |
| LOW | tests/test_model_home.py | 78 | def test_validate_model_path_accepts_both_roots(clean_env, tmp_path): | CODE |
| LOW⚡ | tests/test_model_home.py | 89 | def test_validate_model_path_rejects_outside_paths(clean_env, tmp_path): | CODE |
| LOW⚡ | tests/test_model_home.py | 96 | def test_validate_model_path_rejects_traversal(clean_env, tmp_path): | CODE |
| LOW⚡ | tests/test_model_home.py | 105 | def test_validate_model_path_rejects_sibling_prefix(clean_env, tmp_path): | CODE |
| LOW⚡ | tests/test_model_home.py | 115 | def test_validate_model_path_requires_the_argument(clean_env): | CODE |
| LOW⚡ | tests/test_matting.py | 13 | def test_default_variant_is_a_known_one(): | CODE |
| LOW⚡ | tests/test_matting.py | 17 | def test_every_variant_declares_a_file_and_checksum(): | CODE |
| LOW⚡ | tests/test_matting.py | 23 | def test_resolve_variant_defaults_when_unset(): | CODE |
| LOW⚡ | tests/test_matting.py | 27 | def test_resolve_variant_accepts_known_names(): | CODE |
| LOW⚡ | tests/test_matting.py | 32 | def test_resolve_variant_rejects_unknown_names(): | CODE |
| LOW⚡ | tests/test_matting.py | 37 | def test_resolve_variant_error_lists_the_options(): | CODE |
| LOW⚡ | tests/test_matting.py | 53 | def test_trimap_has_only_the_three_expected_levels(): | CODE |
| LOW⚡ | tests/test_matting.py | 58 | def test_trimap_marks_an_unknown_band(): | CODE |
| LOW⚡ | tests/test_matting.py | 63 | def test_trimap_keeps_the_mask_size(): | CODE |
| LOW⚡ | tests/test_matting.py | 68 | def test_larger_erode_size_widens_the_unknown_band(): | CODE |
| LOW⚡ | tests/test_matting.py | 75 | def test_trimap_accepts_a_non_grayscale_mask(): | CODE |
| LOW | tests/test_withoutbg.py | 18 | def test_missing_api_key_raises(monkeypatch): | CODE |
| LOW | tests/test_withoutbg.py | 30 | def test_api_key_kwarg_overrides_env(monkeypatch): | CODE |
| LOW | tests/test_withoutbg.py | 36 | def test_name_and_download_models(): | CODE |
| LOW | tests/test_withoutbg.py | 47 | def test_predict_rejects_oversized_upload(monkeypatch): | CODE |
| LOW | tests/test_withoutbg.py | 65 | def test_predict_returns_mask_matching_input_size(monkeypatch): | CODE |
| LOW | tests/test_withoutbg.py | 93 | def test_predict_http_error_raises(monkeypatch): | CODE |
| LOW | tests/test_migrate.py | 27 | def test_dry_run_touches_nothing(layout): | CODE |
| LOW | tests/test_migrate.py | 35 | def test_migrate_copies_into_per_model_dirs(layout): | CODE |
| LOW⚡ | tests/test_migrate.py | 48 | def test_migrate_keeps_originals_by_default(layout): | CODE |
| LOW⚡ | tests/test_migrate.py | 55 | def test_unrecognised_files_are_never_moved(layout): | CODE |
| LOW⚡ | tests/test_migrate.py | 62 | def test_orphans_are_kept_unless_asked(layout): | CODE |
| LOW⚡ | tests/test_migrate.py | 67 | def test_clean_orphans_removes_them(layout): | CODE |
| LOW⚡ | tests/test_migrate.py | 72 | def test_migrate_is_idempotent(layout): | CODE |
| LOW⚡ | tests/test_migrate.py | 81 | def test_second_pass_reclaims_already_migrated_files(layout): | CODE |
| LOW | tests/test_migrate.py | 93 | def test_mismatched_copy_is_left_alone(layout): | CODE |
| LOW | tests/test_migrate.py | 105 | def test_missing_legacy_dir_is_not_an_error(monkeypatch, tmp_path): | CODE |
| LOW | tests/test_migrate.py | 116 | def test_same_source_and_target_is_refused(monkeypatch, tmp_path): | CODE |
| Severity | File | Line | Snippet | Context |
|---|---|---|---|---|
| MEDIUM⚡ | rembg/bg.py | 248 | print(f"Error: no model found: {model}") | CODE |
| LOW⚡ | rembg/bg.py | 256 | except Exception as e: | CODE |
| MEDIUM⚡ | rembg/bg.py | 257 | print(f"Error downloading model: {e}") | CODE |
| LOW | rembg/commands/p_command.py | 240 | except Exception: | CODE |
| LOW | rembg/commands/p_command.py | 272 | except Exception as e: | CODE |
| LOW | rembg/commands/i_command.py | 120 | except Exception: | CODE |
| LOW | rembg/commands/b_command.py | 131 | except Exception: | CODE |
| LOW | rembg/commands/s_command.py | 214 | except Exception: | CODE |
| LOW | rembg/commands/s_command.py | 247 | except Exception: | CODE |
| LOW | rembg/commands/s_command.py | 272 | except Exception: | CODE |
| MEDIUM | rembg/commands/s_command.py | 244 | def startup(): | CODE |
| LOW | rembg/commands/m_command.py | 20 | except Exception: # nosec B112 - a session that cannot report its own | CODE |
| Severity | File | Line | Snippet | Context |
|---|---|---|---|---|
| LOW | rembg/bg.py | 32 | CODE | |
| LOW | rembg/__init__.py | 11 | CODE | |
| LOW | rembg/__init__.py | 12 | CODE | |
| LOW | rembg/sessions/__init__.py | 1 | CODE | |
| LOW | rembg/sessions/__init__.py | 3 | CODE | |
| LOW | rembg/commands/b_command.py | 6 | CODE |
| Severity | File | Line | Snippet | Context |
|---|---|---|---|---|
| LOW | tests/test_remove.py | 13 | CODE | |
| LOW | rembg/bg.py | 237 | CODE | |
| LOW | rembg/bg.py | 260 | CODE | |
| LOW | rembg/sessions/base.py | 13 | CODE | |
| LOW | rembg/commands/m_command.py | 60 | CODE |
| Severity | File | Line | Snippet | Context |
|---|---|---|---|---|
| LOW | rembg/bg.py | 260 | CODE | |
| LOW | rembg/commands/s_command.py | 111 | CODE | |
| LOW | rembg/commands/s_command.py | 160 | CODE |
| Severity | File | Line | Snippet | Context |
|---|---|---|---|---|
| MEDIUM | rembg/sessions/u2netp.py | 13 | """This class represents a session for using the U2netp model.""" | STRING |