fffiloni commited on
Commit
a00b386
1 Parent(s): 14b82b8

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +97 -0
app.py ADDED
@@ -0,0 +1,97 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 (audio_in):
9
+
10
+ # IMG_PATH: your image path (url or local file)
11
+ IMG_PATH = audio_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
+
19
+ #col-container {
20
+ max-width: 780px;
21
+ margin-left: auto;
22
+ margin-right: auto;
23
+ }
24
+ img[src*='#center'] {
25
+ display: block;
26
+ margin: auto;
27
+ }
28
+ .footer {
29
+ margin-bottom: 45px;
30
+ margin-top: 10px;
31
+ text-align: center;
32
+ border-bottom: 1px solid #e5e5e5;
33
+ }
34
+ .footer > p {
35
+ font-size: .8rem;
36
+ display: inline-block;
37
+ padding: 0 10px;
38
+ transform: translateY(10px);
39
+ background: white;
40
+ }
41
+ .dark .footer {
42
+ border-color: #303030;
43
+ }
44
+ .dark .footer > p {
45
+ background: #0b0f19;
46
+ }
47
+
48
+ """
49
+
50
+ with gr.Blocks(css=css) as demo:
51
+ with gr.Column(elem_id="col-container"):
52
+ gr.Markdown("""
53
+
54
+ <h1 style="text-align: center;">
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
+
61
+ """)
62
+
63
+ image_in = gr.Image(
64
+ label = "Source Image",
65
+ source = "upload",
66
+ type = "filepath"
67
+ )
68
+
69
+ submit_btn = gr.Button(
70
+ "Submit"
71
+ )
72
+
73
+ video_out = gr.Video(
74
+ label = "Video Result"
75
+ )
76
+
77
+ gr.HTML("""
78
+
79
+ <div class="footer">
80
+ <p>
81
+ MS-Image2Video Demo by 🤗 <a href="https://twitter.com/fffiloni" target="_blank">Sylvain Filoni</a>
82
+ </p>
83
+ </div>
84
+
85
+ """)
86
+
87
+ submit_btn.click(
88
+ fn = infer,
89
+ inputs = [
90
+ audio_in
91
+ ],
92
+ outputs = [
93
+ video_out
94
+ ]
95
+ )
96
+
97
+ demo.queue(max_size=20).launch()