Skip to content

Circular Import Issue #21

Open
Open
@jeffreyianwilson

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

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