2023-11-13 21:40:16 +00:00
|
|
|
package main
|
2023-07-14 23:19:43 +00:00
|
|
|
|
|
|
|
// This is a wrapper to statisfy the GRPC service interface
|
|
|
|
// It is meant to be used by the main executable that is the server for the specific backend type (falcon, gpt3, etc)
|
|
|
|
import (
|
|
|
|
"github.com/go-skynet/LocalAI/pkg/grpc/base"
|
|
|
|
pb "github.com/go-skynet/LocalAI/pkg/grpc/proto"
|
2023-12-24 19:27:24 +00:00
|
|
|
"github.com/go-skynet/LocalAI/pkg/tinydream"
|
2023-07-14 23:19:43 +00:00
|
|
|
)
|
|
|
|
|
2023-12-24 19:27:24 +00:00
|
|
|
type Image struct {
|
2023-08-20 12:04:45 +00:00
|
|
|
base.SingleThread
|
2023-12-24 19:27:24 +00:00
|
|
|
tinydream *tinydream.TinyDream
|
2023-07-14 23:19:43 +00:00
|
|
|
}
|
|
|
|
|
2023-12-24 19:27:24 +00:00
|
|
|
func (image *Image) Load(opts *pb.ModelOptions) error {
|
2023-07-14 23:19:43 +00:00
|
|
|
var err error
|
|
|
|
// Note: the Model here is a path to a directory containing the model files
|
2023-12-24 19:27:24 +00:00
|
|
|
image.tinydream, err = tinydream.New(opts.ModelFile)
|
2023-07-14 23:19:43 +00:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2023-12-24 19:27:24 +00:00
|
|
|
func (image *Image) GenerateImage(opts *pb.GenerateImageRequest) error {
|
|
|
|
return image.tinydream.GenerateImage(
|
2023-07-14 23:19:43 +00:00
|
|
|
int(opts.Height),
|
|
|
|
int(opts.Width),
|
|
|
|
int(opts.Step),
|
|
|
|
int(opts.Seed),
|
|
|
|
opts.PositivePrompt,
|
|
|
|
opts.NegativePrompt,
|
|
|
|
opts.Dst)
|
|
|
|
}
|