Skip to content

Commit

Permalink
Update recommendations for passing file inputs to models (#315)
Browse files Browse the repository at this point in the history
Signed-off-by: Mattt Zmuda <mattt@replicate.com>
  • Loading branch information
mattt authored Jun 28, 2024
1 parent a78cc1e commit b86aca7
Showing 1 changed file with 14 additions and 15 deletions.
29 changes: 14 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,21 +54,7 @@ replicate.run(
)
```

Some models, like [andreasjansson/blip-2](https://replicate.com/andreasjansson/blip-2), have files as inputs.
To run a model that takes a file input,
pass a URL to a publicly accessible file.
Or, for smaller files (<10MB), you can pass a file handle directly.

```python
>>> output = replicate.run(
"andreasjansson/blip-2:f677695e5e89f8b236e52ecd1d3f01beb44c34606419bcc19345e046d8f786f9",
input={ "image": open("path/to/mystery.jpg") }
)

"an astronaut riding a horse"
```

> [!NOTE]
> [!TIP]
> You can also use the Replicate client asynchronously by prepending `async_` to the method name.
>
> Here's an example of how to run several predictions concurrently and wait for them all to complete:
Expand All @@ -94,6 +80,19 @@ Or, for smaller files (<10MB), you can pass a file handle directly.
> print(results)
> ```
To run a model that takes a file input you can pass either
a URL to a publicly accessible file on the Internet
or a handle to a file on your local device.
```python
>>> output = replicate.run(
"andreasjansson/blip-2:f677695e5e89f8b236e52ecd1d3f01beb44c34606419bcc19345e046d8f786f9",
input={ "image": open("path/to/mystery.jpg") }
)
"an astronaut riding a horse"
```
## Run a model and stream its output

Replicate’s API supports server-sent event streams (SSEs) for language models.
Expand Down

0 comments on commit b86aca7

Please sign in to comment.