-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
992c729
commit 9b38a03
Showing
22 changed files
with
1,299 additions
and
211 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 |
---|---|---|
|
@@ -17,5 +17,5 @@ vendor/ | |
# Go workspace file | ||
go.work | ||
|
||
# Binary | ||
replicate | ||
# Misc | ||
.DS_Store |
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 |
---|---|---|
@@ -1,62 +1,120 @@ | ||
# replicate-cli | ||
Command line interface for the Replicate API, powered by Go. | ||
Command line interface for the [Replicate API](https://replicate.com/docs/reference/http), powered by Go. | ||
|
||
### Version 0.1.0 - Experimental Support | ||
Run open source AI models from the command line using [Replicate.com's](https://replicate.com) hardware. | ||
|
||
Run models and retrieves model version IDs. See TODO for proposed feature list. Currently only supports models that accept a single "image" input. **Note: Stable Diffusion and other text input models are not yet supported, but will be soon. Executable name may change to replicate, from replicate-cli.** | ||
## Features | ||
|
||
Version 0.2.2 - Expanded model support + chaining | ||
|
||
* Run models | ||
* Chaining: pass the output of one model to another replicate command | ||
* URL or Local file support | ||
* Get model info | ||
* Get model input parameters | ||
* Get model versions | ||
|
||
## Requirements | ||
* Go 1.19 | ||
* Replicate API Token, [get yours here](https://replicate.com/account). | ||
|
||
## Install, Build & Run | ||
## Installation | ||
|
||
### Install | ||
[go](https://go.dev/dl/) is required. | ||
``` | ||
go install github.com/jamiesteven/replicate-cli@latest | ||
go install github.com/jamiesteven/replicate-cli/cmd/replicate@latest | ||
``` | ||
|
||
### Run | ||
``` | ||
replicate-cli | ||
replicate | ||
``` | ||
|
||
### Uninstall | ||
``` | ||
rm $GOPATH/bin/replicate-cli | ||
rm $GOPATH/bin/replicate | ||
``` | ||
|
||
## How to use | ||
## Usage | ||
|
||
### Authentication | ||
The Replicate API requires an API token. [Get one here.](https://replicate.com/account). | ||
The Replicate API requires an API token. [Get one here.](https://replicate.com/account) | ||
|
||
Set a ```REPLICATE_TOKEN``` environment variable, or use ```--token <your key here>```. | ||
``` | ||
replicate-cli --token <your key here> | ||
replicate --token <your key here> | ||
``` | ||
|
||
### Get model versions | ||
### Input Parameters | ||
Input parameters use the [shorthand](https://github.com/danielgtaylor/shorthand) format, separated by comma. | ||
``` | ||
replicate-cli versions jingyunliang/swinir | ||
image:https://picsum.photos/512/512, fidelity:0.4 | ||
``` | ||
|
||
### Run a model | ||
### run: run a model | ||
``` | ||
replicate run [model] [inputs] | ||
``` | ||
|
||
#### Run a model with parameter input | ||
``` | ||
replicate run stability-ai/stable-diffusion prompt:photo of a cat | ||
``` | ||
|
||
**Run using model name.** replicate-cli will use the latest version. | ||
#### Run a model using an image URL | ||
``` | ||
replicate-cli run jingyunliang/swinir [input] | ||
replicate run jingyunliang/swinir image:https://picsum.photos/512/512 | ||
``` | ||
Input currently supports a fully qualified domain-name. | ||
|
||
**Run using version ID.** | ||
#### Run a model using using a local image | ||
``` | ||
replicate-cli run jingyunliang/swinir | ||
replicate run jingyunliang/swinir image:/path/to/file.png | ||
``` | ||
|
||
### Chaining: run multiple AI models in succession | ||
Pipe the output of one replicate command to another: | ||
``` | ||
replicate run stability-ai/stable-diffusion prompt:photo of a smiling person \ | ||
| replicate run jingyunliang/swinir image: \ | ||
| replicate run sczhou/codeformer codeformer_fidelity:0.4, upscale:1, image: | ||
``` | ||
|
||
### info: get model info | ||
``` | ||
replicate info [model] | ||
replicate info stability-ai/stable-diffusion | ||
``` | ||
|
||
### inputs: get inputs for a specific model | ||
``` | ||
replicate inputs [model] [?version] | ||
replicate inputs jingyunliang/swinir | ||
replicate inputs jingyunliang/swinir 9d91795e944f3a585fa83f749617fc75821bea8b323348f39cf84f8fd0cbc2f7 | ||
``` | ||
|
||
### versions: get versions for a specific model | ||
``` | ||
replicate versions [model] | ||
replicate versions jingyunliang/swinir | ||
``` | ||
|
||
## Development | ||
Pull requests welcome! replicate-cli is built using [Cobra](https://cobra.dev). | ||
Pull requests welcome! | ||
|
||
## Credits | ||
|
||
replicate-cli uses the following packages: | ||
|
||
--- | ||
* [cobra](https://github.com/spf13/cobra) | ||
* [shorthand](https://github.com/danielgtaylor/shorthand) | ||
* [resty](https://github.com/go-resty/resty) | ||
* [gjson](https://github.com/tidwall/gjson) | ||
* [tablewritter](https://github.com/olekukonko/tablewriter) | ||
* [spinner](https://github.com/briandowns/spinner) | ||
|
||
**Copyright (c) 2022 Jamie Steven. Licensed Under Apache 2.0.** |
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 |
---|---|---|
@@ -1,20 +1,40 @@ | ||
v0.1.0 | ||
v0.1.x | ||
Experimental support | ||
Code cleanup | ||
Document code where needed | ||
Publish to GitHub with license | ||
"Release in GitHub" | ||
|
||
v0.2.0 | ||
Support text models, like Stable Diffusion | ||
Support models with unique inputs using via flags or arguments | ||
Add local file support as image input | ||
Save output to local file | ||
Consider normalizing model output (always wrap in JSON?) | ||
v0.2.x | ||
Change to 'replicate' as primary command, from 'replicate-cli' | ||
run command: run a model | ||
Support most models with command line parameter support | ||
Shorthand support for inputting parameters using https://github.com/danielgtaylor/shorthand | ||
Command chaining: run commands supports piping input from one replicate command to another | ||
Support local file as image input | ||
Normalize model output to output as a standardized URL | ||
Improved waiting indicator | ||
info command: get info about models | ||
input command: get the inputs for a specific model | ||
Normalize errors | ||
Add known issues | ||
Give credit to primary packages | ||
|
||
v0.? | ||
Tests? | ||
Improved documentation? | ||
Packagecloud binary support? | ||
v0.3.0 (or later) | ||
Optionally save output to local file | ||
Explore support for non-image models, like Whisper | ||
start command - run model asynchronously | ||
predictions command - list, view and stop predictions | ||
models/collections command - list and view models | ||
Provide shorthand input examples for each model | ||
Improved documentation for each command | ||
Notate required fields on inputs | ||
Pre-compiled binary support (Packagecloud, Homebrew tap, etc) | ||
Tests | ||
|
||
Known issues: | ||
Currently does not support the output of multiple images; Replicate API issue? | ||
Does not support image URL paths that includes commas - shorthand uses commas to delineate args | ||
|
||
Notes: | ||
Suggest Replicate team return 404 for https://api.replicate.com/v1/predictions on non-existant version IDs | ||
Suggest Replicate team return 404 for https://api.replicate.com/v1/predictions on non-existent version IDs |
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,9 @@ | ||
package main | ||
|
||
import ( | ||
cmd "github.com/jamiesteven/replicate-cli/internal/cmd" | ||
) | ||
|
||
func main() { | ||
cmd.Execute() | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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.