File size: 566 Bytes
c45703e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
from PIL import Image
from .process_images import make_img_html


class ExamplesHandler:
    def __init__(self, examples):
        self.examples = examples 

    def to_html(self):

        ret = ""
        for i, (img_path, category) in enumerate(self.examples): 
            ret += f"<figure id='example_{i}' onclick='remap_click({i})'>"
            img = Image.open(img_path).convert("RGB")
            ret += make_img_html(img)
            ret += f"<figcaption>{category}</figcaption>"
            ret += "</figure>"

        ret += "<p></p>"

        return ret