Commit
·
c804b0a
1
Parent(s):
4b6b116
Update app.py
Browse files
app.py
CHANGED
@@ -2,9 +2,14 @@ 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]
|
@@ -18,6 +23,7 @@ with gr.Blocks() as demo:
|
|
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",
|
@@ -26,6 +32,6 @@ with gr.Blocks() as demo:
|
|
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()
|
|
|
2 |
from modelscope.pipelines import pipeline
|
3 |
from modelscope.outputs import OutputKeys
|
4 |
|
5 |
+
SECRET_TOKEN = os.getenv('SECRET_TOKEN', 'default_secret')
|
6 |
+
|
7 |
pipe = pipeline(task='image-to-video', model='damo/Image-to-Video', model_revision='v1.1.0')
|
8 |
|
9 |
+
def infer (image_in, secret_token):
|
10 |
+
if secret_token != SECRET_TOKEN:
|
11 |
+
raise gr.Error(f'Invalid secret token. Please fork the original space if you want to use it for yourself.')
|
12 |
+
|
13 |
# IMG_PATH: your image path (url or local file)
|
14 |
IMG_PATH = image_in
|
15 |
output_video_path = pipe(IMG_PATH, output_video='output.mp4')[OutputKeys.OUTPUT_VIDEO]
|
|
|
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 |
+
secret_token = gr.Text(label='Secret', max_lines=1, placeholder='secret')
|
27 |
image_in = gr.Image(
|
28 |
label = "Source Image",
|
29 |
source = "upload",
|
|
|
32 |
)
|
33 |
submit_btn = gr.Button("Submit")
|
34 |
video_out = gr.Video(label = "Video Result", elem_id = "video-out")
|
35 |
+
submit_btn.click(fn = infer, inputs = [image_in, secret_token], outputs = [video_out], api_name ="generate")
|
36 |
|
37 |
demo.queue(max_size=6).launch()
|