File size: 1,816 Bytes
319886d
 
 
 
 
 
 
 
 
 
 
 
af44a4b
 
 
 
 
 
319886d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import os
from data.prefix_instruction import get_image_prompt, get_task_instruction, get_layout_instruction, get_content_instruction
import random
from PIL import Image


task_instruction = "Each row shows a virtual try-on process that aims to put [IMAGE2] the clothing onto [IMAGE1] the person, producing [IMAGE3] the person wearing the new clothing."
content_instruction = ""
tryon = [
    dict(
        name='Virtual Try-On', 
        images=[
            os.path.join('examples/examples/tryon/00700_00.jpg'),
            os.path.join('examples/examples/tryon/03673_00.jpg'),
            os.path.join('examples/examples/tryon/00700_00_tryon_catvton_0.jpg'),
            os.path.join('examples/examples/tryon/00555_00.jpg'),
            os.path.join('examples/examples/tryon/12265_00.jpg'),
            os.path.join('examples/examples/tryon/00555_00_tryon_catvton_0.jpg'),
        ], 
        grid_h=2,
        grid_w=3,
        task_prompt=task_instruction, 
        content_prompt=content_instruction,
    ),
]
tryon_text = [[x['name']] for x in tryon]


def process_tryon_tasks(x):
    for task in tryon:
        if task['name'] == x[0]:
            task_prompt = task['task_prompt']
            content_prompt = task['content_prompt']

            images = task['images']
            rets = []
            for image in images:
                rets.append(Image.open(image))

            grid_h = task['grid_h']
            grid_w = task['grid_w']
            mask = task.get('mask', [0 for _ in range(grid_w - 1)] + [1])
            layout_prompt = get_layout_instruction(grid_w, grid_h)

            upsampling_noise = None
            steps = None
            outputs = [mask, grid_h, grid_w, layout_prompt, task_prompt, content_prompt, upsampling_noise, steps] + rets
            break

    return outputs