Deep-Live-Cam
Deep-Live-Cam copied to clipboard
IndenationError: Unexpected indent
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
The indentation in the Python code is incorrect. modules/__init__.py
The indentation in the Python code is incorrect. modules/init.py forgive me for being clueless but what should I do?
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
thank you so much!
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
This was fixed in #1268.