|
1 | 1 | # replicate-cli |
2 | | -Command line interface for the Replicate API, powered by Go. |
| 2 | +Command line interface for the [Replicate API](https://replicate.com/docs/reference/http), powered by Go. |
3 | 3 |
|
4 | | -### Version 0.1.0 - Experimental Support |
| 4 | +Run open source AI models from the command line using [Replicate.com's](https://replicate.com) hardware. |
5 | 5 |
|
6 | | -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.** |
| 6 | +## Features |
| 7 | + |
| 8 | +Version 0.2.2 - Expanded model support + chaining |
| 9 | + |
| 10 | +* Run models |
| 11 | +* Chaining: pass the output of one model to another replicate command |
| 12 | +* URL or Local file support |
| 13 | +* Get model info |
| 14 | +* Get model input parameters |
| 15 | +* Get model versions |
7 | 16 |
|
8 | 17 | ## Requirements |
9 | 18 | * Go 1.19 |
10 | 19 | * Replicate API Token, [get yours here](https://replicate.com/account). |
11 | 20 |
|
12 | | -## Install, Build & Run |
| 21 | +## Installation |
13 | 22 |
|
14 | 23 | ### Install |
| 24 | +[go](https://go.dev/dl/) is required. |
15 | 25 | ``` |
16 | | -go install github.com/jamiesteven/replicate-cli@latest |
| 26 | +go install github.com/jamiesteven/replicate-cli/cmd/replicate@latest |
17 | 27 | ``` |
18 | 28 |
|
19 | 29 | ### Run |
20 | 30 | ``` |
21 | | -replicate-cli |
| 31 | +replicate |
22 | 32 | ``` |
23 | 33 |
|
24 | 34 | ### Uninstall |
25 | 35 | ``` |
26 | | -rm $GOPATH/bin/replicate-cli |
| 36 | +rm $GOPATH/bin/replicate |
27 | 37 | ``` |
28 | 38 |
|
29 | | -## How to use |
| 39 | +## Usage |
30 | 40 |
|
31 | 41 | ### Authentication |
32 | | -The Replicate API requires an API token. [Get one here.](https://replicate.com/account). |
| 42 | +The Replicate API requires an API token. [Get one here.](https://replicate.com/account) |
33 | 43 |
|
34 | 44 | Set a ```REPLICATE_TOKEN``` environment variable, or use ```--token <your key here>```. |
35 | 45 | ``` |
36 | | -replicate-cli --token <your key here> |
| 46 | +replicate --token <your key here> |
37 | 47 | ``` |
38 | 48 |
|
39 | | -### Get model versions |
| 49 | +### Input Parameters |
| 50 | +Input parameters use the [shorthand](https://github.com/danielgtaylor/shorthand) format, separated by comma. |
40 | 51 | ``` |
41 | | -replicate-cli versions jingyunliang/swinir |
| 52 | +image:https://picsum.photos/512/512, fidelity:0.4 |
42 | 53 | ``` |
43 | 54 |
|
44 | | -### Run a model |
| 55 | +### run: run a model |
| 56 | +``` |
| 57 | +replicate run [model] [inputs] |
| 58 | +``` |
| 59 | + |
| 60 | +#### Run a model with parameter input |
| 61 | +``` |
| 62 | +replicate run stability-ai/stable-diffusion prompt:photo of a cat |
| 63 | +``` |
45 | 64 |
|
46 | | -**Run using model name.** replicate-cli will use the latest version. |
| 65 | +#### Run a model using an image URL |
47 | 66 | ``` |
48 | | -replicate-cli run jingyunliang/swinir [input] |
| 67 | +replicate run jingyunliang/swinir image:https://picsum.photos/512/512 |
49 | 68 | ``` |
50 | | -Input currently supports a fully qualified domain-name. |
51 | 69 |
|
52 | | -**Run using version ID.** |
| 70 | +#### Run a model using using a local image |
53 | 71 | ``` |
54 | | -replicate-cli run jingyunliang/swinir |
| 72 | +replicate run jingyunliang/swinir image:/path/to/file.png |
| 73 | +``` |
| 74 | + |
| 75 | +### Chaining: run multiple AI models in succession |
| 76 | +Pipe the output of one replicate command to another: |
| 77 | +``` |
| 78 | +replicate run stability-ai/stable-diffusion prompt:photo of a smiling person \ |
| 79 | +| replicate run jingyunliang/swinir image: \ |
| 80 | +| replicate run sczhou/codeformer codeformer_fidelity:0.4, upscale:1, image: |
| 81 | +``` |
| 82 | + |
| 83 | +### info: get model info |
| 84 | +``` |
| 85 | +replicate info [model] |
| 86 | +
|
| 87 | +replicate info stability-ai/stable-diffusion |
| 88 | +``` |
| 89 | + |
| 90 | +### inputs: get inputs for a specific model |
| 91 | +``` |
| 92 | +replicate inputs [model] [?version] |
| 93 | +
|
| 94 | +replicate inputs jingyunliang/swinir |
| 95 | +
|
| 96 | +replicate inputs jingyunliang/swinir 9d91795e944f3a585fa83f749617fc75821bea8b323348f39cf84f8fd0cbc2f7 |
| 97 | +``` |
| 98 | + |
| 99 | +### versions: get versions for a specific model |
| 100 | +``` |
| 101 | +replicate versions [model] |
| 102 | +
|
| 103 | +replicate versions jingyunliang/swinir |
55 | 104 | ``` |
56 | 105 |
|
57 | 106 | ## Development |
58 | | -Pull requests welcome! replicate-cli is built using [Cobra](https://cobra.dev). |
| 107 | +Pull requests welcome! |
| 108 | + |
| 109 | +## Credits |
| 110 | + |
| 111 | +replicate-cli uses the following packages: |
59 | 112 |
|
60 | | ---- |
| 113 | +* [cobra](https://github.com/spf13/cobra) |
| 114 | +* [shorthand](https://github.com/danielgtaylor/shorthand) |
| 115 | +* [resty](https://github.com/go-resty/resty) |
| 116 | +* [gjson](https://github.com/tidwall/gjson) |
| 117 | +* [tablewritter](https://github.com/olekukonko/tablewriter) |
| 118 | +* [spinner](https://github.com/briandowns/spinner) |
61 | 119 |
|
62 | 120 | **Copyright (c) 2022 Jamie Steven. Licensed Under Apache 2.0.** |
0 commit comments