{"id":15469327,"url":"https://github.com/shyamsn97/stable-diffusion-server","last_synced_at":"2025-06-24T23:35:10.144Z","repository":{"id":62864078,"uuid":"563029641","full_name":"shyamsn97/stable-diffusion-server","owner":"shyamsn97","description":"Stable Diffusion colab server built with fastapi","archived":false,"fork":false,"pushed_at":"2023-01-13T22:58:20.000Z","size":1708,"stargazers_count":7,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-23T12:49:48.701Z","etag":null,"topics":["fastapi","stable-diffusion"],"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/shyamsn97.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":"2022-11-07T19:04:05.000Z","updated_at":"2023-07-20T11:10:17.000Z","dependencies_parsed_at":"2023-02-09T17:31:37.823Z","dependency_job_id":null,"html_url":"https://github.com/shyamsn97/stable-diffusion-server","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/shyamsn97/stable-diffusion-server","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shyamsn97%2Fstable-diffusion-server","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shyamsn97%2Fstable-diffusion-server/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shyamsn97%2Fstable-diffusion-server/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shyamsn97%2Fstable-diffusion-server/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/shyamsn97","download_url":"https://codeload.github.com/shyamsn97/stable-diffusion-server/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shyamsn97%2Fstable-diffusion-server/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261776268,"owners_count":23208080,"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":["fastapi","stable-diffusion"],"created_at":"2024-10-02T01:59:34.222Z","updated_at":"2025-06-24T23:35:10.110Z","avatar_url":"https://github.com/shyamsn97.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Stable Diffusion Google Colab FastAPI Server\n\n[![PyPI version](https://badge.fury.io/py/sd-server.svg)](https://badge.fury.io/py/sd-server)\n\n## Note: This is a pretty hacky server / client interface for generic Stable Diffusion pipelines using diffusers. It's not made for production use and hasn't really been optimized completely.\n\n#### Installation\n\nFrom pip:\n\n```bash\npip install sd-server\n```\n\nFrom source:\n\n```bash\ngit clone git@github.com:shyamsn97/stable-diffusion-server.git\ncd stable-diffusion-server/\npython setup.py install\n```\n\n### Stable Diffusion Server + Client Interface -- Simple Usage\n\nHere we create a simple server hosting the standard `StableDiffusionPipeline` from the amazing package [`diffusers`](https://github.com/huggingface/diffusers). The client takes in `**kwargs` that should be the arguments passed into the `__call__` function from the pipeline. For instance, the `StableDiffusionPipeline` `__call__` method can be found: https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion.py#L185. `host` and `port` can be specified in the `start` method for generic hosting.\n\n\n```python\nfrom sd_server import DiffusersServer, DiffusersClient\nfrom diffusers import StableDiffusionPipeline\n\nSTABLE_DIFFUSION_PATH = \"runwayml/stable-diffusion-v1-5\" # this can be a local path\npipeline_kwargs = {\n    \"revision\":\"fp16\",\n    \"torch_dtype\":torch.float16\n}\ndevice = torch.device('cuda')\n\nserver = DiffusersServer.create(\n    pretrained_path = STABLE_DIFFUSION_PATH,\n    pipeline_cls = StableDiffusionPipeline,\n    pipeline_kwargs = pipeline_kwargs,\n    enable_attention_slicing = True,\n    device = device\n)\nurl = server.start(host=\"127.0.0.1\", port=8000) # url -- either remote or local\n\n# on another host / terminal\nclient = DiffusersClient(url)\n\nresponses = client(prompt='a photo of an astronaut riding a horse on mars', num_images_per_prompt=4) # this should return a list of images\n\n```\n\n### Serving from Google Colab\n\nFull google colab example: [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/drive/13B7EzuDTAsjd0hpUki_ZiqoQ4wgOyZUM?usp=sharing)\n\nUsing the server in Google Colab requires an [ngrok](https://ngrok.com/) account, and needs your ngrok auth token https://dashboard.ngrok.com/get-started/your-authtoken to be passed to the server. Note: Ngrok basically opens a tunnel from a dev machine to the cloud, which means its not really that secure, and should be used at your own risk. Read more here: https://stackoverflow.com/questions/36552950/is-ngrok-safe-to-use-or-can-it-be-compromised.\n\n\n```python\nNGROK_AUTH_KEY = \"your auth key from https://dashboard.ngrok.com/get-started/your-authtoken\"\n\n... # imports from above\n\nserver = DiffusersServer.create(\n    pretrained_path = STABLE_DIFFUSION_PATH,\n    pipeline_cls = StableDiffusionPipeline,\n    pipeline_kwargs = pipeline_kwargs,\n    enable_attention_slicing = True,\n    device = device\n)\n\nurl = server.start(ngrok_auth_token=NGROK_AUTH_KEY)\n\n# on another host\nclient = DiffusersClient(url)\n\nresponses = client(prompt='a photo of an astronaut riding a horse on mars', num_images_per_prompt=4) # this should return a list of images\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshyamsn97%2Fstable-diffusion-server","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fshyamsn97%2Fstable-diffusion-server","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshyamsn97%2Fstable-diffusion-server/lists"}