File size: 838 Bytes
e0dfb76
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import os

import gradio as gr

import modelscope_studio as mgr


def resolve_assets(relative_path):
    return os.path.join(os.path.dirname(__file__), "../../resources",
                        relative_path)


def fn(data: gr.EventData):
    print(data._data)


with gr.Blocks() as demo:
    gallery = mgr.WaterfallGallery(
        value=[
            resolve_assets('modelscope.svg'),
            # pass a tuple
            [resolve_assets('bot.jpeg'), 'bot'],
            # pass a dict
            {
                "image": resolve_assets('user.jpeg'),
                "caption": "user",
            },
            resolve_assets('screen.jpeg'),
        ],
        action_label="Click Me!",
        columns=2,
        height=600)
    gallery.like(fn=fn)
    gallery.click(fn=fn)

if __name__ == "__main__":
    demo.queue().launch()