Node.js / Browser
const res = await fetch("https://nsfw.mitecorp.web.id/classify", {
method: "POST",
headers: { "Content-Type": "application/octet-stream" },
body: imageBlobOrBuffer,
});
const { prediction } = await res.json();
Hasil klasifikasi akan tampil setelah gambar diupload.
Detail lima kelas prediksi akan muncul di sini.
Consume API
Kirim binary gambar langsung ke endpoint klasifikasi menggunakan metode POST dan header Content-Type: application/octet-stream. Response JSON berisi array prediction.
const res = await fetch("https://nsfw.mitecorp.web.id/classify", {
method: "POST",
headers: { "Content-Type": "application/octet-stream" },
body: imageBlobOrBuffer,
});
const { prediction } = await res.json();
import requests
with open("image.jpg", "rb") as f:
resp = requests.post(
"https://nsfw.mitecorp.web.id/classify",
data=f,
headers={"Content-Type": "application/octet-stream"},
)
print(resp.json()["prediction"])
# [{ className: "Neutral", probability: 0.637 }, ...]
http POST https://nsfw.mitecorp.web.id/classify \
Content-Type:application/octet-stream \
@image.jpg
curl -X POST \
-H "Content-Type: application/octet-stream" \
--data-binary @image.jpg \
https://nsfw.mitecorp.web.id/classify