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

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -42
app.py CHANGED
@@ -1,59 +1,31 @@
1
  import gradio as gr
2
-
3
  from modelscope.pipelines import pipeline
4
  from modelscope.outputs import OutputKeys
5
 
6
  pipe = pipeline(task='image-to-video', model='damo/Image-to-Video', model_revision='v1.1.0')
7
 
8
  def infer (image_in):
9
-
10
  # IMG_PATH: your image path (url or local file)
11
  IMG_PATH = 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
-
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
-
28
- image_in = gr.Image(
29
- label = "Source Image",
30
- source = "upload",
31
- type = "filepath",
32
- elem_id = "image-in"
33
- )
34
- with gr.Row():
35
-
36
- submit_btn = gr.Button(
37
- "Submit"
38
- )
39
-
40
- video_out = gr.Video(
41
- label = "Video Result",
42
- elem_id = "video-out"
43
- )
44
-
45
- with gr.Row():
46
-
47
-
48
-
49
- submit_btn.click(
50
- fn = infer,
51
- inputs = [
52
- image_in
53
- ],
54
- outputs = [
55
- video_out,
56
- ]
57
  )
 
 
 
58
 
59
  demo.queue(max_size=6).launch()
 
1
  import gradio as gr
 
2
  from modelscope.pipelines import pipeline
3
  from modelscope.outputs import OutputKeys
4
 
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: your image path (url or local file)
9
  IMG_PATH = image_in
10
  output_video_path = pipe(IMG_PATH, output_video='output.mp4')[OutputKeys.OUTPUT_VIDEO]
11
  print(output_video_path)
 
12
  return output_video_path
13
 
 
14
  with gr.Blocks() as demo:
15
+ gr.Markdown("""
16
+ <p>
17
+ You are currently viewing a micro-service API meant to be used by robots.<br/>
18
+ For the human UI, please check out the <a href="https://huggingface.co/spaces/fffiloni/MS-Image2Video">original Space by Sylvain Filoni</a>.
19
+ </p>
20
+ """)
21
+ image_in = gr.Image(
22
+ label = "Source Image",
23
+ source = "upload",
24
+ type = "filepath",
25
+ elem_id = "image-in"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
26
  )
27
+ submit_btn = gr.Button("Submit")
28
+ video_out = gr.Video(label = "Video Result", elem_id = "video-out")
29
+ submit_btn.click(fn = infer, inputs = [image_in], outputs = [video_out])
30
 
31
  demo.queue(max_size=6).launch()