noumanjavaid's picture
Update app.py
52ffb7e verified
raw
history blame
2.47 kB
import gradio as gr
import os
css = """
p {
font-size: 120%;
}
li {
font-size: 110%;
}
.container {
height: initial;
}
video {
max-height: 400px;
}
.image-container {
width: 200px;
max-height: 300px;
margin: auto;
}
img {
width: auto;
height: auto;
}
"""
a = os.path.join(os.path.dirname(__file__), "files/barkley_balloon.mp4")
b = os.path.join(os.path.dirname(__file__), "files/eiffel_tower.mp4")
w1 = os.path.join(os.path.dirname(__file__), "files/AI_generated.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(css=css) as demo:
with gr.Row():
with gr.Column():
gr.Markdown("# Centurion Watermarking")
gr.Markdown("Watermarks can be **visible** or **invisible**.")
gr.Markdown("""They can provide information directly, or provide a link for more information.
- Visible watermarks are useful to disclose when content is AI-generated.
- Invisible watermarks can mark content as authentic.
- ...And vice versa! There are many possibilities for what watermarks can provide.""")
with gr.Column():
with gr.Column():
gr.Image('files/watermark_example.png', visible=False)
with gr.Column():
gr.Image('files/watermark_example.png',
show_label=False,
show_download_button=False,
elem_id='example',
container=False,
interactive=False)
gr.Code('import gradio as gr\n\nwatermarked_video = gr.Video(original_video_file, watermark=watermark_file)',
lines=3)
with gr.Column():
gr.Image('files/watermark_example.png', visible=False)
with gr.Row():
with gr.Column():
gr.Markdown("**Inputs**: Video and watermark file")
with gr.Column():
gr.Markdown("**Output**: Watermarked video")
gr.Interface(
generate_video,
[gr.Video(), gr.Image(type='filepath', image_mode=None)],
gr.Video(),
examples=[[a, w1], [b, w2], [a, w3], [b, w4]]
)
if __name__ == "__main__":
demo.launch()