Skip to content

Circular Import Issue #21

Description

@jeffreyianwilson

I am using the demo script verbatim in VS Code with Python 3.11 and I am getting a circular import error

ImportError: cannot import name 'patchify' from partially initialized module 'patchify' (most likely due to a circular import)

import numpy as np
from PIL import Image
from patchify import patchify
   
image = Image.open("C:\\Projects\\Python\\Roboflow\\patchify.jpg")
image = np.asarray(image)
patches = patchify(image, (512, 512, 3), step=512)
print(patches.shape)  # (6, 10, 1, 512, 512, 3)

for i in range(patches.shape[0]):
    for j in range(patches.shape[1]):
        patch = patches[i, j, 0]
        patch = Image.fromarray(patch)
        num = i * patches.shape[1] + j
        patch.save(f"patch_{num}.jpg")

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions