vale46n1/immich_duplicate_finder

Cannot connect to immich server

fir3drag0n opened this issue ยท 15 comments

If I try to connect to my server with FAISS Index/DB, I always get this result:

HTTP error occurred: 404 Client Error: Not Found for url: https://ABCDEF.duckdns.org/api/asset/
HTTP error occurred: 404 Client Error: Not Found for url: https://ABCDEF.duckdns.org/api/asset/

Docker is unhealty and reports this:

 You can now view your Streamlit app in your browser.

0.0%
0.0%
0.0%
0.0%
0.0%
0.0%
0.0%
0.0%
0.0%
0.0%
0.0%
0.0%
0.0%
0.0%
0.1%
0.1%
0.1%
0.1%
0.1%
0.1%
0.1%
0.1%
0.1%
0.1%
0.1%
0.1%
0.1%
0.1%
0.1%
0.1%
0.1%
0.1%
0.1%
0.1%
0.1%
0.1%
0.1%
0.1%
0.1%
0.1%
0.1%
0.1%
0.1%
0.1%
0.2%
0.2%
0.2%
0.2%
0.2%
0.2%
0.2%
0.2%
0.2%
0.2%
0.2%
0.2%
0.2%
0.2%
0.2%
0.2%
0.2%
0.2%
0.2%
0.2%
0.2%
0.2%
0.2%
0.2%
0.2%
0.2%
0.2%
0.2%
0.2%
0.3%
0.3%
0.3%
0.3%
0.3%
0.3%
0.3%
0.3%
0.3%
0.3%
0.3%
0.3%
0.3%
0.3%
0.3%
0.3%
0.3%
0.3%
0.3%
0.3%
0.3%
0.3%
0.3%
0.3%
0.3%
0.3%
0.3%
0.3%
0.3%
0.3%
0.4%
0.4%
0.4%
0.4%
0.4%
0.4%
0.4%
0.4%
0.4%
0.4%
0.4%
0.4%
0.4%
0.4%
0.4%
0.4%
0.4%
0.4%
0.4%
0.4%
0.4%
0.4%
0.4%
0.4%
0.4%
0.4%
0.4%
0.4%
0.4%
0.5%
0.5%
0.5%
0.5%
0.5%
0.5%
0.5%
0.5%
0.5%
0.5%
0.5%
0.5%
0.5%
0.5%
0.5%
0.5%
[...]
100.0%
100.0%
100.0%
100.0%
/usr/local/lib/python3.12/site-packages/urllib3/connectionpool.py:1099: InsecureRequestWarning: Unverified HTTPS request is being made to host 'ABCDEF.duckdns.org'. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#tls-warnings
  warnings.warn(
Downloading: "https://download.pytorch.org/models/resnet152-f82ba261.pth" to /root/.cache/torch/hub/checkpoints/resnet152-f82ba261.pth

I use nginx proxy manager, but what I need to do in order to get it running?

same issue here, except not using docker.

Getting that same error โ€“ HTTP error occurred: 404 Client Error: Not Found for url: https://localIP:PORT/api/asset/ but my docker logs look clean.

Edit: I didn't know this feature (duplicate detection / deletion) had been rolled into immich in version 1.106.1.

Similar problem here, immich/duplicate finder running in docker on same machine:

HTTP error occurred: 404 Client Error: Not Found for url: http://192.168.178.2:2283/api/asset/

Can access immich with that url (of course minus /api/asset)

I am getting exactly same error, immich version v1.111.0

HTTP error occurred: 404 Client Error: Not Found for url: http://192.168.XX.XX:2283/api/asset/ No assets found or failed to fetch assets.

Same error here

Same here :-(

Getting the same error.

Same error with the latest Immich and freshly built immich_duplicate_finder. I think the Immich API changed.

as a personal temporary solution for myself:
Comment out the 'fetchAssets' method in 'api.py' and add the following code:

@st.cache_data(show_spinner=True) 
def fetchAssets(immich_server_url, api_key, timeout, type):
    if 'fetch_message' not in st.session_state:
        st.session_state['fetch_message'] = ""
    message_placeholder = st.empty()

    assets = []

    base_url = immich_server_url.rstrip('/')
    asset_paths_url = f"{base_url}/api/view/folder/unique-paths"
    asset_info_url = f"{base_url}/api/view/folder"

    response = requests.get(asset_paths_url, headers={'Accept': 'application/json', 'x-api-key': api_key}, verify=False, timeout=timeout)
    response.raise_for_status()
    if response.status_code == 200:
        paths = response.json()
    else:
        st.session_state['fetch_message'] = 'Received an empty response.'
        paths = []

    for path in paths:
        if path:
            response = requests.get(f'{asset_info_url}?path={path}', headers={'Accept': 'application/json', 'x-api-key': api_key}, verify=False, timeout=timeout)
            if response.status_code == 200:
                assets.extend(response.json())
    
    assets = [asset for asset in assets if asset.get("type") == type]                       
    st.session_state['fetch_message'] = 'Assets fetched successfully!'
    message_placeholder.text(st.session_state['fetch_message'])

    return assets

update: 2024-10-06

modify the getImage function.
find:

response = requests.request("GET", f"{immich_server_url}/api/asset/thumbnail/{asset_id}?format=JPEG", headers={'Accept': 'application/octet-stream','x-api-key': api_key}, data={})

replace:

response = requests.request("GET", f"{immich_server_url}/api/assets/{asset_id}/thumbnail?size=thumbnail", headers={'Accept': 'application/octet-stream','x-api-key': api_key}, data={})

as a personal temporary solution for myself:
Comment out the 'fetchAssets' method in 'api.py' and add the following code:

@st.cache_data(show_spinner=True) 
def fetchAssets(immich_server_url, api_key, timeout, type):
    if 'fetch_message' not in st.session_state:
        st.session_state['fetch_message'] = ""
    message_placeholder = st.empty()

    assets = []

    base_url = immich_server_url.rstrip('/')
    asset_paths_url = f"{base_url}/api/view/folder/unique-paths"
    asset_info_url = f"{base_url}/api/view/folder"

    response = requests.get(asset_paths_url, headers={'Accept': 'application/json', 'x-api-key': api_key}, verify=False, timeout=timeout)
    response.raise_for_status()
    if response.status_code == 200:
        paths = response.json()
    else:
        st.session_state['fetch_message'] = 'Received an empty response.'
        paths = []

    for path in paths:
        if path:
            response = requests.get(f'{asset_info_url}?path={path}', headers={'Accept': 'application/json', 'x-api-key': api_key}, verify=False, timeout=timeout)
            if response.status_code == 200:
                assets.extend(response.json())
    
    assets = [asset for asset in assets if asset.get("type") == type]                       
    st.session_state['fetch_message'] = 'Assets fetched successfully!'
    message_placeholder.text(st.session_state['fetch_message'])

    return assets

Hey mine gives me this error repeatedly for all assets running that fix, any ideas?
2024-10-05 13:41:17 Skipping non-image asset_id 745fd3c9-7170-4313-9b95-51a8e7cddaa2 with Content-Type: application/json; charset=utf-8

Hey mine gives me this error repeatedly for all assets running that fix, any ideas? 2024-10-05 13:41:17 Skipping non-image asset_id 745fd3c9-7170-4313-9b95-51a8e7cddaa2 with Content-Type: application/json; charset=utf-8

Please check if the API output is in image format based on your ID:
https://yourdomain/api/assets/745fd3c9-7170-4313-9b95-51a8e7cddaa2
This should output a JSON containing originalMimeType: image/jpeg
If the originalMimeType is indeed application/json, please check if a non-image file was uploaded.

Hey mine gives me this error repeatedly for all assets running that fix, any ideas? 2024-10-05 13:41:17 Skipping non-image asset_id 745fd3c9-7170-4313-9b95-51a8e7cddaa2 with Content-Type: application/json; charset=utf-8

Please check if the API output is in image format based on your ID: https://yourdomain/api/assets/745fd3c9-7170-4313-9b95-51a8e7cddaa2 This should output a JSON containing originalMimeType: image/jpeg If the originalMimeType is indeed application/json, please check if a non-image file was uploaded.

Hmm I tested a few from the error but they are all image/jpeg and not application/json. Not sure why it's erroring out
"originalMimeType": "image/jpeg",

Hmm I tested a few from the error but they are all image/jpeg and not application/json. Not sure why it's erroring out "originalMimeType": "image/jpeg",

OMG, It's my fault, I forgot that I had modified a function, and the relevant changes have been updated in the previous reply.

update: 2024-10-06

Hey I got this working but had to update two more lines to get the deleting to work. See below to remove the "-" and add the "+" line in the api.py.
deleteAsset method
-url = f"{immich_server_url}/api/asset"
+url = f"{immich_server_url}/api/assets"
updateAsset method
-url = f"{immich_server_url}/api/asset/{asset_id}" # Ensure the URL is constructed correctly
+url = f"{immich_server_url}/api/assets/{asset_id}" # Ensure the URL is constructed correctly

Hey I got this working but had to update two more lines to get the deleting to work. See below to remove the "-" and add the "+" line in the api.py. deleteAsset method -url = f"{immich_server_url}/api/asset" +url = f"{immich_server_url}/api/assets" updateAsset method -url = f"{immich_server_url}/api/asset/{asset_id}" # Ensure the URL is constructed correctly +url = f"{immich_server_url}/api/assets/{asset_id}" # Ensure the URL is constructed correctly

I have an overwhelming number of files, and I'm still in the process of updating the index ๐Ÿ˜ฎโ€๐Ÿ’จ, so I haven't been able to spot the remaining issues. I'm glad you can fix them.