{"id":15290452,"url":"https://github.com/artemmavrin/focal-loss","last_synced_at":"2025-10-07T04:30:25.153Z","repository":{"id":50823395,"uuid":"209932885","full_name":"artemmavrin/focal-loss","owner":"artemmavrin","description":"TensorFlow implementation of focal loss","archived":true,"fork":false,"pushed_at":"2021-05-28T19:04:19.000Z","size":181,"stargazers_count":191,"open_issues_count":6,"forks_count":42,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-09-10T11:25:30.099Z","etag":null,"topics":["deep-learning","keras","loss-functions","tensorflow"],"latest_commit_sha":null,"homepage":"https://focal-loss.readthedocs.io","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/artemmavrin.png","metadata":{"files":{"readme":"README.rst","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-09-21T05:54:54.000Z","updated_at":"2025-08-21T11:51:27.000Z","dependencies_parsed_at":"2022-09-12T02:31:39.142Z","dependency_job_id":null,"html_url":"https://github.com/artemmavrin/focal-loss","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/artemmavrin/focal-loss","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/artemmavrin%2Ffocal-loss","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/artemmavrin%2Ffocal-loss/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/artemmavrin%2Ffocal-loss/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/artemmavrin%2Ffocal-loss/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/artemmavrin","download_url":"https://codeload.github.com/artemmavrin/focal-loss/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/artemmavrin%2Ffocal-loss/sbom","scorecard":{"id":209081,"data":{"date":"2025-08-11","repo":{"name":"github.com/artemmavrin/focal-loss","commit":"7a1810a968051b6acfedf2052123eb76ba3128c4"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3.4,"checks":[{"name":"Code-Review","score":0,"reason":"Found 0/30 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Maintained","score":0,"reason":"project is archived","details":["Warn: Repository is archived."],"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/python-package.yml:1","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Pinned-Dependencies","score":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/python-package.yml:14: update your workflow using https://app.stepsecurity.io/secureworkflow/artemmavrin/focal-loss/python-package.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/python-package.yml:16: update your workflow using https://app.stepsecurity.io/secureworkflow/artemmavrin/focal-loss/python-package.yml/master?enable=pin","Warn: pipCommand not pinned by hash: .github/workflows/python-package.yml:27","Info:   0 out of   2 GitHub-owned GitHubAction dependencies pinned","Info:   0 out of   1 pipCommand dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: Apache License 2.0: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 6 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-17T00:23:43.041Z","repository_id":50823395,"created_at":"2025-08-17T00:23:43.041Z","updated_at":"2025-08-17T00:23:43.041Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278722195,"owners_count":26034457,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-07T02:00:06.786Z","response_time":59,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["deep-learning","keras","loss-functions","tensorflow"],"created_at":"2024-09-30T16:08:15.073Z","updated_at":"2025-10-07T04:30:24.836Z","avatar_url":"https://github.com/artemmavrin.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"==========\nFocal Loss\n==========\n\n.. image:: https://img.shields.io/pypi/pyversions/focal-loss\n    :target: https://pypi.org/project/focal-loss\n    :alt: Python Version\n\n.. image:: https://img.shields.io/pypi/v/focal-loss\n    :target: https://pypi.org/project/focal-loss\n    :alt: PyPI Package Version\n\n.. image:: https://img.shields.io/github/last-commit/artemmavrin/focal-loss/master\n    :target: https://github.com/artemmavrin/focal-loss\n    :alt: Last Commit\n\n.. image:: https://github.com/artemmavrin/focal-loss/workflows/Python%20package/badge.svg\n    :target: https://github.com/artemmavrin/focal-loss/actions?query=workflow%3A%22Python+package%22\n    :alt: Build Status\n\n.. image:: https://codecov.io/gh/artemmavrin/focal-loss/branch/master/graph/badge.svg\n    :target: https://codecov.io/gh/artemmavrin/focal-loss\n    :alt: Code Coverage\n\n.. image:: https://readthedocs.org/projects/focal-loss/badge/?version=latest\n    :target: https://focal-loss.readthedocs.io/en/latest/\n    :alt: Documentation Status\n\n.. image:: https://img.shields.io/github/license/artemmavrin/focal-loss\n    :target: https://github.com/artemmavrin/focal-loss/blob/master/LICENSE\n    :alt: License\n\nTensorFlow implementation of focal loss [1]_: a loss function generalizing\nbinary and multiclass cross-entropy loss that penalizes hard-to-classify\nexamples.\n\nThe ``focal_loss`` package provides functions and classes that can be used as\noff-the-shelf replacements for ``tf.keras.losses`` functions and classes,\nrespectively.\n\n.. code-block:: python\n\n    # Typical tf.keras API usage\n    import tensorflow as tf\n    from focal_loss import BinaryFocalLoss\n\n    model = tf.keras.Model(...)\n    model.compile(\n        optimizer=...,\n        loss=BinaryFocalLoss(gamma=2),  # Used here like a tf.keras loss\n        metrics=...,\n    )\n    history = model.fit(...)\n\nThe ``focal_loss`` package includes the functions\n\n* ``binary_focal_loss``\n* ``sparse_categorical_focal_loss``\n\nand wrapper classes\n\n* ``BinaryFocalLoss`` (use like ``tf.keras.losses.BinaryCrossentropy``)\n* ``SparseCategoricalFocalLoss`` (use like ``tf.keras.losses.SparseCategoricalCrossentropy``)\n\nDocumentation is available at\n`Read the Docs \u003chttps://focal-loss.readthedocs.io/en/latest/\u003e`__.\n\n.. image:: docs/source/images/focal-loss.png\n    :alt: Focal loss plot\n\nInstallation\n------------\n\nThe ``focal_loss`` package can be installed using the\n`pip \u003chttps://pip.pypa.io/en/stable/\u003e`__ utility.\nFor the latest version, install directly from the package's\n`GitHub page \u003chttps://github.com/artemmavrin/focal-loss\u003e`__:\n\n.. code-block:: bash\n\n    pip install git+https://github.com/artemmavrin/focal-loss.git\n\nAlternatively, install a recent release from the\n`Python Package Index (PyPI) \u003chttps://pypi.org/project/focal-loss\u003e`__:\n\n.. code-block:: bash\n\n    pip install focal-loss\n\n**Note.** To install the project for development (e.g., to make changes to\nthe source code), clone the project repository from GitHub and run\n:code:`make dev`:\n\n.. code-block:: bash\n\n    git clone https://github.com/artemmavrin/focal-loss.git\n    cd focal-loss\n    # Optional but recommended: create and activate a new environment first\n    make dev\n\nThis will additionally install the requirements needed to run tests, check code\ncoverage, and produce documentation.\n\nReferences\n----------\n\n.. [1] T. Lin, P. Goyal, R. Girshick, K. He and P. Dollár. Focal loss for dense\n    object detection. IEEE Transactions on Pattern Analysis and Machine\n    Intelligence, 2018. (`DOI \u003chttps://doi.org/10.1109/TPAMI.2018.2858826\u003e`__)\n    (`arXiv preprint \u003chttps://arxiv.org/abs/1708.02002\u003e`__)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fartemmavrin%2Ffocal-loss","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fartemmavrin%2Ffocal-loss","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fartemmavrin%2Ffocal-loss/lists"}