{"id":13958441,"url":"https://github.com/divamgupta/stable-diffusion-tensorflow","last_synced_at":"2025-05-12T15:54:49.941Z","repository":{"id":59594401,"uuid":"536867444","full_name":"divamgupta/stable-diffusion-tensorflow","owner":"divamgupta","description":"Stable Diffusion in TensorFlow / Keras","archived":false,"fork":false,"pushed_at":"2023-08-08T13:25:03.000Z","size":2126,"stargazers_count":1586,"open_issues_count":33,"forks_count":228,"subscribers_count":25,"default_branch":"master","last_synced_at":"2024-11-28T02:34:43.449Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/divamgupta.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,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-09-15T04:46:25.000Z","updated_at":"2024-11-23T18:39:19.000Z","dependencies_parsed_at":"2024-11-28T02:32:18.598Z","dependency_job_id":"a02abd2b-c7fa-41c1-a55d-17b9cc0fa4d7","html_url":"https://github.com/divamgupta/stable-diffusion-tensorflow","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/divamgupta%2Fstable-diffusion-tensorflow","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/divamgupta%2Fstable-diffusion-tensorflow/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/divamgupta%2Fstable-diffusion-tensorflow/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/divamgupta%2Fstable-diffusion-tensorflow/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/divamgupta","download_url":"https://codeload.github.com/divamgupta/stable-diffusion-tensorflow/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253770422,"owners_count":21961769,"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-08-08T13:01:35.648Z","updated_at":"2025-05-12T15:54:49.914Z","avatar_url":"https://github.com/divamgupta.png","language":"Python","funding_links":[],"categories":["其他_机器视觉"],"sub_categories":["网络服务_其他"],"readme":"# Stable Diffusion in TensorFlow / Keras\n\nA Keras / Tensorflow implementation of Stable Diffusion. \n\nThe weights were ported from the original implementation.\n\n## Colab Notebooks\n\nThe easiest way to try it out is to use one of the Colab notebooks:\n\n\n- [GPU Colab](https://colab.research.google.com/drive/1zVTa4mLeM_w44WaFwl7utTaa6JcaH1zK)\n- [GPU Colab Img2Img](https://colab.research.google.com/drive/1gol0M611zXP6Zpggfri-fG8JDdpMEpsI?usp=sharing)\n- [GPU Colab Inpainting](https://colab.research.google.com/drive/1Bf-bNmAdtQhPcYNyC-guu0uTu9MYYfLu)\n- [GPU Colab - Tile / Texture generation](https://colab.research.google.com/drive/1xCxsNvQMEywzlqbjH4tGfEyXamSAeFbn?usp=sharing)\n- [GPU Colab - Loading Pytorch ckpt Weights](https://colab.research.google.com/drive/1wUdqxji-jxkThYf0OVW3F-0VVpTFdjMa?usp=sharing)\n- [GPU Colab + Mixed Precision](https://colab.research.google.com/drive/15mQgITh3e9HQMNys0zR8JN4R2vp06d-N)\n  - ~10s generation time per image (512x512) on default Colab GPU without drop in quality\n    ([source](https://twitter.com/fchollet/status/1571954014845308928))\n- [TPU Colab](https://colab.research.google.com/drive/17zQOm_2Iu6pcP8otT-v6rx0D-pKgfaLm).\n  - Slower than GPU for single-image generation, faster for large batch of 8+ images\n    ([source](https://twitter.com/fchollet/status/1572004717362028546)).\n- [GPU Colab with Gradio](https://colab.research.google.com/drive/1ANTUur1MF9DKNd5-BTWhbWa7xUBfCWyI)\n- [GPU Colab - Video Generation](https://colab.research.google.com/drive/1aUkXK4zE61iswyYBpUosz730bniNKqk_)\n\n\n\n## Installation\n\n### Install as a python package\n\nInstall using pip with the git repo:\n\n```bash\npip install git+https://github.com/divamgupta/stable-diffusion-tensorflow\n```\n\n### Installing using the repo\n\nDownload the repo, either by downloading the\n[zip](https://github.com/divamgupta/stable-diffusion-tensorflow/archive/refs/heads/master.zip)\nfile or by cloning the repo with git:\n\n```bash\ngit clone git@github.com:divamgupta/stable-diffusion-tensorflow.git\n```\n\n#### Using pip without a virtual environment\n\nInstall dependencies using the `requirements.txt` file or the `requirements_m1.txt` file,:\n\n```bash\npip install -r requirements.txt\n```\n\n#### Using a virtual environment with *virtualenv*\n\n1) Create your virtual environment for `python3`:\n\n    ```bash\n    python3 -m venv venv\n    ```\n   \n2) Activate your virtualenv:\n\n    ```bash\n    source venv/bin/activate\n    ```\n\n3) Install dependencies using the `requirements.txt` file or the `requirements_m1.txt` file,:\n\n    ```bash\n    pip install -r requirements.txt\n    ```\n\n## Usage\n\n### Using the Python interface\n\nIf you installed the package, you can use it as follows:\n\n```python\nfrom stable_diffusion_tf.stable_diffusion import StableDiffusion\nfrom PIL import Image\n\ngenerator = StableDiffusion(\n    img_height=512,\n    img_width=512,\n    jit_compile=False,\n)\nimg = generator.generate(\n    \"An astronaut riding a horse\",\n    num_steps=50,\n    unconditional_guidance_scale=7.5,\n    temperature=1,\n    batch_size=1,\n)\n\n# for image to image :\nimg = generator.generate(\n    \"A Halloween bedroom\",\n    num_steps=50,\n    unconditional_guidance_scale=7.5,\n    temperature=1,\n    batch_size=1,\n    input_image=\"/path/to/img.png\"\n)\n\n\nImage.fromarray(img[0]).save(\"output.png\")\n```\n\n### Using `text2image.py` from the git repo\n\nAssuming you have installed the required packages, \nyou can generate images from a text prompt using:\n\n```bash\npython text2image.py --prompt=\"An astronaut riding a horse\"\n```\n\nThe generated image will be named `output.png` on the root of the repo.\nIf you want to use a different name, use the `--output` flag.\n\n```bash\npython text2image.py --prompt=\"An astronaut riding a horse\" --output=\"my_image.png\"\n```\n\nCheck out the `text2image.py` file for more options, including image size, number of steps, etc.  \n### Using `img2img.py` from the git repo\n\nAssuming you have installed the required packages, \nyou can modify images from a text prompt using:\n\n```bash\npython img2img.py --prompt=\"a high quality sketch of people standing with sun and grass , watercolor , pencil color\" --input=\"img.jpeg\"\n```\n\nThe generated image will be named `img2img-out.jpeg` by default on the root of the repo.\nIf you want to use a different name, use the `--output` flag.  \n\nCheck out the `img2img.py` file for more options, including the number of steps.\n\n## Example outputs \n\nThe following outputs have been generated using this implementation:\n\n1) *A epic and beautiful rococo werewolf drinking coffee, in a burning coffee shop. ultra-detailed. anime, pixiv, uhd 8k cryengine, octane render*\n\n![a](https://user-images.githubusercontent.com/1890549/190841598-3d0b9bd1-d679-4c8d-bd5e-b1e24397b5c8.png)\n\n\n2) *Spider-Gwen Gwen-Stacy Skyscraper Pink White Pink-White Spiderman Photo-realistic 4K*\n\n![a](https://user-images.githubusercontent.com/1890549/190841999-689c9c38-ece4-46a0-ad85-f459ec64c5b8.png)\n\n\n3) *A vision of paradise, Unreal Engine*\n\n![a](https://user-images.githubusercontent.com/1890549/190841886-239406ea-72cb-4570-8f4c-fcd074a7ad7f.png)\n\n### Inpainting\n\n![a](https://user-images.githubusercontent.com/44222184/194685370-e87970f7-dbf5-4d6d-a9d1-31594cdf751a.png)\n\n### Image2Image\n\n1) *a high quality sketch of people standing with sun and grass , watercolor , pencil color*\n\u003cimg width=\"884\" alt=\"Screen Shot 2022-10-09 at 9 34 30 AM\" src=\"https://user-images.githubusercontent.com/1890549/194768637-f586772d-aef5-4d64-8dd5-f7f4962924e1.png\"\u003e\n\n### Keras Stable Diffusion Video Generation\n\n1) *A beautiful street view of prague, artstation concept art, extremely detailed oil painting, vivid colors*\n\nhttps://user-images.githubusercontent.com/63783894/201447745-6a3a96f4-f065-4e54-be5d-01941475a31c.mp4\n\n\n## References\n\n1) https://github.com/CompVis/stable-diffusion\n2) https://github.com/geohot/tinygrad/blob/master/examples/stable_diffusion.py\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdivamgupta%2Fstable-diffusion-tensorflow","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdivamgupta%2Fstable-diffusion-tensorflow","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdivamgupta%2Fstable-diffusion-tensorflow/lists"}