Spaces:
Sleeping
Sleeping
hysts
commited on
Commit
·
7f1a0a5
1
Parent(s):
cc9a95e
Add files
Browse files- .gitattributes +2 -0
- app.py +77 -0
- images/00.jpg +3 -0
- images/01.jpg +3 -0
- videos/00.mp4 +3 -0
- videos/01.mp4 +3 -0
.gitattributes
CHANGED
@@ -1,3 +1,5 @@
|
|
|
|
|
|
1 |
*.7z filter=lfs diff=lfs merge=lfs -text
|
2 |
*.arrow filter=lfs diff=lfs merge=lfs -text
|
3 |
*.bin filter=lfs diff=lfs merge=lfs -text
|
|
|
1 |
+
*.jpg filter=lfs diff=lfs merge=lfs -text
|
2 |
+
*.mp4 filter=lfs diff=lfs merge=lfs -text
|
3 |
*.7z filter=lfs diff=lfs merge=lfs -text
|
4 |
*.arrow filter=lfs diff=lfs merge=lfs -text
|
5 |
*.bin filter=lfs diff=lfs merge=lfs -text
|
app.py
ADDED
@@ -0,0 +1,77 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#!/usr/bin/env python
|
2 |
+
|
3 |
+
import pathlib
|
4 |
+
|
5 |
+
import gradio as gr
|
6 |
+
|
7 |
+
|
8 |
+
def set_example_image(example):
|
9 |
+
return [
|
10 |
+
gr.Image.update(value=example[0]),
|
11 |
+
gr.Image.update(value=example[1])
|
12 |
+
]
|
13 |
+
|
14 |
+
|
15 |
+
def set_example_video(example):
|
16 |
+
return [
|
17 |
+
gr.Video.update(value=example[0]),
|
18 |
+
gr.Video.update(value=example[1])
|
19 |
+
]
|
20 |
+
|
21 |
+
|
22 |
+
css = '''
|
23 |
+
div#image1 {
|
24 |
+
max-width: 300px;
|
25 |
+
max-height: 300px;
|
26 |
+
}
|
27 |
+
div#image2 {
|
28 |
+
max-width: 300px;
|
29 |
+
max-height: 300px;
|
30 |
+
}
|
31 |
+
div#video1 {
|
32 |
+
max-width: 300px;
|
33 |
+
max-height: 300px;
|
34 |
+
}
|
35 |
+
div#video2 {
|
36 |
+
max-width: 300px;
|
37 |
+
max-height: 300px;
|
38 |
+
}
|
39 |
+
'''
|
40 |
+
|
41 |
+
with gr.Blocks(css=css) as demo:
|
42 |
+
with gr.Row():
|
43 |
+
image1 = gr.Image(label='without gr.Group',
|
44 |
+
type='numpy',
|
45 |
+
elem_id='image1')
|
46 |
+
with gr.Group():
|
47 |
+
image2 = gr.Image(label='with gr.Group',
|
48 |
+
type='numpy',
|
49 |
+
elem_id='image2')
|
50 |
+
|
51 |
+
paths = sorted(pathlib.Path('images').rglob('*.jpg'))
|
52 |
+
example_images = gr.Dataset(components=[image1, image2],
|
53 |
+
samples=[[path.as_posix(),
|
54 |
+
path.as_posix()] for path in paths])
|
55 |
+
|
56 |
+
with gr.Row():
|
57 |
+
video1 = gr.Video(label='without gr.Group',
|
58 |
+
format='mp4',
|
59 |
+
elem_id='video1')
|
60 |
+
with gr.Group():
|
61 |
+
video2 = gr.Video(label='with gr.Group',
|
62 |
+
format='mp4',
|
63 |
+
elem_id='video2')
|
64 |
+
|
65 |
+
paths = sorted(pathlib.Path('videos').rglob('*.mp4'))
|
66 |
+
example_videos = gr.Dataset(components=[video1, video2],
|
67 |
+
samples=[[path.as_posix(),
|
68 |
+
path.as_posix()] for path in paths])
|
69 |
+
|
70 |
+
example_images.click(fn=set_example_image,
|
71 |
+
inputs=example_images,
|
72 |
+
outputs=example_images.components)
|
73 |
+
example_videos.click(fn=set_example_video,
|
74 |
+
inputs=example_videos,
|
75 |
+
outputs=example_videos.components)
|
76 |
+
|
77 |
+
demo.launch()
|
images/00.jpg
ADDED
![]() |
Git LFS Details
|
images/01.jpg
ADDED
![]() |
Git LFS Details
|
videos/00.mp4
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:747f9c2f9d19e4955603e1a13b69663187882d4c6a8fbcad18ddbd04ee792d4d
|
3 |
+
size 1972564
|
videos/01.mp4
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:1044083afc06aa6f956838c7fcd582c9cfd59ea3a994adc8a0f5889ffca4d9c8
|
3 |
+
size 2494082
|