Deep-Live-Cam icon indicating copy to clipboard operation
Deep-Live-Cam copied to clipboard

IndenationError: Unexpected indent

Open sebbyjelly opened this issue 6 months ago • 5 comments

I have a feeling this may be a super easy fix but I dont code and I thought I followed all the instructions so I'm very confused! Couldnt find anyone else with this exact same problem.

(my_venv) janedoe Deep-Live-Cam % python run.py Traceback (most recent call last): File "/Users/janedoe/Deep-Live-Cam/run.py", line 3, in from modules import core File "/Users/janedoe/Deep-Live-Cam/modules/init.py", line 16 encoded_img.tofile(path) IndentationError: unexpected indent (my_venv) janedoe Deep-Live-Cam %

sebbyjelly avatar May 12 '25 13:05 sebbyjelly

The indentation in the Python code is incorrect. modules/__init__.py

WiratNR avatar May 12 '25 13:05 WiratNR

The indentation in the Python code is incorrect. modules/init.py forgive me for being clueless but what should I do?

sebbyjelly avatar May 12 '25 13:05 sebbyjelly

I only fixed it enough to make it run. We’ll wait for the expert to review it.

import os
import cv2
import numpy as np

# Utility function to support unicode characters in file paths for reading


def imread_unicode(path, flags=cv2.IMREAD_COLOR):
    return cv2.imdecode(np.fromfile(path, dtype=np.uint8), flags)

# Utility function to support unicode characters in file paths for writing


def imwrite_unicode(path, img, params=None):
    root, ext = os.path.splitext(path)
    if not ext:
        ext = ".png"
    # result, encoded_img = cv2.imencode(ext, img, params if params else [])
    result, encoded_img = cv2.imencode(
        f".{ext}", img, params if params is not None else [])
    encoded_img.tofile(path)
    return True
    # return False

WiratNR avatar May 12 '25 13:05 WiratNR

thank you so much!

sebbyjelly avatar May 12 '25 13:05 sebbyjelly

this seems to be a better solution

def imwrite_unicode(path, img, params=None):
    root, ext = os.path.splitext(path)
    if not ext:
        ext = ".png"
    result, encoded_img = cv2.imencode(f".{ext}", img, params if params is not None else [])
    if result:  # Ensure encoding was successful
        encoded_img.tofile(path)
        return True
    return False

Iamfavur avatar May 12 '25 14:05 Iamfavur

This was fixed in #1268.

moritzschmitz-oviva avatar May 13 '25 08:05 moritzschmitz-oviva