Skip to content

Commit

Permalink
Merge pull request #1 from igolaizola/image-not-mandatory
Browse files Browse the repository at this point in the history
Allow generations with only text prompts
  • Loading branch information
igolaizola authored Jul 31, 2023
2 parents 59ce1de + 019eb56 commit 34d3b80
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
4 changes: 2 additions & 2 deletions cmd/vidai/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,8 @@ func newGenerateCommand() *ffcli.Command {
if cfg.Token == "" {
return fmt.Errorf("token is required")
}
if *image == "" {
return fmt.Errorf("image is required")
if *image == "" && *text == "" {
return fmt.Errorf("image or text is required")
}
c := vidai.New(&cfg)
urls, err := c.Generate(ctx, *image, *text, *output, *extend,
Expand Down
9 changes: 6 additions & 3 deletions vidai.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,12 @@ func (c *Client) Generate(ctx context.Context, image, text, output string,
}
name := filepath.Base(image)

imageURL, err := c.client.Upload(ctx, name, b)
if err != nil {
return nil, fmt.Errorf("vidai: couldn't upload image: %w", err)
var imageURL string
if image != "" {
imageURL, err = c.client.Upload(ctx, name, b)
if err != nil {
return nil, fmt.Errorf("vidai: couldn't upload image: %w", err)
}
}
videoURL, err := c.client.Generate(ctx, imageURL, text, interpolate, upscale, watermark)
if err != nil {
Expand Down

0 comments on commit 34d3b80

Please sign in to comment.