jbilcke-hf HF staff commited on
Commit
2ac584d
·
1 Parent(s): f0bddae

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -180
app.py CHANGED
@@ -1,7 +1,5 @@
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,111 +12,16 @@ def infer (image_in):
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
- #col-container {
21
- max-width: 580px;
22
- margin-left: auto;
23
- margin-right: auto;
24
- }
25
- .animate-spin {
26
- animation: spin 1s linear infinite;
27
- }
28
- @keyframes spin {
29
- from {
30
- transform: rotate(0deg);
31
- }
32
- to {
33
- transform: rotate(360deg);
34
- }
35
- }
36
- #share-btn-container {
37
- display: flex;
38
- padding-left: 0.5rem !important;
39
- padding-right: 0.5rem !important;
40
- background-color: #000000;
41
- justify-content: center;
42
- align-items: center;
43
- border-radius: 9999px !important;
44
- max-width: 15rem;
45
- height: 36px;
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
- div#component-7 {
80
- /* display: flex; */
81
- align-items: center;
82
- /* justify-content: center; */
83
- }
84
- img[src*='#center'] {
85
- display: block;
86
- margin: unset;
87
- margin-top: 6px;
88
- }
89
- .footer {
90
- margin-bottom: 45px;
91
- margin-top: 10px;
92
- text-align: center;
93
- border-bottom: 1px solid #e5e5e5;
94
- }
95
- .footer > p {
96
- font-size: .8rem;
97
- display: inline-block;
98
- padding: 0 10px;
99
- transform: translateY(16px);
100
- background: white;
101
- }
102
- .dark .footer {
103
- border-color: #303030;
104
- }
105
- .dark .footer > p {
106
- background: #0b0f19;
107
- }
108
- """
109
 
110
- with gr.Blocks(css=css) as demo:
111
  with gr.Column(elem_id="col-container"):
112
  gr.Markdown("""
113
-
114
- <h1 style="text-align: center;">
115
- MS Image2Video
116
- </h1>
117
- <p style="text-align: center;">
118
- Turn any image into a video ! <br />
119
- To use this demo, simply upload an image and hit the Submit button. <br />
120
- Don't forget to share your results with the <a href="https://huggingface.co/spaces/fffiloni/MS-Image2Video/discussions">Community</a> ;)
121
- </p>
122
 
123
  """)
124
 
@@ -141,80 +44,7 @@ with gr.Blocks(css=css) as demo:
141
 
142
  with gr.Row():
143
 
144
- with gr.Group(elem_id="share-btn-container", visible=False) as share_group:
145
- community_icon = gr.HTML(community_icon_html)
146
- loading_icon = gr.HTML(loading_icon_html)
147
- share_button = gr.Button("Share with Community", elem_id="share-btn")
148
-
149
- gr.Markdown("""
150
-
151
- [![Duplicate this Space](https://huggingface.co/datasets/huggingface/badges/raw/main/duplicate-this-space-lg.svg#center)](https://huggingface.co/spaces/fffiloni/MS-Image2Video-cloning?duplicate=true)
152
- """)
153
-
154
- gr.Examples(
155
- examples = [
156
- [
157
- "./examples/renaissance.png",
158
- ],
159
- [
160
- "./examples/reverie.png",
161
- ],
162
- [
163
- "./examples/animals_firecamp.png",
164
- ],
165
- [
166
- "./examples/adventurer.png",
167
- ],
168
- [
169
- "./examples/anime_girl.png",
170
- ],
171
- [
172
- "./examples/hopper_nighthawks.jpeg",
173
- ],
174
- [
175
- "./examples/joconde.png",
176
- ],
177
- [
178
- "./examples/medieval_barmaid.png",
179
- ],
180
- [
181
- "./examples/old_ladies.jpeg",
182
- ],
183
- [
184
- "./examples/snow_white.png",
185
- ],
186
- [
187
- "./examples/violonist.png",
188
- ],
189
- [
190
- "./examples/voilier.jpeg",
191
- ],
192
- [
193
- "./examples/wet_coast.jpeg",
194
- ],
195
- [
196
- "./examples/winter_out.png",
197
- ],
198
- ],
199
- fn = infer,
200
- inputs = [
201
- image_in
202
- ],
203
- outputs = [
204
- video_out,
205
- share_group
206
- ],
207
- cache_examples = True
208
- )
209
 
210
- gr.HTML("""
211
-
212
- <div class="footer">
213
- <p>
214
- MS-Image2Video Demo by 🤗 <a href="https://twitter.com/fffiloni" target="_blank">Sylvain Filoni</a>
215
- </p>
216
- </div>
217
- """)
218
 
219
  submit_btn.click(
220
  fn = infer,
@@ -222,11 +52,8 @@ with gr.Blocks(css=css) as demo:
222
  image_in
223
  ],
224
  outputs = [
225
- video_out,
226
- share_group
227
  ]
228
  )
229
 
230
- share_button.click(None, [], [], _js=share_js)
231
-
232
  demo.queue(max_size=6).launch()
 
1
  import gradio as gr
2
 
 
 
3
  from modelscope.pipelines import pipeline
4
  from modelscope.outputs import OutputKeys
5
 
 
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
 
18
+ with gr.Blocks() as demo:
19
  with gr.Column(elem_id="col-container"):
20
  gr.Markdown("""
21
+ <p>
22
+ You are currently viewing a micro-service API meant to be used by robots.<br/>
23
+ For the human UI, please check out the <a href="https://huggingface.co/spaces/fffiloni/MS-Image2Video">original Space by Sylvain Filoni</a>.
24
+ </p>
 
 
 
 
 
25
 
26
  """)
27
 
 
44
 
45
  with gr.Row():
46
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
47
 
 
 
 
 
 
 
 
 
48
 
49
  submit_btn.click(
50
  fn = infer,
 
52
  image_in
53
  ],
54
  outputs = [
55
+ video_out,
 
56
  ]
57
  )
58
 
 
 
59
  demo.queue(max_size=6).launch()