File size: 1,492 Bytes
40e52db
 
 
a6626fd
 
 
6e83c08
a6626fd
40e52db
b024c7c
40e52db
 
 
6477da7
a6626fd
 
 
 
 
 
 
 
b15d92f
a6626fd
 
40e52db
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import gradio as gr
import os

a = os.path.join(os.path.dirname(__file__), "files/barkley_balloon.mp4")
b = os.path.join(os.path.dirname(__file__), "files/convert-to-gradio-sd.mp4")
w1 = os.path.join(os.path.dirname(__file__), "files/AI_generated.png")
w2 = os.path.join(os.path.dirname(__file__), "files/hf-logo.png")
w3 = os.path.join(os.path.dirname(__file__), "files/watermark_qr_code.png")


def generate_video(original_video, watermark):
    return gr.Video(original_video, watermark=watermark)

# Use RGBA image mode to preserve transparency for png images.
with gr.Blocks() as demo:
    gr.Markdown("# Watermarking with Gradio: Example")
    gr.Markdown("Watermarks can be **visible** or **invisible**.")
    gr.Markdown("""They can provide information directly, or provide a link for more information.  
                   Visible watermarks can help to disclose when content is AI-generated, so viewers know it's synthetic.  
                   Invisible watermarks can help to mark content as authentic.""")

    gr.Markdown()
    gr.Markdown("""For more information on watermarking -- what watermarking is, why it's important, and the tools available on Hugging Face -- please check out [our blogpost on AI watermarking](https://huggingface.co/blog/watermarking).""")
    gr.Interface(generate_video, [gr.Video(), gr.Image(type='filepath', image_mode="RGBA")], gr.Video(),
                        examples=[[a, w1], [b, w2], [a, w3]])

if __name__ == "__main__":
    demo.launch()