-
Notifications
You must be signed in to change notification settings - Fork 182
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2959 from livepeer/ai-video
Livepeer AI Subnet
- Loading branch information
Showing
87 changed files
with
12,496 additions
and
1,147 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Default reviewers for the `ai-video` branch. | ||
# TODO: Change if merged into `master` branch. | ||
* @rickstaa |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
package ai | ||
|
||
import ( | ||
"context" | ||
"encoding/json" | ||
"errors" | ||
"os" | ||
|
||
"github.com/livepeer/ai-worker/worker" | ||
) | ||
|
||
type FileWorker struct { | ||
files map[string]string | ||
} | ||
|
||
func NewFileWorker(files map[string]string) *FileWorker { | ||
return &FileWorker{files: files} | ||
} | ||
|
||
func (w *FileWorker) TextToImage(ctx context.Context, req worker.GenTextToImageJSONRequestBody) (*worker.ImageResponse, error) { | ||
Check warning on line 20 in ai/file_worker.go
|
||
fname, ok := w.files["text-to-image"] | ||
if !ok { | ||
return nil, errors.New("text-to-image response file not found") | ||
} | ||
|
||
data, err := os.ReadFile(fname) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
var resp worker.ImageResponse | ||
if err := json.Unmarshal(data, &resp); err != nil { | ||
return nil, err | ||
} | ||
|
||
return &resp, nil | ||
} | ||
|
||
func (w *FileWorker) ImageToImage(ctx context.Context, req worker.GenImageToImageMultipartRequestBody) (*worker.ImageResponse, error) { | ||
Check warning on line 39 in ai/file_worker.go
|
||
fname, ok := w.files["image-to-image"] | ||
if !ok { | ||
return nil, errors.New("image-to-image response file not found") | ||
} | ||
|
||
data, err := os.ReadFile(fname) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
var resp worker.ImageResponse | ||
if err := json.Unmarshal(data, &resp); err != nil { | ||
return nil, err | ||
} | ||
|
||
return &resp, nil | ||
} | ||
|
||
func (w *FileWorker) ImageToVideo(ctx context.Context, req worker.GenImageToVideoMultipartRequestBody) (*worker.VideoResponse, error) { | ||
Check warning on line 58 in ai/file_worker.go
|
||
fname, ok := w.files["image-to-video"] | ||
if !ok { | ||
return nil, errors.New("image-to-video response file not found") | ||
} | ||
|
||
data, err := os.ReadFile(fname) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
var resp worker.VideoResponse | ||
if err := json.Unmarshal(data, &resp); err != nil { | ||
return nil, err | ||
} | ||
|
||
return &resp, nil | ||
} | ||
|
||
func (w *FileWorker) Upscale(ctx context.Context, req worker.GenUpscaleMultipartRequestBody) (*worker.ImageResponse, error) { | ||
Check warning on line 77 in ai/file_worker.go
|
||
fname, ok := w.files["upscale"] | ||
if !ok { | ||
return nil, errors.New("upscale response file not found") | ||
} | ||
|
||
data, err := os.ReadFile(fname) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
var resp worker.ImageResponse | ||
if err := json.Unmarshal(data, &resp); err != nil { | ||
return nil, err | ||
} | ||
|
||
return &resp, nil | ||
} | ||
|
||
func (w *FileWorker) Warm(ctx context.Context, containerName, modelID string) error { | ||
Check warning on line 96 in ai/file_worker.go
|
||
return nil | ||
} | ||
|
||
func (w *FileWorker) Stop(ctx context.Context, containerName string) error { | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.