{"id":18077338,"url":"https://github.com/parisneo/diffusers-fastapi","last_synced_at":"2026-02-27T11:03:12.727Z","repository":{"id":255350467,"uuid":"849296695","full_name":"ParisNeo/diffusers-fastapi","owner":"ParisNeo","description":"A fast api server for Diffusers","archived":false,"fork":false,"pushed_at":"2024-09-24T13:33:32.000Z","size":44,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-12T09:32:37.205Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","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/ParisNeo.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,"zenodo":null}},"created_at":"2024-08-29T10:45:28.000Z","updated_at":"2024-09-24T13:33:34.000Z","dependencies_parsed_at":"2025-04-12T09:33:02.787Z","dependency_job_id":"7db83a5a-fc4c-4f88-a421-e09a0d62a90b","html_url":"https://github.com/ParisNeo/diffusers-fastapi","commit_stats":null,"previous_names":["parisneo/diffusers-fastapi"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/ParisNeo/diffusers-fastapi","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ParisNeo%2Fdiffusers-fastapi","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ParisNeo%2Fdiffusers-fastapi/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ParisNeo%2Fdiffusers-fastapi/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ParisNeo%2Fdiffusers-fastapi/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ParisNeo","download_url":"https://codeload.github.com/ParisNeo/diffusers-fastapi/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ParisNeo%2Fdiffusers-fastapi/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29892063,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-27T09:48:51.284Z","status":"ssl_error","status_checked_at":"2026-02-27T09:48:43.992Z","response_time":57,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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-10-31T11:24:16.324Z","updated_at":"2026-02-27T11:03:12.681Z","avatar_url":"https://github.com/ParisNeo.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Diffusers FastAPI\n[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)\n[![Python](https://img.shields.io/badge/Python-3.7%2B-blue)](https://www.python.org/downloads/)\n[![FastAPI](https://img.shields.io/badge/FastAPI-0.68%2B-green)](https://fastapi.tiangolo.com/)\n[![Pytorch](https://img.shields.io/badge/PyTorch-1.9%2B-red)](https://pytorch.org/)\n\nDiffusers FastAPI is a robust and versatile FastAPI-based server for image generation, image-to-image transformation, and inpainting using Hugging Face Diffusers. This project provides a powerful API for various image generation and manipulation tasks using state-of-the-art diffusion models.\n\n## Features\n\n- Text-to-image generation\n- Image-to-image transformation\n- Inpainting\n- Support for multiple Stable Diffusion models\n- Automatic package management and updates\n- Configurable output and model caching directories\n- Verbose logging option for debugging\n\n## Installation\n\n1. Clone the repository:\n   ```\n   git clone https://github.com/ParisNeo/diffusers-fastapi.git\n   cd diffusers-fastapi\n   ```\n\n2. Install PyTorch:\n   This application requires PyTorch to be installed, preferably with CUDA support for optimal performance. To install PyTorch with CUDA support, use the following command:\n\n   ```\n   pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118\n   ```\n\n   This command installs PyTorch with CUDA 11.8 support. If you need a different CUDA version or don't have a CUDA-capable GPU, please refer to the [official PyTorch installation guide](https://pytorch.org/get-started/locally/) for alternative installation options.\n\n   Note: The CUDA version (cu118 in this case) should match your system's CUDA installation. Adjust as necessary.\n\n3. Install other dependencies:\n   ```\n   pip install -r requirements.txt\n   ```\n\n## Usage\n\nTo start the Diffusers FastAPI server, run the following command:\n\n```\npython diffusers_fastapi.py [options]\n```\n\n### Options\n\n- `--host`: Host to run the server on (default: 127.0.0.1)\n- `--port`: Port to run the server on (default: 8253)\n- `--model`: Diffusers model to use (default: \"v2ray/stable-diffusion-3-medium-diffusers\")\n- `--output_dir`: Directory to save generated images (default: \"output\")\n- `--models_dir`: Directory to cache models (default: \"models\")\n- `--verbose`: Enable verbose logging\n\nExample:\n```\npython diffusers_fastapi.py --host 0.0.0.0 --port 8253 --model \"stabilityai/stable-diffusion-2-1\" --output_dir \"output\" --models_dir \"models\" --verbose\n```\n\n## API Endpoints\n\nThe server provides the following endpoints:\n\n1. `/generate-image`: Text-to-image generation\n2. `/img2img`: Image-to-image transformation\n3. `/inpaint`: Inpainting\n\nFor detailed information about request and response formats, please refer to the API documentation available at `/docs` when the server is running.\n\n## Python Examples\n\nHere are some examples of how to use the API with Python requests:\n\n### Text-to-Image Generation\n\n```python\nimport requests\nimport json\n\nurl = \"http://localhost:8253/generate-image\"\npayload = {\n    \"positive_prompt\": \"A beautiful landscape with mountains and a lake\",\n    \"negative_prompt\": \"clouds, people\",\n    \"seed\": 42,\n    \"scale\": 7.5,\n    \"steps\": 20,\n    \"width\": 512,\n    \"height\": 512\n}\n\nresponse = requests.post(url, json=payload)\nresult = json.loads(response.text)\nprint(f\"Generated image path: {result['image_path']}\")\n```\n\n### Image-to-Image Transformation\n\n```python\nimport requests\n\nurl = \"http://localhost:8253/img2img\"\nfiles = {\n    'image': ('input.png', open('input.png', 'rb'), 'image/png')\n}\ndata = {\n    'positive_prompt': 'Transform this landscape into a snowy scene',\n    'negative_prompt': 'summer, green',\n    'seed': 42,\n    'scale': 7.5,\n    'steps': 20\n}\n\nresponse = requests.post(url, files=files, data=data)\nresult = response.json()\nprint(f\"Generated image path: {result['image_path']}\")\n```\n\n### Inpainting\n\n```python\nimport requests\n\nurl = \"http://localhost:8253/inpaint\"\nfiles = {\n    'image': ('input.png', open('input.png', 'rb'), 'image/png'),\n    'mask': ('mask.png', open('mask.png', 'rb'), 'image/png')\n}\ndata = {\n    'positive_prompt': 'Add a cat sitting on the couch',\n    'negative_prompt': 'dog, bird',\n    'seed': 42,\n    'scale': 7.5,\n    'steps': 20\n}\n\nresponse = requests.post(url, files=files, data=data)\nresult = response.json()\nprint(f\"Generated image path: {result['image_path']}\")\n```\n\n## API Documentation\n\nFor detailed API documentation, including request and response schemas, please run the server and navigate to `http://localhost:8253/docs` in your web browser. This will open the Swagger UI, which provides interactive documentation for all available endpoints.\n\n## License\n\nThis project is licensed under the Apache 2.0 License.\n\n## Author\n\nParisNeo - A computer geek passionate about AI\n\nGitHub: [https://github.com/ParisNeo](https://github.com/ParisNeo)\n\n## Contributing\n\nContributions are welcome! Please feel free to submit a Pull Request.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fparisneo%2Fdiffusers-fastapi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fparisneo%2Fdiffusers-fastapi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fparisneo%2Fdiffusers-fastapi/lists"}