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

ImagePool fix #2

Closed
zhufeida opened this issue May 7, 2017 · 1 comment
Closed

ImagePool fix #2

zhufeida opened this issue May 7, 2017 · 1 comment

Comments

@zhufeida
Copy link

zhufeida commented May 7, 2017

class ImagePool(object): 
    def __init__(self, maxsize=50):
        self.maxsize = maxsize
        self.num_img = 0
        self.images = []
    def __call__(self, image):
        if self.maxsize == 0:
            return image
        if self.num_img < self.maxsize:
            self.images.append(image)
            self.num_img=self.num_img+1  //It seems you forgot this line
            return image
        if np.random.rand() > 0.5:
            idx = int(np.random.rand()*self.maxsize)
            tmp = copy.copy(self.images[idx])
            self.images[idx] = image
            return tmp
        else:
            return image
@xiaowei-hu
Copy link
Owner

Thank you for your help. I have fixed the bug in the latest commit.

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