{"id":20038511,"url":"https://github.com/yahoo/photo-background-generation","last_synced_at":"2025-05-05T06:32:15.164Z","repository":{"id":234260291,"uuid":"782577126","full_name":"yahoo/photo-background-generation","owner":"yahoo","description":null,"archived":false,"fork":false,"pushed_at":"2024-05-05T18:58:56.000Z","size":2763,"stargazers_count":61,"open_issues_count":5,"forks_count":6,"subscribers_count":9,"default_branch":"master","last_synced_at":"2025-04-08T18:51:25.415Z","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":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/yahoo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"Code_of_Conduct.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-04-05T15:22:40.000Z","updated_at":"2025-03-14T05:22:35.000Z","dependencies_parsed_at":"2024-11-13T10:40:26.548Z","dependency_job_id":null,"html_url":"https://github.com/yahoo/photo-background-generation","commit_stats":null,"previous_names":["yahoo/photo-background-generation"],"tags_count":1,"template":false,"template_full_name":"yahoo/.github","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yahoo%2Fphoto-background-generation","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yahoo%2Fphoto-background-generation/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yahoo%2Fphoto-background-generation/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yahoo%2Fphoto-background-generation/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yahoo","download_url":"https://codeload.github.com/yahoo/photo-background-generation/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252451768,"owners_count":21749977,"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-13T10:29:37.975Z","updated_at":"2025-05-05T06:32:14.210Z","avatar_url":"https://github.com/yahoo.png","language":"Jupyter Notebook","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Salient Object Aware Background Generation [![Paper](assets/arxiv.svg)](https://arxiv.org/pdf/2404.10157.pdf) [![Model](assets/huggingface.svg)](https://huggingface.co/yahoo-inc/photo-background-generation)\nThis repository accompanies our paper, [Salient Object-Aware Background Generation using Text-Guided Diffusion Models](https://arxiv.org/abs/2404.10157), which has been accepted for publication in [CVPR 2024 Generative Models for Computer Vision](https://generative-vision.github.io/workshop-CVPR-24/) workshop. You can try our model on [Huggingface](https://huggingface.co/yahoo-inc/photo-background-generation).\n\nThe paper addresses an issue we call \"object expansion\" when generating backgrounds for salient objects using inpainting diffusion models. We show that models such as [Stable Inpainting](https://huggingface.co/stabilityai/stable-diffusion-2-inpainting) can sometimes arbitrarily expand or distort the salient object, which is undesirable in applications where the object's identity should be preserved, such as e-commerce ads. Some examples of object expansion:\n\n\u003cdiv align=\"center\"\u003e\n  \u003cimg src=\"assets/fig.jpg\"\u003e\n\u003c/div\u003e\n\n\n\n## Setup\n\nThe dependencies are provided in `requirements.txt`, install them by:\n\n```bash\npip install -r requirements.txt\n```\n\n## Usage\n### Training\n\nThe following runs the training of text-to-image inpainting ControlNet initialized with the weights of \"stable-diffusion-2-inpainting\":\n```bash\naccelerate launch --multi_gpu --mixed_precision=fp16 --num_processes=8 train_controlnet_inpaint.py --pretrained_model_name_or_path \"stable-diffusion-2-inpainting\" --proportion_empty_prompts 0.1\n```\n\nThe following runs the training of text-to-image ControlNet initialized with the weights of \"stable-diffusion-2-base\":\n```bash\naccelerate launch --multi_gpu --mixed_precision=fp16 --num_processes=8 train_controlnet.py --pretrained_model_name_or_path \"stable-diffusion-2-base\" --proportion_empty_prompts 0.1\n```\n\n### Inference\n\nPlease refer to `inference.ipynb`. Tu run the code you need to download our model checkpoints. You can also try our model using Huggingface pipeline:\n\n```\nfrom diffusers import DiffusionPipeline\npipeline = DiffusionPipeline.from_pretrained(\"yahoo-inc/photo-background-generation\")\n```\n\n## Models Checkpoints\n\n| Model link                                       | Datasets used                                                                                                                                                                                      |\n|--------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| [controlnet_inpainting_salient_aware.pth](https://drive.google.com/file/d/1ad4CNJqFI_HnXFFRqcS4mOD0Le2Mvd3L/view?usp=sharing)     | Salient segmentation datasets, COCO |\n\n## Citations\n\nIf you found our work useful, please consider citing our paper:\n\n```bibtex\n@misc{eshratifar2024salient,\n      title={Salient Object-Aware Background Generation using Text-Guided Diffusion Models}, \n      author={Amir Erfan Eshratifar and Joao V. B. Soares and Kapil Thadani and Shaunak Mishra and Mikhail Kuznetsov and Yueh-Ning Ku and Paloma de Juan},\n      year={2024},\n      eprint={2404.10157},\n      archivePrefix={arXiv},\n      primaryClass={cs.CV}\n}\n```\n\n## Maintainers\n\n- Erfan Eshratifar: erfan.eshratifar@yahooinc.com\n- Joao Soares: jvbsoares@yahooinc.com\n\n## License\n\nThis project is licensed under the terms of the [Apache 2.0](LICENSE) open source license. Please refer to [LICENSE](LICENSE) for the full terms.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyahoo%2Fphoto-background-generation","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyahoo%2Fphoto-background-generation","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyahoo%2Fphoto-background-generation/lists"}