fffiloni commited on
Commit
7883b3e
1 Parent(s): b63560a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +83 -13
app.py CHANGED
@@ -1,5 +1,7 @@
1
  import gradio as gr
2
 
 
 
3
  from modelscope.pipelines import pipeline
4
  from modelscope.outputs import OutputKeys
5
 
@@ -12,7 +14,7 @@ def infer (image_in):
12
  output_video_path = pipe(IMG_PATH, output_video='output.mp4')[OutputKeys.OUTPUT_VIDEO]
13
  print(output_video_path)
14
 
15
- return output_video_path
16
 
17
  css="""
18
 
@@ -21,6 +23,59 @@ css="""
21
  margin-left: auto;
22
  margin-right: auto;
23
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
24
  img[src*='#center'] {
25
  display: block;
26
  margin: auto;
@@ -55,6 +110,12 @@ with gr.Blocks(css=css) as demo:
55
  MS Image2Video
56
  </h1>
57
 
 
 
 
 
 
 
58
  [![Duplicate this Space](https://huggingface.co/datasets/huggingface/badges/raw/main/duplicate-this-space-sm.svg#center)](https://huggingface.co/spaces/fffiloni/MS-Image2Video-cloning?duplicate=true)
59
 
60
 
@@ -74,6 +135,21 @@ with gr.Blocks(css=css) as demo:
74
  label = "Video Result"
75
  )
76
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
77
  gr.Examples(
78
  examples = [
79
  [
@@ -91,29 +167,23 @@ with gr.Blocks(css=css) as demo:
91
  image_in
92
  ],
93
  outputs = [
94
- video_out
 
95
  ],
96
  cache_examples = False
97
  )
98
 
99
- gr.HTML("""
100
-
101
- <div class="footer">
102
- <p>
103
- MS-Image2Video Demo by 🤗 <a href="https://twitter.com/fffiloni" target="_blank">Sylvain Filoni</a>
104
- </p>
105
- </div>
106
-
107
- """)
108
-
109
  submit_btn.click(
110
  fn = infer,
111
  inputs = [
112
  image_in
113
  ],
114
  outputs = [
115
- video_out
 
116
  ]
117
  )
118
 
 
 
119
  demo.queue(max_size=20).launch()
 
1
  import gradio as gr
2
 
3
+ from share_btn import community_icon_html, loading_icon_html, share_js
4
+
5
  from modelscope.pipelines import pipeline
6
  from modelscope.outputs import OutputKeys
7
 
 
14
  output_video_path = pipe(IMG_PATH, output_video='output.mp4')[OutputKeys.OUTPUT_VIDEO]
15
  print(output_video_path)
16
 
17
+ return output_video_path, gr.Group.update(visible=True)
18
 
19
  css="""
20
 
 
23
  margin-left: auto;
24
  margin-right: auto;
25
  }
26
+ .animate-spin {
27
+ animation: spin 1s linear infinite;
28
+ }
29
+ @keyframes spin {
30
+ from {
31
+ transform: rotate(0deg);
32
+ }
33
+ to {
34
+ transform: rotate(360deg);
35
+ }
36
+ }
37
+ #share-btn-container {
38
+ display: flex;
39
+ padding-left: 0.5rem !important;
40
+ padding-right: 0.5rem !important;
41
+ background-color: #000000;
42
+ justify-content: center;
43
+ align-items: center;
44
+ border-radius: 9999px !important;
45
+ max-width: 13rem;
46
+ }
47
+ div#share-btn-container > div {
48
+ flex-direction: row;
49
+ background: black;
50
+ align-items: center;
51
+ }
52
+ #share-btn-container:hover {
53
+ background-color: #060606;
54
+ }
55
+ #share-btn {
56
+ all: initial;
57
+ color: #ffffff;
58
+ font-weight: 600;
59
+ cursor:pointer;
60
+ font-family: 'IBM Plex Sans', sans-serif;
61
+ margin-left: 0.5rem !important;
62
+ padding-top: 0.5rem !important;
63
+ padding-bottom: 0.5rem !important;
64
+ right:0;
65
+ }
66
+ #share-btn * {
67
+ all: unset;
68
+ }
69
+ #share-btn-container div:nth-child(-n+2){
70
+ width: auto !important;
71
+ min-height: 0px !important;
72
+ }
73
+ #share-btn-container .wrap {
74
+ display: none !important;
75
+ }
76
+ #share-btn-container.hidden {
77
+ display: none!important;
78
+ }
79
  img[src*='#center'] {
80
  display: block;
81
  margin: auto;
 
110
  MS Image2Video
111
  </h1>
112
 
113
+ <p style="text-align: center;">
114
+ Turn any image into a video ! <br />
115
+ To use this demo, simply upload an image and hit the Submit button. <br />
116
+ Don't forget to share your results with the Community ;)
117
+ </p>
118
+
119
  [![Duplicate this Space](https://huggingface.co/datasets/huggingface/badges/raw/main/duplicate-this-space-sm.svg#center)](https://huggingface.co/spaces/fffiloni/MS-Image2Video-cloning?duplicate=true)
120
 
121
 
 
135
  label = "Video Result"
136
  )
137
 
138
+ with gr.Group(elem_id="share-btn-container", visible=False) as share_group:
139
+ community_icon = gr.HTML(community_icon_html)
140
+ loading_icon = gr.HTML(loading_icon_html)
141
+ share_button = gr.Button("Share to community", elem_id="share-btn")
142
+
143
+ gr.HTML("""
144
+
145
+ <div class="footer">
146
+ <p>
147
+ MS-Image2Video Demo by 🤗 <a href="https://twitter.com/fffiloni" target="_blank">Sylvain Filoni</a>
148
+ </p>
149
+ </div>
150
+
151
+ """)
152
+
153
  gr.Examples(
154
  examples = [
155
  [
 
167
  image_in
168
  ],
169
  outputs = [
170
+ video_out,
171
+ share_group
172
  ],
173
  cache_examples = False
174
  )
175
 
 
 
 
 
 
 
 
 
 
 
176
  submit_btn.click(
177
  fn = infer,
178
  inputs = [
179
  image_in
180
  ],
181
  outputs = [
182
+ video_out,
183
+ share_group
184
  ]
185
  )
186
 
187
+ share_button.click(None, [], [], _js=share_js)
188
+
189
  demo.queue(max_size=20).launch()