ModelScope-Image
A Dify plugin based on ModelScope API‑Inference, providing text‑to‑image and image‑to‑image capabilities. It supports calling most AIGC models available on the ModelScope platform.
Features
- Multi‑model support: Switch freely by specifying the model ID in the parameters. Supported models include 、、, and many others from the ModelScope AIGC collection.
- Text‑to‑image: Generate images from text prompts. Supports positive/negative prompts, aspect ratio, resolution, seed, sampling steps, guidance scale, and LoRA models.
- Image‑to‑image: Use an uploaded image as a template and generate a new image guided by a text prompt. All parameters available in text‑to‑image are supported, plus an "original" aspect ratio option to preserve the input image’s proportions.
- Comprehensive parameter tuning:
- Aspect ratio: 7 common ratios (1:1, 4:3, 3:4, 16:9, 9:16, 2:1, 1:2); image‑to‑image also offers an "original" option.
- Resolution: Adjustable from 64 to 2048.
- Sampling steps: 1–100 steps to balance quality and speed.
- Guidance scale: 1.5–20 to control prompt influence.
- Random seed: Fix a seed for reproducible results.
- LoRA models: Specify compatible LoRA model IDs for style transfer or detail enhancement.
Installation & Configuration
1. Get an API Key
You need a ModelScope API Key before using this plugin:
2. Install the Plugin in Dify
Add the plugin to Dify’s plugin directory or install it via Dify’s plugin management interface.
3. Configure the API Key
Enter your ModelScope API Key in the plugin’s credential settings.
4. (For Image‑to‑Image Only) Environment Variable
If you use the image‑to‑image tool, you must set the following environment variable in Dify’s file to allow the plugin to access uploaded image files:
This is required for internal container communication. Without it, the image‑to‑image tool may fail to retrieve the input image.
Usage Examples
文生图
[Image blocked: text-to-image]
图生图
[Image blocked: text-to-image]
Development
The plugin is written in Python and follows this structure:
- Python version: 3.12
- Supported architectures: amd64, arm64
Entry point
The plugin entry point is , defined in .
Important Notes
- Ensure your API Key has sufficient permissions to call the selected models.
- For image‑to‑image, the input image should be in a common format (e.g., PNG, JPEG). Make sure the environment variable is correctly set.
- Different models may support different parameter ranges or features. Refer to the official ModelScope documentation for model‑specific details.
- Check out ModelScope AIGC models available for free。
Privacy & License
- See PRIVACY.md for privacy information.
- This plugin is subject to the terms of use of the ModelScope API.
Author
Version
Current version: