Repository Analysis

danielgatis/rembg

Rembg is a tool to remove images background

80.4 Strong AI signal View on GitHub

Analysis Overview

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).

80.4
Adjusted Score
80.4
Raw Score
100%
Time Factor
2026-08-18
Last Push
24.5K
Stars
Python
Language
6.1K
Lines of Code
56
Files
151
Pattern Hits
2026-08-29
Scan Date
1.43
HC Hit Rate

What These Metrics Mean

Adjusted Score
Primary synthetic code indicator. Raw score normalised per 1,000 lines of code and multiplied by the temporal discount factor. This is the definitive comparative metric — use it to rank repositories by AI authorship density.
Raw Score
The unmodified sum of all severity-weighted, context-multiplied pattern match scores before temporal discounting. Reflects the absolute signal strength independent of when the repository was last active.
Time Factor
The temporal discount multiplier (0–100%) applied to the raw score. Repositories last updated before ChatGPT's launch (Nov 2022) receive a 5% factor. Full signal is only assigned to repositories active in the post-adoption era (Jan 2024+).
Pattern Hits
Total count of individual pattern matches across all files and categories. A high hit count with a low score may indicate a very large codebase with isolated AI snippets; a low count with a high score indicates dense, concentrated AI signatures.
HC Hit Rate
High+Critical pattern hits per file, averaged across the repository. This orthogonal signal catches repositories where a few files are densely packed with high-severity AI tells — a strong indicator even when the normalised score appears moderate due to codebase size.
Lines of Code / Files
Total lines and files analysed. The scanner examines 94 file extensions. These denominators are used to normalise the score, enabling fair comparison between repositories of vastly different sizes.

Score History

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.

Severity Breakdown

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.

CRITICAL 0HIGH 80MEDIUM 4LOW 67

Directory Score Breakdown

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.

Pattern Findings

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.

