An open API service indexing awesome lists of open source software.

https://github.com/jtyszkiew/imagesmith

ComfyUI Discord Bot - Share workflows with your friends through Discord!
https://github.com/jtyszkiew/imagesmith

ai-chatbot comfyui comfyui-nodes discord-bot stable-diffusion

Last synced: 6 months ago
JSON representation

ComfyUI Discord Bot - Share workflows with your friends through Discord!

Awesome Lists containing this project

README

          

![gif](./assets/imagesmith.gif)

# ImageSmith ๐Ÿ”จ

[![Discord](https://img.shields.io/discord/1301892549568368651.svg?label=Discord)](https://discord.gg/9Ne74HPEue)
![Codecov](https://img.shields.io/codecov/c/github/jtyszkiew/ImageSmith)

> Forge your imagination into reality with ImageSmith - A powerful Discord bot that seamlessly integrates with ComfyUI for intuitive image generation.

## โœจ Overview

ImageSmith is a Discord bot that brings the power of ComfyUI directly to your Discord server. With a user-friendly interface and powerful customization options, it allows users to generate images through simple commands while leveraging ComfyUI's advanced capabilities.

> **Note**: ImageSmith is a workflow executor, not a workflow creator. You'll need to create your own workflows, but the bot makes them easily accessible through Discord's UI. Check out the example workflows in the repository to get started.

## ๐ŸŒŸ Key Features

- ๐Ÿ”„ **Direct ComfyUI Integration** - Seamless connection with your ComfyUI instance
- ๐Ÿ“Š **Queue Management** - Efficient handling of generation requests
- ๐Ÿ› ๏ธ **Customizable Workflows** - Support for custom ComfyUI workflows
- ๐Ÿ”Œ **Plugin System** - Extend functionality through plugins
- ๐Ÿ“ˆ **Real-time Progress** - Live updates on generation status
- โš™๏ธ **Flexible Configuration** - Highly customizable settings
- ๐Ÿช **Hook System** - Customize workflow behavior

## ๐Ÿš€ Getting Started

### Prerequisites

- Python 3.10+
- Running ComfyUI instance
- Discord Bot Token

### Installation Options

#### ๐Ÿณ Docker

**Basic Setup**
```bash
docker run -e DISCORD_TOKEN="" ghcr.io/jtyszkiew/imagesmith:latest
```

**Custom Configuration**
```bash
docker run -e DISCORD_TOKEN="" \
--mount type=bind,source=./configuration.yml,target=/app/configuration.yml \
ghcr.io/jtyszkiew/imagesmith:latest
```

**Custom Configuration & Workflows**
```bash
docker run -e DISCORD_TOKEN="" \
--mount type=bind,source=./configuration.yml,target=/app/configuration.yml \
-v "./custom_workflows:/app/custom_workflows" \
ghcr.io/jtyszkiew/imagesmith:latest
```

> **Important**: Default workflows use `sd_xl_base_1.0` for image generation and Mochi models for video generation. Ensure these are available in your ComfyUI instance.

#### ๐Ÿ”ง From Source

1. **Clone & Setup**
```bash
git clone https://github.com/jtyszkiew/ImageSmith.git
cd ImageSmith
python -m venv venv
source venv/bin/activate # Windows: .\venv\Scripts\activate
pip install -r requirements.txt
```

2. **Configure**
```bash
cp configuration.example.yml configuration.yml
# Edit configuration.yml with your settings
```

3. **Run**
```bash
python main.py
```

## ๐Ÿ’ฌ Usage Guide

### Available Commands

| Command | Description | Parameters |
|---------|-------------|------------|
| `/forge` | Generate image from text | `prompt`, `[workflow]`, `[settings]` |
| `/reforge` | Transform existing image | `image`, `prompt`, `[workflow]`, `[settings]` |
| `/upscale` | Upscale with modifications | `image`, `prompt`, `[workflow]`, `[settings]` |
| `/workflows` | List available workflows | - |

### Example Usage

```bash
# Basic generation
/forge A majestic mountain landscape at sunset

# Using specific workflow
/forge A cyberpunk city --workflow cyberpunk_generator

# With custom settings
/forge A fantasy character --workflow character_generator --settings "change_steps(30);add_lora('fantasy_style', 0.8)"
```

## โš™๏ธ Advanced Configuration

### Generic Settings

Two settings types: `__before` and `__after` are called before each workflow execution.

```yaml
- name: __before
description: "Default workflow configuration"
code: |
def __before(workflowjson):
import random
workflowjson["4"]["inputs"]["ckpt_name"] = "Juggernaut_X_RunDiffusion.safetensors"
workflowjson["3"]["inputs"]["seed"] = random.randint(0, 2**32 - 1)
```

### Custom non-generic setting example

```yaml
- name: hd
description: "HD resolution preset"
code: |
def hd(workflowjson):
workflowjson["5"]["inputs"]["width"] = 1280
workflowjson["5"]["inputs"]["height"] = 720
```

Usage: `/forge A fantasy character --settings "hd()"`

## ๐Ÿ”’ Security

Configure access control for workflows and settings:

```yaml
# Workflow security
workflows:
forge:
security:
enabled: true
allowed_roles: ["Smith"]
allowed_users: ["Smith123"]

# Setting security
- name: hd
security:
enabled: true
allowed_roles: ["Smith"]
allowed_users: ["Smith123"]
code: "..."
```

## ๐Ÿ”Œ Plugin Development

Create custom plugins to extend functionality:

```python
from src.core.plugin import Plugin

class MyPlugin(Plugin):
async def on_load(self):
await super().on_load()
self.bot.hook_manager.register_hook('is.comfyui.client.before_create', self.my_hook)

async def my_hook(self, workflow_json: dict, instances: list):
return workflow_json
```

### Available Hooks

- `is.comfyui.client.before_create`
- `is.comfyui.client.after_create`
- `is.security.before`
- `is.comfyui.client.instance.timeout`
- `is.comfyui.client.instance.reconnect`

## ๐Ÿงช Testing

```bash
pip install pytest pytest-asyncio pytest-mock pytest-cov
pytest tests/ -v --cov=./
```

## ๐Ÿค Contributing

1. Fork the repository
2. Create feature branch: `git checkout -b feature/AmazingFeature`
3. Commit changes: `git commit -m 'Add AmazingFeature'`
4. Push to branch: `git push origin feature/AmazingFeature`
5. Open a Pull Request

## ๐Ÿ“„ License

Licensed under the MIT License - see the [LICENSE](LICENSE) file for details.

## ๐Ÿ™ Acknowledgments

- [ComfyUI](https://github.com/comfyanonymous/ComfyUI) - Image generation backend
- [discord.py](https://github.com/Rapptz/discord.py) - Discord integration

## โš ๏ธ Disclaimer

This bot is for educational and creative purposes. Users are responsible for ensuring their usage complies with ComfyUI's and Discord's terms of service.

## ๐Ÿ’ฌ Community

Join our [Discord server](https://discord.gg/9Ne74HPEue) to see the bot in action and stay updated with the latest developments!