{"id":20040899,"url":"https://github.com/littlelittlecloud/torchsharp-stable-diffusion-2","last_synced_at":"2025-07-11T08:37:35.756Z","repository":{"id":229716984,"uuid":"777436353","full_name":"LittleLittleCloud/Torchsharp-stable-diffusion-2","owner":"LittleLittleCloud","description":null,"archived":false,"fork":false,"pushed_at":"2024-04-16T23:29:14.000Z","size":1222,"stargazers_count":10,"open_issues_count":1,"forks_count":2,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-03T05:24:30.434Z","etag":null,"topics":["stable-diffusion","torchsharp"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/LittleLittleCloud.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2024-03-25T21:06:42.000Z","updated_at":"2025-01-02T22:57:57.000Z","dependencies_parsed_at":"2024-03-30T02:25:33.238Z","dependency_job_id":"dfdd4a21-dd22-44da-b975-5d256753f973","html_url":"https://github.com/LittleLittleCloud/Torchsharp-stable-diffusion-2","commit_stats":null,"previous_names":["littlelittlecloud/torchsharp-stable-diffusion-2"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/LittleLittleCloud/Torchsharp-stable-diffusion-2","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LittleLittleCloud%2FTorchsharp-stable-diffusion-2","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LittleLittleCloud%2FTorchsharp-stable-diffusion-2/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LittleLittleCloud%2FTorchsharp-stable-diffusion-2/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LittleLittleCloud%2FTorchsharp-stable-diffusion-2/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/LittleLittleCloud","download_url":"https://codeload.github.com/LittleLittleCloud/Torchsharp-stable-diffusion-2/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LittleLittleCloud%2FTorchsharp-stable-diffusion-2/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264766700,"owners_count":23660825,"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":["stable-diffusion","torchsharp"],"created_at":"2024-11-13T10:44:34.040Z","updated_at":"2025-07-11T08:37:35.718Z","avatar_url":"https://github.com/LittleLittleCloud.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"## Torchsharp Stable Diffusion 2\n\nThis repo contains a torchsharp implementation for [stable diffusion 2 model](https://github.com/Stability-AI/stablediffusion).\n\n## Quick Start\nTo run the stable diffusion 2 model on your local machine, the following prerequisites are required:\n- dotnet 6\n- git lfs, this is to download the model file from hugging face\n\n### Step 1: Get the model weight from huggingface\nTo get stable-diffusion-2 model weight, run the following command to download model weight from huggingface. Be sure to have git lfs installed.\n```bash\ngit clone https://huggingface.co/stabilityai/stable-diffusion-2\n```\n\u003e [!Note]\n\u003e To load fp32 model weight into GPU, it's recommended to have at least 16GB of GPU memory if you want to generate 768 * 768 size image. Loading fp16 model weight requires around 8GB of GPU memory.\n\n### Step 2: Run the model\nClone this repo and replace the `modelFolder` folder with where you download huggingface model weight in [Program.cs](./Program.cs#L25)\n\nThen run the following command to start the model:\n```bash\ndotnet run\n```\n\n### Example output\n![a photo of an astronaut riding a horse on mars](./img/a%20photo%20of%20an%20astronaut%20riding%20a%20horse%20on%20mars.png)\n(a photo of an astronaut riding a horse on mars)\n\n### Load fp16 model weight for faster and more GPU memory efficient inference\nYou can load fp16 model weight by setting `dtype` to ` ScalarType.Float16` in [Program.cs](./Program.cs#L4). The inference on fp16 model weight is faster and more GPU memory efficient.\n\n\u003e [!Note]\n\u003e fp16 model only work with GPU because some operators doesn't work with fp16 and cpu.\n\n### Update log\n#### Update on 2024/04/03\n- Add support for loading fp16 model weight\n### See also\n- [Torchsharp-llama](https://github.com/LittleLittleCloud/Torchsharp-llama): A torchsharp implementation for llama 2 model\n- [Torchsharp-phi](https://github.com/LittleLittleCloud/Torchsharp-phi): A torchsharp implementation for phi model\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flittlelittlecloud%2Ftorchsharp-stable-diffusion-2","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flittlelittlecloud%2Ftorchsharp-stable-diffusion-2","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flittlelittlecloud%2Ftorchsharp-stable-diffusion-2/lists"}