# comfyapi **Repository Path**: rachelos/comfyapi ## Basic Information - **Project Name**: comfyapi - **Description**: No description available - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: main - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2025-08-28 - **Last Updated**: 2025-08-28 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # ComfyUI 工具集 这是一个基于 ComfyUI 的图像生成工具集,提供了命令行工具和 API 服务,方便用户使用 ComfyUI 生成图像。 ## 项目结构 ``` comfyui/ ├── api/ # API 服务相关代码 │ ├── __init__.py │ └── fastapi_app.py # FastAPI 应用 ├── client/ # ComfyUI 客户端代码 │ ├── __init__.py │ └── comfyui_client.py # ComfyUI 客户端 ├── core/ # 核心功能模块 │ ├── __init__.py │ └── image_generator.py # 图像生成器 ├── resources/ # 资源文件 │ └── img08/ # 生成的图像文件 ├── templates/ # 模板文件 │ ├── qwen-image-workflowAPI.json # 通义千问图像工作流模板 │ └── qwen-image-workflowAPI4.json # 通义千问图像工作流模板(4步版本) ├── tests/ # 测试代码 │ ├── __init__.py │ ├── test_api.py # API 测试 │ └── test_progress.py # 进度显示测试 ├── utils/ # 工具函数和辅助代码 │ ├── __init__.py │ └── generate_image.py # 图像生成命令行工具 ├── main.py # 主入口文件 └── start_api_server.py # API 服务启动脚本 ``` ## 使用方法 ### 启动 API 服务 ```bash python main.py api --port 8000 ``` 或者直接使用: ```bash python start_api_server.py ``` ### 生成图像(命令行) ```bash python main.py generate --prompt "美丽的山水风景" --negative "模糊,低质量" --width 640 --height 480 ``` 或者直接使用: ```bash python utils/generate_image.py --prompt "美丽的山水风景" --negative "模糊,低质量" --width 640 --height 480 ``` ### 运行测试 ```bash python main.py test ``` ## API 接口 ### 生成图像 - **URL**: `/api/generate_image` - **方法**: POST - **请求体**: ```json { "prompt": "美丽的山水风景", "negative_prompt": "模糊,低质量", "width": 512, "height": 512, "steps": 4, "cfg": 7.0, "seed": -1, "model": "qwen-image-Q4_K_M.gguf", "extra_params": { "95.sampler_name": "euler_ancestral", "95.scheduler": "karras" } } ``` - **响应**: ```json { "status": "success", "task_id": "任务ID", "message": "任务已提交,请使用任务ID查询状态" } ``` ### 获取任务状态 - **URL**: `/api/task_status/{task_id}` - **方法**: GET - **响应**: ```json { "status": "completed", "task_id": "任务ID", "result": "图像文件路径", "execution_time": 10.5 } ``` ### 获取图像文件路径 - **URL**: `/api/get_file/{prompt_id}` - **方法**: GET - **响应**: ```json { "status": "success", "file_path": "图像文件路径" } ``` ### 下载图像 - **URL**: `/api/download_image/{prompt_id}` - **方法**: GET - **响应**: 图像文件(PNG)