sergeipetrov commited on
Commit
2a3656e
1 Parent(s): c57eb63

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +24 -15
README.md CHANGED
@@ -9,22 +9,31 @@ base_model: timbrooks/instruct-pix2pix
9
  library_name: generic
10
  ---
11
 
12
- # Fork of [timbrooks/instruct-pix2pix](https://huggingface.co/timbrooks/instruct-pix2pix) for an `image-to-image` Inference endpoint.
13
 
14
- This repository implements a `custom` task for `image-to-image` with instructions for 🤗 Inference Endpoints. The code for the customized
15
- pipeline is in the handler.py.
16
 
17
- To use deploy this model an Inference Endpoint you have to select `Custom` as task to use the `handler.py` file.
18
-
19
- ### expected Request payload
20
-
21
- ```json
22
- {
23
- "image": encoded_image,
24
- "parameters": {
25
- "candidate_labels": "green, yellow, blue, white, silver"
26
- }
27
- }
 
 
 
28
  ```
29
 
30
- `encoded_image` is a base64 encoded image.
 
 
 
 
 
 
 
 
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
+ ```