mirror of
https://github.com/karl0ss/ai_image_frame_server.git
synced 2025-11-12 21:09:41 +00:00
feat(config): add automatic config file creation from sample
- Modify load_config function to copy user_config.cfg from user_config.cfg.sample if it doesn't exist - Update README.md to reflect new features and configuration options, including web-based settings and job queue management
This commit is contained in:
parent
854732b1c2
commit
9e3731bfdc
36
README.md
36
README.md
@ -4,12 +4,19 @@ This project is a Flask-based web server designed to generate and display images
|
|||||||
|
|
||||||
## Features
|
## Features
|
||||||
|
|
||||||
* **Web Interface:** A simple web interface to view generated images.
|
* **Web Interface:** A simple web interface to view generated images, manage favourites, and monitor job queues.
|
||||||
* **Image Generation:** Integrates with ComfyUI to generate images based on given prompts and models.
|
* **Image Generation:** Integrates with ComfyUI to generate images using SDXL, FLUX, and Qwen models based on given prompts.
|
||||||
|
* **Prompt Generation:** Automatic prompt generation using OpenWebUI or OpenRouter APIs with topic-based theming.
|
||||||
* **Scheduled Generation:** Automatically generates new images at a configurable time.
|
* **Scheduled Generation:** Automatically generates new images at a configurable time.
|
||||||
|
* **Favourites System:** Mark and manage favourite images.
|
||||||
|
* **Job Queue Management:** View and cancel running/pending image generation jobs.
|
||||||
|
* **Thumbnail Generation:** Automatic thumbnail creation for generated images.
|
||||||
|
* **Prompt Logging:** Maintains a log of recent prompts to avoid repetition.
|
||||||
|
* **Settings Management:** Web-based configuration editor for all settings.
|
||||||
* **Docker Support:** Comes with a `Dockerfile` and `docker-compose.yml` for easy setup and deployment.
|
* **Docker Support:** Comes with a `Dockerfile` and `docker-compose.yml` for easy setup and deployment.
|
||||||
* **Configurable:** Most options can be configured through a `user_config.cfg` file.
|
* **Configurable:** Most options can be configured through a `user_config.cfg` file or web interface.
|
||||||
* **Authentication:** Optional password protection for image creation.
|
* **Authentication:** Optional password protection for image creation.
|
||||||
|
* **Version Management:** Uses bump-my-version for version tracking.
|
||||||
|
|
||||||
## Prerequisites
|
## Prerequisites
|
||||||
|
|
||||||
@ -33,8 +40,8 @@ This project is a Flask-based web server designed to generate and display images
|
|||||||
```
|
```
|
||||||
|
|
||||||
3. **Configure the application:**
|
3. **Configure the application:**
|
||||||
* Copy the `user_config.cfg.sample` to `user_config.cfg`.
|
* The `user_config.cfg` file will be automatically created from `user_config.cfg.sample` on first run if it doesn't exist.
|
||||||
* Edit `user_config.cfg` with your settings. See the [Configuration](#configuration) section for more details.
|
* Edit `user_config.cfg` with your settings, or use the web-based settings page accessible by clicking the version number in the bottom right corner of the home page. See the [Configuration](#configuration) section for more details.
|
||||||
|
|
||||||
4. **Run the application:**
|
4. **Run the application:**
|
||||||
```bash
|
```bash
|
||||||
@ -51,8 +58,8 @@ This project is a Flask-based web server designed to generate and display images
|
|||||||
```
|
```
|
||||||
|
|
||||||
2. **Configure the application:**
|
2. **Configure the application:**
|
||||||
* Copy the `user_config.cfg.sample` to `user_config.cfg`.
|
* The `user_config.cfg` file will be automatically created from `user_config.cfg.sample` on first run if it doesn't exist.
|
||||||
* Edit `user_config.cfg` with your settings. The `comfyui_url` should be the address of your ComfyUI instance, accessible from within the Docker network (e.g., `http://host.docker.internal:8188` or your server's IP).
|
* Edit `user_config.cfg` with your settings, or use the web-based settings page accessible by clicking the version number in the bottom right corner of any page. The `comfyui_url` should be the address of your ComfyUI instance, accessible from within the Docker network (e.g., `http://host.docker.internal:8188` or your server's IP).
|
||||||
|
|
||||||
3. **Build and run with Docker Compose:**
|
3. **Build and run with Docker Compose:**
|
||||||
```bash
|
```bash
|
||||||
@ -82,7 +89,6 @@ The application is configured via the `user_config.cfg` file.
|
|||||||
| `[comfyui]` | `secondary_topic` | A secondary topic for prompt generation. | |
|
| `[comfyui]` | `secondary_topic` | A secondary topic for prompt generation. | |
|
||||||
| `[comfyui]` | `flux` | Enable FLUX models (`True`/`False`). | `False` |
|
| `[comfyui]` | `flux` | Enable FLUX models (`True`/`False`). | `False` |
|
||||||
| `[comfyui]` | `qwen` | Enable Qwen models (`True`/`False`). | `False` |
|
| `[comfyui]` | `qwen` | Enable Qwen models (`True`/`False`). | `False` |
|
||||||
| `[comfyui]` | `only_flux` | Only use FLUX models (`True`/`False`). | `False` |
|
|
||||||
| `[comfyui:flux]` | `models` | A comma-separated list of FLUX models. | `flux1-dev-Q4_0.gguf,flux1-schnell-Q4_0.gguf` |
|
| `[comfyui:flux]` | `models` | A comma-separated list of FLUX models. | `flux1-dev-Q4_0.gguf,flux1-schnell-Q4_0.gguf` |
|
||||||
| `[comfyui:qwen]` | `models` | A comma-separated list of Qwen models. | `qwen-image-Q4_K_S.gguf, qwen-image-Q2_K.gguf` |
|
| `[comfyui:qwen]` | `models` | A comma-separated list of Qwen models. | `qwen-image-Q4_K_S.gguf, qwen-image-Q2_K.gguf` |
|
||||||
| `[openwebui]` | `base_url` | The base URL for OpenWebUI. | `https://openwebui` |
|
| `[openwebui]` | `base_url` | The base URL for OpenWebUI. | `https://openwebui` |
|
||||||
@ -96,14 +102,24 @@ The application is configured via the `user_config.cfg` file.
|
|||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
* **Gallery:** Open your browser to `http://<server_ip>:<port>` to see the gallery of generated images.
|
* **Gallery:** Open your browser to `http://<server_ip>:<port>` to see the gallery of generated images.
|
||||||
* **Create Image:** Navigate to `/create` to manually trigger image generation.
|
* **Create Image:** Navigate to `/create` or `/create_image` to manually trigger image generation with various model options.
|
||||||
|
* **Job Queue:** Monitor and cancel running/pending jobs via the gallery interface.
|
||||||
|
* **API Endpoints:**
|
||||||
|
* `/api/queue` - Get current job queue details (JSON)
|
||||||
|
* `/cancel` - Cancel the current running job
|
||||||
|
|
||||||
## Dependencies
|
## Dependencies
|
||||||
|
|
||||||
* Flask
|
* Flask
|
||||||
* comfy_api_simplified
|
* comfy_api_simplified
|
||||||
* APScheduler
|
* APScheduler
|
||||||
* Pillow
|
* Pillow
|
||||||
|
* tenacity
|
||||||
|
* nest_asyncio
|
||||||
|
* openai
|
||||||
|
* websockets
|
||||||
|
* bump-my-version
|
||||||
|
* openwebui-chat-client
|
||||||
* And others, see `requirements.txt`.
|
* And others, see `requirements.txt`.
|
||||||
|
|
||||||
## Contributing
|
## Contributing
|
||||||
|
|||||||
@ -5,6 +5,7 @@ import sys
|
|||||||
import time
|
import time
|
||||||
import os
|
import os
|
||||||
import random
|
import random
|
||||||
|
import shutil
|
||||||
from PIL import Image
|
from PIL import Image
|
||||||
import nest_asyncio
|
import nest_asyncio
|
||||||
import json
|
import json
|
||||||
@ -38,10 +39,21 @@ def save_prompt(prompt):
|
|||||||
|
|
||||||
|
|
||||||
def load_config() -> configparser.ConfigParser:
|
def load_config() -> configparser.ConfigParser:
|
||||||
"""Loads user configuration from ./user_config.cfg."""
|
"""Loads user configuration from ./user_config.cfg. If it doesn't exist, copies from user_config.cfg.sample."""
|
||||||
user_config = configparser.ConfigParser()
|
user_config = configparser.ConfigParser()
|
||||||
|
config_path = "./user_config.cfg"
|
||||||
|
sample_path = "./user_config.cfg.sample"
|
||||||
|
|
||||||
|
if not os.path.exists(config_path):
|
||||||
|
if os.path.exists(sample_path):
|
||||||
|
shutil.copy(sample_path, config_path)
|
||||||
|
logging.info("Configuration file copied from sample.")
|
||||||
|
else:
|
||||||
|
logging.error("Neither user_config.cfg nor user_config.cfg.sample found.")
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
user_config.read("./user_config.cfg")
|
user_config.read(config_path)
|
||||||
logging.debug("Configuration loaded successfully.")
|
logging.debug("Configuration loaded successfully.")
|
||||||
return user_config
|
return user_config
|
||||||
except KeyError as e:
|
except KeyError as e:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user