Commit
·
815b564
1
Parent(s):
ffda3ec
Update README.md
Browse files
README.md
CHANGED
@@ -48,6 +48,7 @@ gr.Interface.load("models/midjourney-community/midjourney-mini").launch()
|
|
48 |
|
49 |
## Deploy in Inference API
|
50 |
|
|
|
51 |
```py
|
52 |
import requests
|
53 |
|
@@ -60,6 +61,25 @@ def query(payload):
|
|
60 |
image_bytes = query({
|
61 |
"inputs": "Astronaut riding a horse",
|
62 |
})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
63 |
# You can access the image with PIL.Image for example
|
64 |
import io
|
65 |
from PIL import Image
|
|
|
48 |
|
49 |
## Deploy in Inference API
|
50 |
|
51 |
+
<h3>Python:</h3>
|
52 |
```py
|
53 |
import requests
|
54 |
|
|
|
61 |
image_bytes = query({
|
62 |
"inputs": "Astronaut riding a horse",
|
63 |
})
|
64 |
+
|
65 |
+
<h3>Javascript:</h3>
|
66 |
+
```js
|
67 |
+
async function query(data) {
|
68 |
+
const response = await fetch(
|
69 |
+
"https://api-inference.huggingface.co/models/midjourney-community/midjourney-mini",
|
70 |
+
{
|
71 |
+
headers: { Authorization: "Bearer hf_token" },
|
72 |
+
method: "POST",
|
73 |
+
body: JSON.stringify(data),
|
74 |
+
}
|
75 |
+
);
|
76 |
+
const result = await response.blob();
|
77 |
+
return result;
|
78 |
+
}
|
79 |
+
query({"inputs": "Astronaut riding a horse"}).then((response) => {
|
80 |
+
// Use image
|
81 |
+
});
|
82 |
+
```
|
83 |
# You can access the image with PIL.Image for example
|
84 |
import io
|
85 |
from PIL import Image
|