Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
ollama
Commits
543240fb
Unverified
Commit
543240fb
authored
Mar 13, 2025
by
Michael Yang
Committed by
GitHub
Mar 13, 2025
Browse files
Merge pull request #9741 from ollama/mxyng/visionless
fix: error if image requested without vision model
parents
4bed7392
3e102b7d
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
10 additions
and
0 deletions
+10
-0
model/model.go
model/model.go
+2
-0
model/models/gemma3/model.go
model/models/gemma3/model.go
+4
-0
model/models/mllama/model.go
model/models/mllama/model.go
+4
-0
No files found.
model/model.go
View file @
543240fb
...
@@ -22,6 +22,8 @@ import (
...
@@ -22,6 +22,8 @@ import (
"github.com/ollama/ollama/model/input"
"github.com/ollama/ollama/model/input"
)
)
var
ErrNoVisionModel
=
errors
.
New
(
"this model is missing data required for image input"
)
// Model implements a specific model architecture, defining the forward pass and any model-specific configuration
// Model implements a specific model architecture, defining the forward pass and any model-specific configuration
type
Model
interface
{
type
Model
interface
{
Forward
(
ml
.
Context
,
input
.
Options
)
(
ml
.
Tensor
,
error
)
Forward
(
ml
.
Context
,
input
.
Options
)
(
ml
.
Tensor
,
error
)
...
...
model/models/gemma3/model.go
View file @
543240fb
...
@@ -84,6 +84,10 @@ func New(c ml.Config) (model.Model, error) {
...
@@ -84,6 +84,10 @@ func New(c ml.Config) (model.Model, error) {
}
}
func
(
m
*
Model
)
EncodeMultimodal
(
ctx
ml
.
Context
,
multimodalData
[]
byte
)
(
any
,
error
)
{
func
(
m
*
Model
)
EncodeMultimodal
(
ctx
ml
.
Context
,
multimodalData
[]
byte
)
(
any
,
error
)
{
if
len
(
m
.
VisionModel
.
Layers
)
==
0
{
return
nil
,
model
.
ErrNoVisionModel
}
image
,
_
,
err
:=
image
.
Decode
(
bytes
.
NewReader
(
multimodalData
))
image
,
_
,
err
:=
image
.
Decode
(
bytes
.
NewReader
(
multimodalData
))
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
...
...
model/models/mllama/model.go
View file @
543240fb
...
@@ -63,6 +63,10 @@ func New(c ml.Config) (model.Model, error) {
...
@@ -63,6 +63,10 @@ func New(c ml.Config) (model.Model, error) {
}
}
func
(
m
*
Model
)
EncodeMultimodal
(
ctx
ml
.
Context
,
multimodalData
[]
byte
)
(
any
,
error
)
{
func
(
m
*
Model
)
EncodeMultimodal
(
ctx
ml
.
Context
,
multimodalData
[]
byte
)
(
any
,
error
)
{
if
len
(
m
.
VisionModel
.
Transformer
.
Layers
)
==
0
||
len
(
m
.
GlobalTransformer
.
Layers
)
==
0
{
return
nil
,
model
.
ErrNoVisionModel
}
image
,
_
,
err
:=
image
.
Decode
(
bytes
.
NewReader
(
multimodalData
))
image
,
_
,
err
:=
image
.
Decode
(
bytes
.
NewReader
(
multimodalData
))
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
...
...
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