AayushKrChaudhary / RITnet

This is a winning model of OpenEDS Semantic Segmentation Challenge
MIT License
73 stars 28 forks source link

TypeError: cannot pickle 'cv2.CLAHE' object #12

Closed BILLXZY1215 closed 1 year ago

BILLXZY1215 commented 1 year ago

Hi, I'm trying to run test.py as the README suggested: python test.py --model densenet --load best_model.pkl --bs 4 --dataset data/, I just changed the dataset into my own images (already resized to 640*400), however I'm getting this error:

Traceback (most recent call last):
  File "test.py", line 59, in <module>
    for i, batchdata in tqdm(enumerate(testloader),total=len(testloader)):
... ... 
TypeError: cannot pickle 'cv2.CLAHE' object

P.S. I'm using PyTorch CPU Version, but since it is an opencv problem, any workaround here? Thanks.

Or only CUDA can work well?

BILLXZY1215 commented 1 year ago

Figured out. We should not clarify clahe in __init__ function of dataset.py.

Change this into __getitem__ function:

clahe = cv2.createCLAHE(clipLimit=1.5, tileGridSize=(8,8))

img = clahe.apply(np.array(np.uint8(pilimg)))