ImmichI
Immich6mo ago
ZZ

Using machine learning model outside Immich

Hi all, I'm running Immich in docker and have exposed the machine learning model outside the docker.

There's a predict method but does anyone know how to use it?

I see the require fields are image, entries. Is image in base 64 and what about entries?


Below is the code I used for this and the output

import base64
import requests

IMMICH_ML_URL = "http://192.168.0.108:3003/predict"

# Path to the local image file
image_path = "path"

# Read and encode the image to base64
with open(image_path, "rb") as image_file:
    image_base64 = base64.b64encode(image_file.read()).decode("utf-8")

# Prepare the request payload
form_data = {
    "image": image_base64,
    "entries": "face-detection"
}

# Send POST request
response = requests.post(IMMICH_ML_URL, data=form_data)

# Output the result
print("Status Code:", response.status_code)
print("Response:", response.json())


Output:
Status Code: 422
Response: {'detail': 'Invalid request format.'}
image.png
image.png
Was this page helpful?