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

Make images as condition not text #5

Open
sapkun opened this issue Mar 1, 2024 · 1 comment
Open

Make images as condition not text #5

sapkun opened this issue Mar 1, 2024 · 1 comment

Comments

@sapkun
Copy link

sapkun commented Mar 1, 2024

great job! I have a question that is ok that make images as condition instead of text? for example, as for original dataset the dataset structure is like this:

fill50k/train.jsonl
fill50k/images/X.png
fill50k/conditioning_images/X.png

can i use the conditioning_images as condition, and change the relevent part of the code in here:

class MyDataset(Dataset):
    def __init__(self):
        self.data = []
        with open('./training/cfill50k/prompt.json', 'rt') as f:
            for line in f:
                self.data.append(json.loads(line))

    def __len__(self):
        return len(self.data)

    def __getitem__(self, idx):
        item = self.data[idx]

        image_filename = item['image']
        source = item['source']
        target = item['target']

        image = cv2.imread('./training/cfill50k/' + image_filename)

        # Do not forget that OpenCV read images in BGR order.
        image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)

        image = (image.astype(np.float32) / 127.5) - 1.0

        return dict(jpg=image, source=source, txt=target)

Thank you!

@XiaMu799
Copy link

Hello, have you solved this problem?

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