Docstring Block Structure50 hits · 250 pts
SeverityFileLineSnippetContext
HIGHrembg/session_factory.py16 Create a new session object based on the specified model name. This function searches for the session class baSTRING
HIGHrembg/sessions/u2net_custom.py15 Initialize a new U2netCustomSession object. Parameters: model_name (str): The name of the STRING
HIGHrembg/sessions/u2net_custom.py34 Predict the segmentation mask for the input image. Parameters: img (PILImage): The input iSTRING
HIGHrembg/sessions/u2net_custom.py67 Download the model files. Parameters: *args: Additional positional arguments. STRING
HIGHrembg/sessions/u2net_custom.py81 Get the name of the model. Parameters: *args: Additional positional arguments. STRING
HIGHrembg/sessions/withoutbg.py34 Initialize a WithoutBgSession. Does not call BaseSession.__init__ because no local ONNX model is used.STRING
HIGHrembg/sessions/withoutbg.py60 Predict the alpha mask for the input image via the withoutBG API. Parameters: img (PILImagSTRING
HIGHrembg/sessions/u2net_cloth_seg.py59 Predict the cloth category of an image. This method takes an image as input and predicts the cloth catSTRING
HIGHrembg/sessions/birefnet_portrait.py15 Downloads the BiRefNet-Portrait model file from a specific URL and saves it. Parameters: *STRING
HIGHrembg/sessions/birefnet_portrait.py46 Returns the name of the BiRefNet-Portrait session. Parameters: *args: Additional positionaSTRING
HIGHrembg/sessions/birefnet_general.py21 Predicts the output masks for the input image using the inner session. Parameters: img (PISTRING
HIGHrembg/sessions/birefnet_general.py54 Downloads the BiRefNet-General model file from a specific URL and saves it. Parameters: *aSTRING
HIGHrembg/sessions/birefnet_general.py85 Returns the name of the BiRefNet-General session. Parameters: *args: Additional positionalSTRING
HIGHrembg/sessions/u2net_human_seg.py18 Predicts human segmentation masks for the input image. Parameters: img (PILImage): The inpSTRING
HIGHrembg/sessions/u2net_human_seg.py51 Downloads the U2Net model weights. Parameters: *args: Variable length argument list. STRING
HIGHrembg/sessions/u2net_human_seg.py82 Returns the name of the U2Net model. Parameters: *args: Variable length argument list. STRING
HIGHrembg/sessions/ben_custom.py63 Download the model files. Parameters: *args: Additional positional arguments. STRING
HIGHrembg/sessions/ben_custom.py77 Get the name of the model. Parameters: *args: Additional positional arguments. STRING
HIGHrembg/sessions/dis_anime.py18 Use a pre-trained model to predict the object in the given image. Parameters: img (PILImagSTRING
HIGHrembg/sessions/dis_anime.py49 Download the pre-trained models. Parameters: *args: Variable length argument list. STRING
HIGHrembg/sessions/dis_anime.py80 Get the name of the pre-trained model. Parameters: *args: Variable length argument list. STRING
HIGHrembg/sessions/dis_custom.py62 Download the model files. Parameters: *args: Additional positional arguments. STRING
HIGHrembg/sessions/dis_custom.py76 Get the name of the model. Parameters: *args: Additional positional arguments. STRING
HIGHrembg/sessions/birefnet_general_lite.py15 Downloads the BiRefNet-General-Lite model file from a specific URL and saves it. Parameters: STRING
HIGHrembg/sessions/birefnet_general_lite.py46 Returns the name of the BiRefNet-General-Lite session. Parameters: *args: Additional positSTRING
HIGHrembg/sessions/birefnet_hrsod.py15 Downloads the BiRefNet-HRSOD model file from a specific URL and saves it. Parameters: *argSTRING
HIGHrembg/sessions/birefnet_hrsod.py46 Returns the name of the BiRefNet-HRSOD session. Parameters: *args: Additional positional aSTRING
HIGHrembg/sessions/dis_general_use.py45 Downloads the pre-trained model file. This class method downloads the pre-trained model file from a spSTRING
HIGHrembg/sessions/dis_general_use.py78 Returns the name of the model. This class method returns the name of the model. Parameters: STRING
HIGHrembg/sessions/birefnet_massive.py15 Downloads the BiRefNet-Massive model file from a specific URL and saves it. Parameters: *aSTRING
HIGHrembg/sessions/birefnet_massive.py46 Returns the name of the BiRefNet-Massive session. Parameters: *args: Additional positionalSTRING
HIGHrembg/sessions/birefnet_dis.py15 Downloads the BiRefNet-DIS model file from a specific URL and saves it. Parameters: *args:STRING
HIGHrembg/sessions/birefnet_dis.py46 Returns the name of the BiRefNet-DIS session. Parameters: *args: Additional positional argSTRING
HIGHrembg/sessions/sam.py172 Predict masks for an input image. This function takes an image as input and performs various preprocesSTRING
HIGHrembg/sessions/sam.py300 Class method to download ONNX model files. This method is responsible for downloading two ONNX model fSTRING
HIGHrembg/sessions/sam.py391 Class method to return a string value. This method returns the string value 'sam'. ParametersSTRING
HIGHrembg/sessions/u2net.py18 Predicts the output masks for the input image using the inner session. Parameters: img (PISTRING
HIGHrembg/sessions/u2net.py51 Downloads the U2net model file from a specific URL and saves it. Parameters: *args: AdditiSTRING
HIGHrembg/sessions/u2net.py82 Returns the name of the U2net session. Parameters: *args: Additional positional arguments.STRING
HIGHrembg/sessions/silueta.py16 Predict the mask of the input image. This method takes an image as input, preprocesses it, and performSTRING
HIGHrembg/sessions/silueta.py51 Download the pre-trained model file. This method downloads the pre-trained model file from a specifiedSTRING
HIGHrembg/sessions/silueta.py84 Return the name of the model. This method returns the name of the Silueta model. Parameters: STRING
HIGHrembg/sessions/bria_rmbg.py18 Predicts the output masks for the input image using the inner session. Parameters: img (PISTRING
HIGHrembg/sessions/bria_rmbg.py51 Downloads the BRIA-RMBG 2.0 model file from a specific URL and saves it. Parameters: *argsSTRING
HIGHrembg/sessions/bria_rmbg.py82 Returns the name of the Bria-rmbg session. Parameters: *args: Additional positional argumeSTRING
HIGHrembg/sessions/birefnet_cod.py15 Downloads the BiRefNet-COD model file from a specific URL and saves it. Parameters: *args:STRING
HIGHrembg/sessions/birefnet_cod.py46 Returns the name of the BiRefNet-COD session. Parameters: *args: Additional positional argSTRING
HIGHrembg/commands/p_command.py216 Command-line interface (CLI) program for performing background removal on images in a folder. This program takSTRING
HIGHrembg/commands/i_command.py103 Click command line interface function to process an input file based on the provided options. This function isSTRING
HIGHrembg/commands/b_command.py112 Command-line interface for processing images by removing the background using a specified model and generating a maSTRING
Cross-File Repetition30 hits · 150 pts
SeverityFileLineSnippetContext
HIGHrembg/sessions/u2net_custom.py0download the model files. parameters: *args: additional positional arguments. **kwargs: additional keyword arguments. reSTRING
HIGHrembg/sessions/ben_custom.py0download the model files. parameters: *args: additional positional arguments. **kwargs: additional keyword arguments. reSTRING
HIGHrembg/sessions/dis_custom.py0download the model files. parameters: *args: additional positional arguments. **kwargs: additional keyword arguments. reSTRING
HIGHrembg/sessions/u2net_custom.py0get the name of the model. parameters: *args: additional positional arguments. **kwargs: additional keyword arguments. rSTRING
HIGHrembg/sessions/ben_custom.py0get the name of the model. parameters: *args: additional positional arguments. **kwargs: additional keyword arguments. rSTRING
HIGHrembg/sessions/dis_custom.py0get the name of the model. parameters: *args: additional positional arguments. **kwargs: additional keyword arguments. rSTRING
HIGHrembg/sessions/birefnet_portrait.py0downloads the birefnet-cod model file from a specific url and saves it. parameters: *args: additional positional argumenSTRING
HIGHrembg/sessions/birefnet_general.py0downloads the birefnet-cod model file from a specific url and saves it. parameters: *args: additional positional argumenSTRING
HIGHrembg/sessions/birefnet_general_lite.py0downloads the birefnet-cod model file from a specific url and saves it. parameters: *args: additional positional argumenSTRING
HIGHrembg/sessions/birefnet_hrsod.py0downloads the birefnet-cod model file from a specific url and saves it. parameters: *args: additional positional argumenSTRING
HIGHrembg/sessions/birefnet_massive.py0downloads the birefnet-cod model file from a specific url and saves it. parameters: *args: additional positional argumenSTRING
HIGHrembg/sessions/birefnet_dis.py0downloads the birefnet-cod model file from a specific url and saves it. parameters: *args: additional positional argumenSTRING
HIGHrembg/sessions/u2net.py0downloads the birefnet-cod model file from a specific url and saves it. parameters: *args: additional positional argumenSTRING
HIGHrembg/sessions/bria_rmbg.py0downloads the birefnet-cod model file from a specific url and saves it. parameters: *args: additional positional argumenSTRING
HIGHrembg/sessions/birefnet_cod.py0downloads the birefnet-cod model file from a specific url and saves it. parameters: *args: additional positional argumenSTRING
HIGHrembg/sessions/birefnet_portrait.py0returns the name of the birefnet-cod session. parameters: *args: additional positional arguments. **kwargs: additional kSTRING
HIGHrembg/sessions/birefnet_general.py0returns the name of the birefnet-cod session. parameters: *args: additional positional arguments. **kwargs: additional kSTRING
HIGHrembg/sessions/birefnet_general_lite.py0returns the name of the birefnet-cod session. parameters: *args: additional positional arguments. **kwargs: additional kSTRING
HIGHrembg/sessions/birefnet_hrsod.py0returns the name of the birefnet-cod session. parameters: *args: additional positional arguments. **kwargs: additional kSTRING
HIGHrembg/sessions/birefnet_massive.py0returns the name of the birefnet-cod session. parameters: *args: additional positional arguments. **kwargs: additional kSTRING
HIGHrembg/sessions/birefnet_dis.py0returns the name of the birefnet-cod session. parameters: *args: additional positional arguments. **kwargs: additional kSTRING
HIGHrembg/sessions/u2net.py0returns the name of the birefnet-cod session. parameters: *args: additional positional arguments. **kwargs: additional kSTRING
HIGHrembg/sessions/bria_rmbg.py0returns the name of the birefnet-cod session. parameters: *args: additional positional arguments. **kwargs: additional kSTRING
HIGHrembg/sessions/birefnet_cod.py0returns the name of the birefnet-cod session. parameters: *args: additional positional arguments. **kwargs: additional kSTRING
HIGHrembg/sessions/birefnet_general.py0predicts the output masks for the input image using the inner session. parameters: img (pilimage): the input image. *argSTRING
HIGHrembg/sessions/u2net.py0predicts the output masks for the input image using the inner session. parameters: img (pilimage): the input image. *argSTRING
HIGHrembg/sessions/bria_rmbg.py0predicts the output masks for the input image using the inner session. parameters: img (pilimage): the input image. *argSTRING
HIGHrembg/sessions/ben_custom.py0predicts the mask image for the input image. this method takes a pilimage object as input and returns a list of pilimageSTRING
HIGHrembg/sessions/dis_custom.py0predicts the mask image for the input image. this method takes a pilimage object as input and returns a list of pilimageSTRING
HIGHrembg/sessions/dis_general_use.py0predicts the mask image for the input image. this method takes a pilimage object as input and returns a list of pilimageSTRING
Hyper-Verbose Identifiers44 hits · 56 pts
SeverityFileLineSnippetContext
LOWtests/test_decontaminate.py60def test_decontaminate_removes_background_color_fringing():CODE
LOWtests/test_decontaminate.py79def test_decontaminate_preserves_alpha():CODE
LOWtests/test_decontaminate.py89def test_decontaminate_leaves_opaque_pixels_alone():CODE
LOWtests/test_model_home.py17def test_defaults_to_dot_rembg(clean_env):CODE
LOWtests/test_model_home.py21def test_rembg_home_env_wins_over_default(clean_env):CODE
LOWtests/test_model_home.py26def test_xdg_data_home_has_no_leading_dot(clean_env):CODE
LOWtests/test_model_home.py32def test_legacy_env_still_takes_precedence(clean_env):CODE
LOWtests/test_model_home.py43def test_model_dir_is_per_model(clean_env):CODE
LOWtests/test_model_home.py48def test_resolve_existing_prefers_new_layout(clean_env, tmp_path):CODE
LOWtests/test_model_home.py59def test_resolve_existing_falls_back_to_legacy(clean_env, tmp_path):CODE
LOWtests/test_model_home.py71def test_resolve_existing_returns_none_when_absent(clean_env, tmp_path):CODE
LOWtests/test_model_home.py78def test_validate_model_path_accepts_both_roots(clean_env, tmp_path):CODE
LOWtests/test_model_home.py89def test_validate_model_path_rejects_outside_paths(clean_env, tmp_path):CODE
LOWtests/test_model_home.py96def test_validate_model_path_rejects_traversal(clean_env, tmp_path):CODE
LOWtests/test_model_home.py105def test_validate_model_path_rejects_sibling_prefix(clean_env, tmp_path):CODE
LOWtests/test_model_home.py115def test_validate_model_path_requires_the_argument(clean_env):CODE
LOWtests/test_matting.py13def test_default_variant_is_a_known_one():CODE
LOWtests/test_matting.py17def test_every_variant_declares_a_file_and_checksum():CODE
LOWtests/test_matting.py23def test_resolve_variant_defaults_when_unset():CODE
LOWtests/test_matting.py27def test_resolve_variant_accepts_known_names():CODE
LOWtests/test_matting.py32def test_resolve_variant_rejects_unknown_names():CODE
LOWtests/test_matting.py37def test_resolve_variant_error_lists_the_options():CODE
LOWtests/test_matting.py53def test_trimap_has_only_the_three_expected_levels():CODE
LOWtests/test_matting.py58def test_trimap_marks_an_unknown_band():CODE
LOWtests/test_matting.py63def test_trimap_keeps_the_mask_size():CODE
LOWtests/test_matting.py68def test_larger_erode_size_widens_the_unknown_band():CODE
LOWtests/test_matting.py75def test_trimap_accepts_a_non_grayscale_mask():CODE
LOWtests/test_withoutbg.py18def test_missing_api_key_raises(monkeypatch):CODE
LOWtests/test_withoutbg.py30def test_api_key_kwarg_overrides_env(monkeypatch):CODE
LOWtests/test_withoutbg.py36def test_name_and_download_models():CODE
LOWtests/test_withoutbg.py47def test_predict_rejects_oversized_upload(monkeypatch):CODE
LOWtests/test_withoutbg.py65def test_predict_returns_mask_matching_input_size(monkeypatch):CODE
LOWtests/test_withoutbg.py93def test_predict_http_error_raises(monkeypatch):CODE
LOWtests/test_migrate.py27def test_dry_run_touches_nothing(layout):CODE
LOWtests/test_migrate.py35def test_migrate_copies_into_per_model_dirs(layout):CODE
LOWtests/test_migrate.py48def test_migrate_keeps_originals_by_default(layout):CODE
LOWtests/test_migrate.py55def test_unrecognised_files_are_never_moved(layout):CODE
LOWtests/test_migrate.py62def test_orphans_are_kept_unless_asked(layout):CODE
LOWtests/test_migrate.py67def test_clean_orphans_removes_them(layout):CODE
LOWtests/test_migrate.py72def test_migrate_is_idempotent(layout):CODE
LOWtests/test_migrate.py81def test_second_pass_reclaims_already_migrated_files(layout):CODE
LOWtests/test_migrate.py93def test_mismatched_copy_is_left_alone(layout):CODE
LOWtests/test_migrate.py105def test_missing_legacy_dir_is_not_an_error(monkeypatch, tmp_path):CODE
LOWtests/test_migrate.py116def test_same_source_and_target_is_refused(monkeypatch, tmp_path):CODE
Excessive Try-Catch Wrapping12 hits · 18 pts
SeverityFileLineSnippetContext
MEDIUMrembg/bg.py248 print(f"Error: no model found: {model}")CODE
LOWrembg/bg.py256 except Exception as e:CODE
MEDIUMrembg/bg.py257 print(f"Error downloading model: {e}")CODE
LOWrembg/commands/p_command.py240 except Exception:CODE
LOWrembg/commands/p_command.py272 except Exception as e:CODE
LOWrembg/commands/i_command.py120 except Exception:CODE
LOWrembg/commands/b_command.py131 except Exception:CODE
LOWrembg/commands/s_command.py214 except Exception:CODE
LOWrembg/commands/s_command.py247 except Exception:CODE
LOWrembg/commands/s_command.py272 except Exception:CODE
MEDIUMrembg/commands/s_command.py244def startup():CODE
LOWrembg/commands/m_command.py20 except Exception: # nosec B112 - a session that cannot report its ownCODE
Unused Imports6 hits · 6 pts
SeverityFileLineSnippetContext
LOWrembg/bg.py32CODE
LOWrembg/__init__.py11CODE
LOWrembg/__init__.py12CODE
LOWrembg/sessions/__init__.py1CODE
LOWrembg/sessions/__init__.py3CODE
LOWrembg/commands/b_command.py6CODE
Deep Nesting5 hits · 5 pts
SeverityFileLineSnippetContext
LOWtests/test_remove.py13CODE
LOWrembg/bg.py237CODE
LOWrembg/bg.py260CODE
LOWrembg/sessions/base.py13CODE
LOWrembg/commands/m_command.py60CODE
AI Structural Patterns3 hits · 3 pts
SeverityFileLineSnippetContext
LOWrembg/bg.py260CODE
LOWrembg/commands/s_command.py111CODE
LOWrembg/commands/s_command.py160CODE
Self-Referential Comments1 hit · 1 pts
SeverityFileLineSnippetContext
MEDIUMrembg/sessions/u2netp.py13 """This class represents a session for using the U2netp model."""STRING