[PR #14408] x/imagegen: restore image editing dispatch for flux2 models #76957

Open
opened 2026-05-05 09:41:30 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ollama/ollama/pull/14408
Author: @RajeshKumar11
Created: 2/25/2026
Status: 🔄 Open

Base: mainHead: fix/imagegen-restore-image-editing


📝 Commits (1)

  • 934643a x/imagegen: restore image editing dispatch for flux2 models

📊 Changes

1 file changed (+32 additions, -2 deletions)

View changed files

📝 x/imagegen/imagegen.go (+32 -2)

📄 Description

Problem

Closes #14306

Commit 6ddd8862 refactored the imagegen runner but accidentally dropped two things:

  1. The ImageEditModel interface that extends ImageModel with GenerateImageWithInputs
  2. The conditional dispatch in handleImageCompletion that routes to GenerateImageWithInputs when input images (req.Images) are present

This caused Flux2 Klein image-to-image editing (introduced in v0.15.4) to silently fall back to plain text-to-image generation in v0.15.6+, ignoring any uploaded reference images entirely.

Fix

Restore the ImageEditModel interface and update handleImageCompletion to:

  • Decode req.Images bytes into []image.Image
  • Dispatch to editModel.GenerateImageWithInputs(...) when input images are present
  • Fall back to s.imageModel.GenerateImage(...) for prompt-only requests
  • Return HTTP 400 if a model receives images but doesn't implement ImageEditModel

flux2.Model already implements GenerateImageWithInputs (it was never removed from the model itself, only the dispatch was lost), so no changes are needed there.

Testing

  • gofmt passes with no issues
  • go mod tidy produces no changes (stdlib image package, no new deps)
  • Build failure in x/imagegen on non-mlx platforms is pre-existing (requires Apple Silicon + MLX framework); CI macOS runners will compile this correctly
  • Manually verified flux2.Model.GenerateImageWithInputs signature matches the restored interface exactly

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ollama/ollama/pull/14408 **Author:** [@RajeshKumar11](https://github.com/RajeshKumar11) **Created:** 2/25/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `fix/imagegen-restore-image-editing` --- ### 📝 Commits (1) - [`934643a`](https://github.com/ollama/ollama/commit/934643af18ce29938f391852d6ae15adb9e3493c) x/imagegen: restore image editing dispatch for flux2 models ### 📊 Changes **1 file changed** (+32 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `x/imagegen/imagegen.go` (+32 -2) </details> ### 📄 Description ## Problem Closes #14306 Commit 6ddd8862 refactored the imagegen runner but accidentally dropped two things: 1. The `ImageEditModel` interface that extends `ImageModel` with `GenerateImageWithInputs` 2. The conditional dispatch in `handleImageCompletion` that routes to `GenerateImageWithInputs` when input images (`req.Images`) are present This caused Flux2 Klein image-to-image editing (introduced in v0.15.4) to silently fall back to plain text-to-image generation in v0.15.6+, ignoring any uploaded reference images entirely. ## Fix Restore the `ImageEditModel` interface and update `handleImageCompletion` to: - Decode `req.Images` bytes into `[]image.Image` - Dispatch to `editModel.GenerateImageWithInputs(...)` when input images are present - Fall back to `s.imageModel.GenerateImage(...)` for prompt-only requests - Return HTTP 400 if a model receives images but doesn't implement `ImageEditModel` `flux2.Model` already implements `GenerateImageWithInputs` (it was never removed from the model itself, only the dispatch was lost), so no changes are needed there. ## Testing - `gofmt` passes with no issues - `go mod tidy` produces no changes (stdlib `image` package, no new deps) - Build failure in `x/imagegen` on non-mlx platforms is pre-existing (requires Apple Silicon + MLX framework); CI macOS runners will compile this correctly - Manually verified `flux2.Model.GenerateImageWithInputs` signature matches the restored interface exactly --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-05-05 09:41:30 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#76957