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
5bddb025
Commit
5bddb025
authored
Mar 19, 2026
by
Your Name
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add debug output for image generation to diagnose black images
parent
b7fbde39
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
2 deletions
+7
-2
images.py
codai/api/images.py
+7
-2
No files found.
codai/api/images.py
View file @
5bddb025
...
@@ -504,12 +504,17 @@ async def create_image_generation(request: ImageGenerationRequest, http_request:
...
@@ -504,12 +504,17 @@ async def create_image_generation(request: ImageGenerationRequest, http_request:
# Convert to base64
# Convert to base64
import
numpy
as
np
import
numpy
as
np
# Handle NaN/Inf values in image data - convert to valid values
# Debug: print image type and value range
print
(
f
"DEBUG: Image type: {type(img)}"
)
if
isinstance
(
img
,
np
.
ndarray
):
if
isinstance
(
img
,
np
.
ndarray
):
print
(
f
"DEBUG: Image shape: {img.shape}, dtype: {img.dtype}, min: {img.min()}, max: {img.max()}"
)
# Handle NaN/Inf values in image data - convert to valid values
# This fixes RuntimeWarning about invalid values in cast
# Replace NaN and Inf with valid values
# Replace NaN and Inf with valid values
img
=
np
.
nan_to_num
(
img
,
nan
=
0.
0
,
posinf
=
1.0
,
neginf
=
0.0
)
img
=
np
.
nan_to_num
(
img
,
nan
=
0.
5
,
posinf
=
1.0
,
neginf
=
0.0
)
# Use 0.5 for NaN (gray, not black
)
# Clip to valid range [0, 1]
# Clip to valid range [0, 1]
img
=
np
.
clip
(
img
,
0.0
,
1.0
)
img
=
np
.
clip
(
img
,
0.0
,
1.0
)
print
(
f
"DEBUG: After NaN handling - min: {img.min()}, max: {img.max()}"
)
# Use helper function to save and get response
# Use helper function to save and get response
img_data
=
save_image_response
(
img
,
request
.
response_format
,
http_request
)
img_data
=
save_image_response
(
img
,
request
.
response_format
,
http_request
)
...
...
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