CADDM icon indicating copy to clipboard operation
CADDM copied to clipboard

ImportError

Open langhua11 opened this issue 1 year ago • 3 comments

ImportError: cannot import name '_jpegpy' from partially initialized module 'lib.data_preprocess.utils.jpegpy' (most likely due to a circular import) (/home/dancer/project_xm/CADDM-master/lib/data_preprocess/utils/jpegpy/init.py) 出现这个报错怎么修改

langhua11 avatar Dec 15 '24 13:12 langhua11

+1

healer-hub avatar Jan 02 '25 14:01 healer-hub

+1

all = ['jpeg_encode', 'jpeg_decode']

def jpeg_encode(): from .jpegpy import jpeg_encode return jpeg_encode()

def jpeg_decode(): from .jpegpy import jpeg_decode return jpeg_decode()

这个就可以了

langhua11 avatar Jan 03 '25 02:01 langhua11

-- coding: utf-8 --

$File: init.py

$Author: Xinyu Zhou [email protected]

Copyright (c) 2015 Megvii Inc. All rights reserved.

from .jpegpy import jpeg_encode, jpeg_decode

import numpy as np

# all = ['jpeg_encode', 'jpeg_decode']

all = ['jpeg_encode', 'jpeg_decode']

def jpeg_encode(img: np.array, quality=80):

from .jpegpy import jpeg_encode

return jpeg_encode(img,quality=quality)

def jpeg_decode(code: bytes):

from .jpegpy import jpeg_decode

return jpeg_decode(code)

vim: foldmethod=marker

import imageio import numpy as np from io import BytesIO

def jpeg_encode(img: np.array, quality=80): img_byte_arr = BytesIO() imageio.imwrite(img_byte_arr, img, format='JPEG', quality=quality) return img_byte_arr.getvalue()

def jpeg_decode(code: bytes): img = imageio.imread(code) return img

actually,u can replace the author's method(JPEGLib/cpp) to imageio(python) and it can use directly

AbitGo avatar Jan 06 '25 06:01 AbitGo