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

solution for jpegpy #57

Open
AbitGo opened this issue Jan 6, 2025 · 1 comment
Open

solution for jpegpy #57

AbitGo opened this issue Jan 6, 2025 · 1 comment

Comments

@AbitGo
Copy link

AbitGo commented Jan 6, 2025

someone meet problem as "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)"

issue:#56 (comment)

but, it is so difficult for me to compile jpegpy.so, emmmm beacause i use windows.so i give a direct solution for this problem:
1.enter the file :"CADDM-master\lib\data_preprocess\utils\jpegpy":
2.replace the following code to originial code:

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

@vikrantc672
Copy link

In lib/data_preprocess/utils/jpegpy/jpegpy.py change the code to the below code everything is fine you don't need to recompile anything

#!/usr/bin/env mdl
import cv2
import numpy as np

import cv2
import numpy as np

def jpeg_encode(img: np.array, quality=80):
from . import _jpegpy # Move import inside the function
img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
return _jpegpy.encode(img, quality)

def jpeg_decode(code: bytes):
from . import _jpegpy # Move import inside the function
img = _jpegpy.decode(code)
return cv2.cvtColor(img, cv2.COLOR_RGB2BGR)

vim: ts=4 sw=4 sts=4 expandtab

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

2 participants