File size: 806 Bytes
f076f26
 
 
 
 
 
 
 
 
 
 
2a3656e
f076f26
2a3656e
f076f26
2a3656e
 
 
 
 
6ec8056
 
2a3656e
 
 
 
 
 
 
f076f26
 
2a3656e
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
---
tags:
  - vision
  - image-to-image
  - endpoints-template
inference: false
pipeline_tag: image-to-image
base_model: timbrooks/instruct-pix2pix
library_name: generic
---

## timbrooks/instruct-pix2pix to deploy with Inference Endpoints

Expected payload:

```python
def predict(path_to_image, prompt):
    with open(path_to_image, "rb") as i:
        b64 = base64.b64encode(i.read()).decode()
    payload = {
        "inputs": b64,
        "parameters": { 
            "prompt": prompt
        }
    }
    response = r.post(
        ENDPOINT_URL, json=payload, headers={"Content-Type": "application/json"}
    )
    return response.json()
```

Call it with:
```python
resp = predict(
    path_to_image="car.png", 
    prompt="make the car green"
)
img = Image.open(BytesIO(base64.b64decode(resp)))
```