{"id":29092402,"url":"https://github.com/parisneo/openimagegen","last_synced_at":"2025-06-28T07:06:44.160Z","repository":{"id":284982200,"uuid":"956659422","full_name":"ParisNeo/OpenImageGen","owner":"ParisNeo","description":"An open source image generation service","archived":false,"fork":false,"pushed_at":"2025-03-28T17:57:28.000Z","size":2,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-28T18:48:49.322Z","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":null,"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":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":"2025-03-28T16:24:25.000Z","updated_at":"2025-03-28T17:57:31.000Z","dependencies_parsed_at":"2025-03-28T18:48:55.618Z","dependency_job_id":null,"html_url":"https://github.com/ParisNeo/OpenImageGen","commit_stats":null,"previous_names":["parisneo/openimagegen"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/ParisNeo/OpenImageGen","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ParisNeo%2FOpenImageGen","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ParisNeo%2FOpenImageGen/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ParisNeo%2FOpenImageGen/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ParisNeo%2FOpenImageGen/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ParisNeo","download_url":"https://codeload.github.com/ParisNeo/OpenImageGen/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ParisNeo%2FOpenImageGen/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262389486,"owners_count":23303343,"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":"2025-06-28T07:06:42.342Z","updated_at":"2025-06-28T07:06:44.154Z","avatar_url":"https://github.com/ParisNeo.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# OpenImageGen\n\n\u003cdiv align=\"center\"\u003e\n  \u003c!-- Add a relevant logo/icon later --\u003e\n  \u003c!-- \u003cimg src=\"https://github.com/ParisNeo/OpenImageGen/blob/main/assets/icon.png\" alt=\"Logo\" width=\"200\" height=\"200\"\u003e --\u003e\n  \u003cp\u003e🎨\u003c/p\u003e\n\u003c/div\u003e\n\n[![License](https://img.shields.io/github/license/ParisNeo/OpenImageGen)](https://github.com/ParisNeo/OpenImageGen/blob/main/LICENSE) \u003c!-- Update URL --\u003e\n[![Python 3.11+](https://img.shields.io/badge/python-3.11+-blue.svg)](https://www.python.org/downloads/release/python-311/)\n\u003c!-- Add other badges as needed --\u003e\n\nOpen source image generation API using various diffusion models via the `diffusers` library.\n\n## Features\n\n- 🎨 Generate images from text prompts using state-of-the-art diffusion models.\n- 🔄 Support for multiple models (Stable Diffusion, SDXL, Kandinsky, etc.).\n- ⚙️ Configurable via `config.toml` with flexible search paths.\n- 🚀 FastAPI-based RESTful API with asynchronous job processing.\n- 📊 Job status checking and image downloading.\n- 🧹 Automatic file purging after a configurable time.\n- 🔧 Control over GPU usage, data type, and generation parameters.\n- 📝 Logging for debugging and monitoring.\n- 📦 Easy installation via pip.\n- 🐧 Ubuntu systemd service support (example provided).\n- 🐳 Docker integration (example provided).\n\n## Installation\n\n### Prerequisites\n\n- Python 3.11 or higher\n- CUDA-enabled GPU (highly recommended for performance)\n- Git (for installing from source)\n\n### Install via pip (Once published)\n\n```bash\n# pip install openimagegen # (Coming soon)\n```\n\n### Install from source\n\nClone the repository:\n\n```bash\ngit clone https://github.com/ParisNeo/OpenImageGen.git # Update URL\ncd OpenImageGen\n```\n\nInstall dependencies (preferably in a virtual environment):\n\n```bash\npython -m venv venv\nsource venv/bin/activate  # On Windows use `venv\\Scripts\\activate`\npip install -r requirements.txt\npip install . # Installs OpenImageGen itself\n```\n\n## Usage\n\n### Run the API\n\nUse the command-line interface:\n\n```bash\nopenimagegen --host 0.0.0.0 --port 8089\n```\n\nOr directly with Uvicorn:\n\n```bash\nuvicorn openimagegen.main:app --host 0.0.0.0 --port 8089\n```\n\nYou can specify a custom config file:\n\n```bash\nopenimagegen --host 0.0.0.0 --port 8089 --config /path/to/custom_config.toml\n```\n\nAlternatively, set the `OPENIMAGEGEN_CONFIG` environment variable:\n\n```bash\nexport OPENIMAGEGEN_CONFIG=/path/to/custom_config.toml\nopenimagegen --host 0.0.0.0 --port 8089\n```\n\n### Config File Search Paths\n\nThe API searches for `config.toml` in the following locations (priority order):\n\n1.  Path specified via the `--config` command-line argument.\n2.  Path specified via the `OPENIMAGEGEN_CONFIG` environment variable.\n3.  System-specific locations:\n    - **Linux:** `/etc/openimagegen/config.toml`, `/usr/local/etc/openimagegen/config.toml`, `~/.config/openimagegen/config.toml`, `./config.toml`\n    - **Windows:** `%APPDATA%/openimagegen/config.toml`, `./config.toml`\n    - **macOS:** `~/Library/Application Support/openimagegen/config.toml`, `/usr/local/etc/openimagegen/config.toml`, `./config.toml`\n4.  If no config file is found, a default `config.toml` is created in the current directory.\n\n## API Endpoints\n\n- `GET /health`: Check service status and configuration.\n- `GET /models`: List available models defined in the config.\n- `POST /submit`: Submit an image generation job and get a job ID.\n- `GET /status/{job_id}`: Check the status and progress of a job.\n- `GET /download/{job_id}/{image_index}`: Download a specific generated image for a job.\n- `GET /webui`: (Optional) Access a basic web interface.\n\n## Example Usage (using curl)\n\n### Submit a Job\n\n```bash\ncurl -X POST \"http://localhost:8089/submit\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n    \"prompt\": \"A photorealistic astronaut riding a horse on the moon\",\n    \"negative_prompt\": \"low quality, blurry, cartoon, drawing\",\n    \"model_name\": \"stable_diffusion_xl\",\n    \"height\": 1024,\n    \"width\": 1024,\n    \"steps\": 30,\n    \"guidance_scale\": 7.0,\n    \"num_images_per_prompt\": 2,\n    \"seed\": 12345\n}'\n```\n\nResponse:\n\n```json\n{\n    \"job_id\": \"a1b2c3d4-e5f6-7890-1234-567890abcdef\",\n    \"message\": \"Job submitted successfully\"\n}\n```\n\n### Check Job Status\n\n```bash\ncurl \"http://localhost:8089/status/a1b2c3d4-e5f6-7890-1234-567890abcdef\"\n```\n\nResponse (during processing):\n\n```json\n{\n    \"job_id\": \"a1b2c3d4-e5f6-7890-1234-567890abcdef\",\n    \"status\": \"processing\",\n    \"progress\": 50,\n    \"message\": \"Generating images...\",\n    \"image_urls\": null,\n    \"created_at\": 1678886400.123,\n    \"expires_at\": 1678890000.123\n}\n```\n\nResponse (when completed):\n\n```json\n{\n    \"job_id\": \"a1b2c3d4-e5f6-7890-1234-567890abcdef\",\n    \"status\": \"completed\",\n    \"progress\": 100,\n    \"message\": \"Images generated successfully\",\n    \"image_urls\": [\n        \"/download/a1b2c3d4-e5f6-7890-1234-567890abcdef/0\",\n        \"/download/a1b2c3d4-e5f6-7890-1234-567890abcdef/1\"\n    ],\n    \"created_at\": 1678886400.123,\n    \"expires_at\": 1678890000.123\n}\n```\n\n### Download an Image\n\nDownload the first generated image (index 0):\n\n```bash\ncurl \"http://localhost:8089/download/a1b2c3d4-e5f6-7890-1234-567890abcdef/0\" --output image_0.png\n```\n\nDownload the second generated image (index 1):\n\n```bash\ncurl \"http://localhost:8089/download/a1b2c3d4-e5f6-7890-1234-567890abcdef/1\" --output image_1.png\n```\n\n## Configuration\n\nEdit `config.toml` to customize models, settings, and generation defaults.\n\n```toml\n[models]\n# Add models from Hugging Face Hub\nstable_diffusion_1_5 = {name = \"runwayml/stable-diffusion-v1-5\", type = \"stable_diffusion\"}\nstable_diffusion_xl = {name = \"stabilityai/stable-diffusion-xl-base-1.0\", type = \"stable_diffusion_xl\"}\n# Example with Refiner for SDXL\n# stable_diffusion_xl_refiner = {name = \"stabilityai/stable-diffusion-xl-refiner-1.0\", type = \"stable_diffusion_xl_refiner\"}\n\n[settings]\ndefault_model = \"stable_diffusion_1_5\"\nforce_gpu = false\nuse_gpu = true\ndtype = \"float16\" # \"float16\" or \"bfloat16\"\noutput_folder = \"./outputs\"\nmodel_cache_dir = \"./models\"\nport = 8089\nhost = \"0.0.0.0\"\nfile_retention_time = 3600 # 1 hour\n\n[generation]\nguidance_scale = 7.5\nnum_inference_steps = 50\nnum_images_per_prompt = 1\n```\n\n- **Model Types:** `stable_diffusion`, `stable_diffusion_xl`, `kandinsky`, `deepfloyd_if`. The code needs specific loading logic for each type. SDXL might need handling for base + refiner models.\n- **`force_gpu`**: Requires a GPU or raises an error.\n- **`use_gpu`**: Uses GPU if available.\n- **`dtype`**: `float16` is generally faster and uses less VRAM; `bfloat16` can offer better stability/quality on compatible hardware (Ampere+).\n\n## Setting Up as an Ubuntu Service\n\n(Adapt the instructions from `OpenVideoGen/README.md`, replacing `openvideogen` with `openimagegen`, updating paths, username, and the `ExecStart` command).\n\n## Docker Integration\n\n(Adapt the instructions from `OpenVideoGen/README.md`, replacing `openvideogen` with `openimagegen`, updating paths, port mappings, and image names).\n\n## Supported Models (Examples)\n\n- `stable_diffusion_1_5`: Stable Diffusion v1.5\n- `stable_diffusion_xl`: Stable Diffusion XL Base 1.0\n- `kandinsky`: Kandinsky 2.1/2.2 (requires specific pipeline handling)\n- `deepfloyd_if`: DeepFloyd IF (requires specific pipeline handling and potentially multiple stages)\n\nAdd models to `config.toml`. You may need to extend `main.py` to handle the loading and generation logic for different pipeline types.\n\n## Contributing\n\nContributions are welcome! Please open an issue or submit a pull request.\n\n## License\n\nThis project is licensed under the Apache 2.0 License - see the [LICENSE](LICENSE) file for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fparisneo%2Fopenimagegen","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fparisneo%2Fopenimagegen","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fparisneo%2Fopenimagegen/lists"}