Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ImportError #56

Open
langhua11 opened this issue Dec 15, 2024 · 3 comments
Open

ImportError #56

langhua11 opened this issue Dec 15, 2024 · 3 comments

Comments

@langhua11
Copy link

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)
出现这个报错怎么修改

@healer-hub
Copy link

+1

@langhua11
Copy link
Author

+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()

这个就可以了

@AbitGo
Copy link

AbitGo commented Jan 6, 2025

-- 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants