{"id":19603900,"url":"https://github.com/divelab/noise2same","last_synced_at":"2025-04-27T19:32:27.995Z","repository":{"id":55862591,"uuid":"306236447","full_name":"divelab/Noise2Same","owner":"divelab","description":null,"archived":false,"fork":false,"pushed_at":"2021-02-21T03:06:27.000Z","size":14013,"stargazers_count":63,"open_issues_count":2,"forks_count":15,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-04-05T02:21:44.126Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Jupyter Notebook","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/divelab.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}},"created_at":"2020-10-22T05:53:29.000Z","updated_at":"2024-06-18T12:09:01.000Z","dependencies_parsed_at":"2022-08-15T08:00:49.139Z","dependency_job_id":null,"html_url":"https://github.com/divelab/Noise2Same","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/divelab%2FNoise2Same","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/divelab%2FNoise2Same/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/divelab%2FNoise2Same/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/divelab%2FNoise2Same/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/divelab","download_url":"https://codeload.github.com/divelab/Noise2Same/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251195920,"owners_count":21550870,"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":[],"created_at":"2024-11-11T09:33:33.378Z","updated_at":"2025-04-27T19:32:27.475Z","avatar_url":"https://github.com/divelab.png","language":"Jupyter Notebook","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Noise2Same\nOfficial TensorFlow implementation for the [paper](https://arxiv.org/abs/2010.11971) presented on NeurIPS 2020 titled\n\"*Noise2Same: Optimizing A Self-Supervised Bound for Image Denoising*\".\n\n\u003cimg src=\"./figures/cover.jpg\" width=\"80%\"\u003e \n\u003cimg src=\"./figures/visual.jpg\" width=\"80%\"\u003e \n\n## Environment Requirements\n- jupyter\n- python == 3.7.2\n- tensorflow \u003e=1.10 \u0026 \u003c=1.15\n- scipy\n- skimage\n- tifffile\n\n## Usage\n\n### To reproduce our results\n\n#### Dataset and model checkpoint download\nWe uploaded the datasets used in our experiments and the model checkpoint files to the google drive [here](https://drive.google.com/drive/folders/1VYMo1OoaGxoOLNx6-qIt2Wg03lsZw_kA?usp=sharing). You can download the files and put them in the folders ``Denoising_data`` and ``trained_models``. More details about the dataset construction and the source of data can be found under [Denoising_data](./Denoising_data).\n\nWe have provided four examples in Jupyter Notebook that can reproduce our results in the paper. Once you have downloaded the dataset (and the pretrained chechpoints if you want to skip training), you can simply go through the notebooks for reproduction.\n\n### To train, evaluate and predict with your own datasets\nYou can follow the examples in Jupyter Notebook for denoising with RGB images, grayscale images and 3D images.\n\n#### To be specific, the following code is used to build the model.\n```\nfrom models import Noise2Same\nmodel = Noise2Same(model_dir, model_name, dimension, in_channels)\n```\nwhere ``model_dir`` and ``model_name`` will specify the path to your checkpoint files, ``dimension`` refers to the dimension of image *(2 or 3)* and ``in_channels`` refers to the number of channels of input images.\n\n#### The following code is used for **training**.\n```\nmodel.train(X, patch_size, validation=X_val, batch_size, steps)\n```\nwhere ``X`` and ``X_val`` are the noisy images for training/validation of shape ``[n_samples, width, length, n_channels]`` and of type ``float32``, ``patch_size`` specify the size to crop input images to training patches. Note that the input image should be **normalized** before input for training.\n\n#### The following codes are for **prediction**.\n\n- For prediction of single image,\n  ```\n  model.predict(img[, im_mean, im_std])\n  ```\n  where ``img`` is the noisy image for prediction, ``im_mean`` and ``im_std`` are the mean and standard deviation. If ``im_mean`` and ``im_std`` are not specified, it will use ``img.mean()`` and ``img.std()`` by default.\n\n- For prediction of batched images (and you have enough GPU memory),\n  ```\n  model.batch_predict(images.astype('float32'), batch_size[, im_mean, im_std])\n  ```\n\n- For extremely large images, e.g. CARE 3D images,\n  ```\n  model.crop_predict(image, crop_size, overlap[, im_mean, im_std])\n  ```\n\n### Use Noise2Same under other frameworks\nYou can follow the pseudocode below to build the Noise2Same model.\n\nGiven the noisy images ``images``, the masked noisy images ``masked_images`` and masking map ``mask`` with masked locations being 1 and other 0,\n\n```\nnet = YourNetwork()\n# The two net() below should share their weights\nout_raw = net(images)\nout_masked = net(masked_images) \n\nl_rec = reduce_mean((out_raw - images)^2)\nl_inv = reduce_sum((out_raw - out_masked)^2 * mask) / reduce_sum(mask)\nloss = l_rec + 2 * sqrt(l_inv)\n```\n\n## Reference\n```\n@inproceedings{xie2020noise2same,\n author = {Xie, Yaochen and Wang, Zhengyang and Ji, Shuiwang},\n title = {Noise2{S}ame: Optimizing A Self-Supervised Bound for Image Denoising},\n booktitle = {Advances in Neural Information Processing Systems},\n pages = {20320--20330},\n volume = {33},\n year = {2020}\n}\n```\n\n## Web Demo\nYou can create a web-based demo to run inference by running the `demo.py` file, which uses the `gradio` Python library.\n\nHere is a live demo: https://gradio.app/g/Noise2Same\n\nThe live demo uses the model pre-trained on 20,000 noisy images generated from ImageNet ILSVRC2012 validation dataset.\n\n![](https://media4.giphy.com/media/UChzximhl0mGcFVNDp/giphy.gif)\n\nWe thank [Abubakar Abid](https://github.com/abidlabs) for building this awesome web demo for us!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdivelab%2Fnoise2same","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdivelab%2Fnoise2same","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdivelab%2Fnoise2same/lists"}