Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
C
coderai
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexlab
coderai
Commits
671388fd
Commit
671388fd
authored
Mar 19, 2026
by
Your Name
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix: Use DiffusionPipeline for custom model support (ZImagePipeline)
parent
afb2eead
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
13 deletions
+19
-13
images.py
codai/api/images.py
+19
-13
No files found.
codai/api/images.py
View file @
671388fd
...
...
@@ -314,18 +314,23 @@ async def create_image_generation(request: ImageGenerationRequest, http_request:
# Try to load the model
load_error
=
None
try
:
if
is_xl
:
# Load SDXL
pipeline
=
StableDiffusionXLPipeline
.
from_pretrained
(
model_to_use
,
torch_dtype
=
dtype
,
)
# Use DiffusionPipeline.from_pretrained which auto-detects the correct pipeline class
# from model_index.json (supports custom pipelines like ZImagePipeline)
from
diffusers
import
DiffusionPipeline
print
(
f
"Loading diffusers model: {model_to_use}"
)
# Determine compute type
if
torch
.
cuda
.
is_available
():
dtype
=
torch
.
float16
else
:
# Load SD 1.5
pipeline
=
StableDiffusionPipeline
.
from_pretrained
(
model_to_use
,
torch_dtype
=
dtype
,
)
dtype
=
torch
.
float32
# Use DiffusionPipeline for auto-detection of pipeline class
pipeline
=
DiffusionPipeline
.
from_pretrained
(
model_to_use
,
torch_dtype
=
dtype
,
)
except
Exception
as
load_error
:
# Try with revised model resolution for custom models
print
(
f
"Warning: First model load attempt failed: {load_error}"
)
...
...
@@ -341,13 +346,14 @@ async def create_image_generation(request: ImageGenerationRequest, http_request:
# Try with default resolution
try
:
from
diffusers
import
DiffusionPipeline
if
is_xl
:
pipeline
=
StableDiffusionXLPipeline
.
from_pretrained
(
model_to_use
,
torch_dtype
=
dtype
,
)
else
:
pipeline
=
Stable
DiffusionPipeline
.
from_pretrained
(
pipeline
=
DiffusionPipeline
.
from_pretrained
(
model_to_use
,
torch_dtype
=
dtype
,
)
...
...
@@ -361,7 +367,7 @@ async def create_image_generation(request: ImageGenerationRequest, http_request:
safety_checker
=
None
,
)
else
:
pipeline
=
Stable
DiffusionPipeline
.
from_pretrained
(
pipeline
=
DiffusionPipeline
.
from_pretrained
(
model_to_use
,
torch_dtype
=
dtype
,
safety_checker
=
None
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment