awacke1 commited on
Commit
229aaef
1 Parent(s): 72b37b8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -78
app.py CHANGED
@@ -1,19 +1,13 @@
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
-
8
  pipe = pipeline(task='image-to-video', model='damo/Image-to-Video', model_revision='v1.1.0')
9
 
10
  def infer (image_in):
11
-
12
- # IMG_PATH: your image path (url or local file)
13
  IMG_PATH = 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="""
@@ -110,16 +104,14 @@ img[src*='#center'] {
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
 
125
  image_in = gr.Image(
@@ -129,93 +121,30 @@ with gr.Blocks(css=css) as demo:
129
  elem_id = "image-in"
130
  )
131
  with gr.Row():
132
-
133
  submit_btn = gr.Button(
134
  "Submit"
135
  )
136
-
137
  video_out = gr.Video(
138
  label = "Video Result",
139
  elem_id = "video-out"
140
  )
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,
221
  inputs = [
@@ -226,7 +155,6 @@ with gr.Blocks(css=css) as demo:
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
  from share_btn import community_icon_html, loading_icon_html, share_js
 
3
  from modelscope.pipelines import pipeline
4
  from modelscope.outputs import OutputKeys
 
5
  pipe = pipeline(task='image-to-video', model='damo/Image-to-Video', model_revision='v1.1.0')
6
 
7
  def infer (image_in):
 
 
8
  IMG_PATH = image_in
9
  output_video_path = pipe(IMG_PATH, output_video='output.mp4')[OutputKeys.OUTPUT_VIDEO]
10
  print(output_video_path)
 
11
  return output_video_path, gr.Group.update(visible=True)
12
 
13
  css="""
 
104
  with gr.Blocks(css=css) as demo:
105
  with gr.Column(elem_id="col-container"):
106
  gr.Markdown("""
 
107
  <h1 style="text-align: center;">
108
  MS Image2Video
109
  </h1>
110
  <p style="text-align: center;">
111
  Turn any image into a video ! <br />
112
  To use this demo, simply upload an image and hit the Submit button. <br />
113
+ Don't forget to share your results on Community: <a href="https://huggingface.co/spaces/awacke1/VideoFromImage/discussions">Community</a> ;)
114
  </p>
 
115
  """)
116
 
117
  image_in = gr.Image(
 
121
  elem_id = "image-in"
122
  )
123
  with gr.Row():
 
124
  submit_btn = gr.Button(
125
  "Submit"
126
  )
 
127
  video_out = gr.Video(
128
  label = "Video Result",
129
  elem_id = "video-out"
130
  )
 
131
  with gr.Row():
 
132
  with gr.Group(elem_id="share-btn-container", visible=False) as share_group:
133
  community_icon = gr.HTML(community_icon_html)
134
  loading_icon = gr.HTML(loading_icon_html)
 
 
 
 
 
 
135
 
136
  gr.Examples(
137
  examples = [
138
+ ["./examples/renaissance.png",],
139
+ ["./examples/reverie.png",],
140
+ ["./examples/animals_firecamp.png",],
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
141
  ],
142
  fn = infer,
143
+ inputs = [image_in],
144
+ outputs = [video_out,share_group],
 
 
 
 
 
145
  cache_examples = True
146
  )
147
 
 
 
 
 
 
 
 
 
 
148
  submit_btn.click(
149
  fn = infer,
150
  inputs = [
 
155
  share_group
156
  ]
157
  )
 
158
  share_button.click(None, [], [], _js=share_js)
159
 
160
  demo.queue(max_size=6).launch()