{"id":18785269,"url":"https://github.com/andreped/t-loss-tf","last_synced_at":"2026-05-06T08:36:03.596Z","repository":{"id":188214934,"uuid":"678296570","full_name":"andreped/t-loss-tf","owner":"andreped","description":"Robust T-Loss for Medical Image Segmentation with TensorFlow backend","archived":false,"fork":false,"pushed_at":"2023-09-10T16:19:03.000Z","size":20885,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-02-17T17:52:24.334Z","etag":null,"topics":["image-analysis","keras","medical","python","semantic-segmentation","t-loss","tensorflow","tf","tloss"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/andreped.png","metadata":{"files":{"readme":"README.md","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,"governance":null}},"created_at":"2023-08-14T08:15:08.000Z","updated_at":"2023-09-02T15:18:34.000Z","dependencies_parsed_at":null,"dependency_job_id":"8a85516f-818b-4890-8307-7d78542893b0","html_url":"https://github.com/andreped/t-loss-tf","commit_stats":{"total_commits":23,"total_committers":1,"mean_commits":23.0,"dds":0.0,"last_synced_commit":"6c2242d2ed56d713b441fa97a814645149f4ba57"},"previous_names":["andreped/t-loss-tf"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andreped%2Ft-loss-tf","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andreped%2Ft-loss-tf/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andreped%2Ft-loss-tf/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andreped%2Ft-loss-tf/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/andreped","download_url":"https://codeload.github.com/andreped/t-loss-tf/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239701142,"owners_count":19682861,"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","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":["image-analysis","keras","medical","python","semantic-segmentation","t-loss","tensorflow","tf","tloss"],"created_at":"2024-11-07T20:46:06.301Z","updated_at":"2025-12-21T17:30:19.514Z","avatar_url":"https://github.com/andreped.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n\u003cimg src=\"./assets/tloss.gif\" width=\"320\"\u003e\n\u003ch1 align=\"center\"\u003et-loss-tf\u003c/h1\u003e\n\u003ch3 align=\"center\"\u003eRobust T-Loss for Medical Image Segmentation with TensorFlow backend\u003c/h3\u003e\n\n[![GitHub Downloads](https://img.shields.io/github/downloads/andreped/t-loss-tf/total?label=GitHub%20downloads\u0026logo=github)](https://github.com/andreped/t-loss-tf/releases)\n[![License](https://img.shields.io/badge/License-MIT-green.svg)](https://opensource.org/licenses/MIT)\n[![CI](https://github.com/andreped/t-loss-tf/workflows/tests/badge.svg)](https://github.com/andreped/t-loss-tf/actions)\n\u003ca href=\"https://github.com/psf/black\"\u003e\u003cimg alt=\"Code style: black\" src=\"https://img.shields.io/badge/code%20style-black-000000.svg\"\u003e\u003c/a\u003e\n\n\u003c/div\u003e\n\nThis T-loss implementation is an adaption of the original PyTorch code [Digital-Dermatology/t-loss-loss](https://github.com/Digital-Dermatology/t-loss).\n\nMore information about T-loss and the original paper can be found [here](https://robust-tloss.github.io/).\n\n## [Installation](https://github.com/andreped/t-loss-tf#installation)\n```\npip install git+https://github.com/andreped/t-loss-tf.git\n```\n\n## [Usage](https://github.com/andreped/t-loss-tf#usage)\nAs the t-loss contains a trainable parameter, in keras the loss needed to be implemented as a custom layer.\nHence, instead of setting the loss as normally through `model.compile(loss=[...])`, just add it to the model\nat an appropriate place (e.g., at the end of the network).\n\nAn example can be seen below:\n\n```python\nimport tensorflow as tf\nfrom t_loss import TLoss\n\n# create dummy inputs and GTs\ninput_shape = (16, 16, 1)\nx = tf.ones((32,) + input_shape, dtype=\"float32\")\ny = tf.ones((32,) + input_shape, dtype=\"float32\")\n\n# define network\ninput_x = tf.keras.Input(shape=input_shape)\ninput_y = tf.keras.Input(shape=input_shape)\nz = tf.keras.layers.Conv2D(filters=4, kernel_size=(1, 1), activation=\"relu\")(input_x)\nz = tf.keras.layers.MaxPooling2D(pool_size=(2, 2))(z)\nz = tf.keras.layers.UpSampling2D(size=(2, 2))(z)\nz = tf.keras.layers.Conv2D(filters=1, kernel_size=(1, 1), activation=\"sigmoid\")(z)\nz = TLoss(tensor_shape=input_shape, image_size=input_shape[0])(z, input_y)\nmodel = tf.keras.Model(inputs=[input_x, input_y], outputs=[z])\n\n# train model\nmodel.compile(optimizer=\"adam\")\nmodel.fit(x=[x, y], y=y, batch_size=2, epochs=1, verbose=\"auto\")\n```\n\n## [License](https://github.com/andreped/t-loss-tf#license)\nThe code in this repository is released under [MIT License](https://github.com/andreped/t-loss-tf/blob/main/LICENSE).\n\n## [Citation](https://github.com/andreped/t-loss-tf#citation)\nThe implementation is based on the original torch implementation hosted [here](https://github.com/Digital-Dermatology/t-loss).\n\nHence, if this code is used, please cite the original research article:\n```\n@inproceedings{gonzalezjimenezRobustTLoss2023,\n  title     = {Robust T-Loss for Medical Image Segmentation},\n  author    = {Gonzalez-Jimenez, Alvaro and Lionetti, Simone and Gottfrois, Philippe and Gröger, Fabian and Pouly, Marc and Navarini, Alexander},\n  journal   = {Medical {{Image Computing}} and {{Computer Assisted Intervention}} – {{MICCAI}} 2023},\n  publisher = {{Springer International Publishing}},\n  year      = {2023},\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandreped%2Ft-loss-tf","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fandreped%2Ft-loss-tf","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandreped%2Ft-loss-tf/lists"}