7e210fe777 Refactor ModelScope Image Generator API (#5)
* Refactor ModelScope Image Generator to use new Async API.

Updates `ModelScopeImageGenerator` in `nodes.py` to:
- Use `v1/images/generations` with `X-ModelScope-Async-Mode: true`.
- Implement polling logic for task completion.
- Update input parameters to match API documentation (steps, guidance, seed, loras, size).
- Support `loras` as string or JSON dict.

* Initial plan

* Address all review comments from PR review thread

Co-authored-by: neverbiasu <90372299+neverbiasu@users.noreply.github.com>

* Add .gitignore and remove __pycache__

Co-authored-by: neverbiasu <90372299+neverbiasu@users.noreply.github.com>

* Move logging import to top and improve headers copy

Co-authored-by: neverbiasu <90372299+neverbiasu@users.noreply.github.com>

* Define logger at module level and fix formatting

Co-authored-by: neverbiasu <90372299+neverbiasu@users.noreply.github.com>

* Refactor ModelScope Image Generator API

Updates `ModelScopeImageGenerator` to use the asynchronous `v1/images/generations` endpoint.
- Implements task polling logic with timestamp-based timeout.
- Adds fail-fast logic for 4xx client errors during polling.
- Updates input parameters to match API: `steps`, `guidance`, `seed`, `loras`.
- Supports `loras` as JSON dict or string ID.
- Uses `logging` instead of `print`.
- Ensures UTF-8 charset in headers for multi-language support.

* Simplify loras parsing logic to avoid duplication

Co-authored-by: neverbiasu <90372299+neverbiasu@users.noreply.github.com>

---------

Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: neverbiasu <90372299+neverbiasu@users.noreply.github.com>
2026-01-05 02:26:23 +00:00
2025-09-25 16:39:14 +01:00
2025-09-24 07:41:07 +08:00
2025-09-24 07:41:07 +08:00
2025-11-08 21:08:47 +00:00
2025-09-25 16:39:14 +01:00
2025-09-24 07:41:07 +08:00

ComfyUI-ModelScope

ComfyUI-ModelScope Logo

A ComfyUI custom node package for ModelScope API integration, providing seamless access to ModelScope's powerful AI models including Large Language Models (LLM), Vision-Language Models (VLM), and Image Generation capabilities.

About ModelScope

ModelScope is a comprehensive AI model platform that offers state-of-the-art models for various AI tasks. This ComfyUI integration provides direct access to ModelScope's API inference services, enabling you to leverage powerful models like Qwen series without local model deployment.

Features

  • Large Language Model (LLM): Generate text responses using ModelScope's chat completion models
  • Vision-Language Model (VLM): Analyze images with text prompts using advanced multimodal models
  • Text-to-Image Generation: Create high-quality images from text descriptions
  • Enhanced Error Handling: Robust timeout management and SSL configuration
  • Input Validation: Comprehensive validation with helpful tooltips and placeholders
  • Text Sanitization: Automatic text cleaning for ComfyUI showText node compatibility
  • Configurable Timeouts: Adjustable request timeouts optimized for different model types

Installation

1. Install the Extension

Download or git clone this repository inside ComfyUI/custom_nodes/ directory:

git clone https://github.com/neverbiasu/ComfyUI-ModelScope.git

Or use the ComfyUI Manager for automatic installation.

2. Install Dependencies

The extension requires the following Python packages:

pip install -r requirements.txt

3. API Configuration

You'll need a ModelScope API key to use these nodes. You can obtain one from ModelScope.

Set your API key in one of these ways:

  • Set the MODELSCOPE_API_KEY environment variable
  • Set the MODELSCOPE_ACCESS_TOKEN environment variable
  • Provide the API key directly in the node's api_key field

4. Restart ComfyUI

Restart ComfyUI to load the new nodes.

Example Workflows

Text Generation Workflow

LLM workflow Use the ModelScope LLM node to generate creative text, answer questions, or perform text processing tasks.

Vision-Language Understanding Workflow

VLM workflow Analyze images and answer questions about their content using advanced vision-language models.

Text-to-Image Generation Workflow

Image Generation workflow Generate custom images from text descriptions with fine-tuned control over output parameters.

S
Description
No description provided
Readme
1.3 MiB
Languages
Python 100%