sergeipetrov
commited on
Commit
•
2a3656e
1
Parent(s):
c57eb63
Update README.md
Browse files
README.md
CHANGED
@@ -9,22 +9,31 @@ base_model: timbrooks/instruct-pix2pix
|
|
9 |
library_name: generic
|
10 |
---
|
11 |
|
12 |
-
|
13 |
|
14 |
-
|
15 |
-
pipeline is in the handler.py.
|
16 |
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
{
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
|
|
|
|
|
|
28 |
```
|
29 |
|
30 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
library_name: generic
|
10 |
---
|
11 |
|
12 |
+
## timbrooks/instruct-pix2pix to deploy with Inference Endpoints
|
13 |
|
14 |
+
Expected payload:
|
|
|
15 |
|
16 |
+
```python
|
17 |
+
def predict(path_to_image, prompt):
|
18 |
+
with open(path_to_image, "rb") as i:
|
19 |
+
b64 = base64.b64encode(i.read()).decode()
|
20 |
+
payload = {
|
21 |
+
"inputs": {
|
22 |
+
"image": b64,
|
23 |
+
"prompt": prompt
|
24 |
+
}
|
25 |
+
}
|
26 |
+
response = r.post(
|
27 |
+
ENDPOINT_URL, json=payload, headers={"Content-Type": "application/json"}
|
28 |
+
)
|
29 |
+
return response.json()
|
30 |
```
|
31 |
|
32 |
+
Call it with:
|
33 |
+
```python
|
34 |
+
resp = predict(
|
35 |
+
path_to_image="car.png",
|
36 |
+
prompt="make the car green"
|
37 |
+
)
|
38 |
+
img = Image.open(BytesIO(base64.b64decode(resp)))
|
39 |
+
```
|