Spaces:
Running
Running
Add image watermarking
Browse files
app.py
CHANGED
|
@@ -44,10 +44,17 @@ img {
|
|
| 44 |
|
| 45 |
a = os.path.join(os.path.dirname(__file__), "files/barkley_balloon.mp4")
|
| 46 |
b = os.path.join(os.path.dirname(__file__), "files/eiffel_tower.mp4")
|
|
|
|
|
|
|
| 47 |
w1 = os.path.join(os.path.dirname(__file__), "files/AI_generated.png")
|
| 48 |
w2 = os.path.join(os.path.dirname(__file__), "files/hf-logo.png")
|
| 49 |
w3 = os.path.join(os.path.dirname(__file__), "files/forest_qr_watermarking.png")
|
| 50 |
w4 = os.path.join(os.path.dirname(__file__), "files/cheetah1.jpg")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 51 |
|
| 52 |
def generate_video(original_video, watermark):
|
| 53 |
return gr.Video(original_video, watermark=watermark)
|
|
@@ -61,7 +68,8 @@ with gr.Blocks(css=css) as demo:
|
|
| 61 |
gr.Markdown("""They can provide information directly, or provide a link for more information.
|
| 62 |
- Visible watermarks are useful to disclose when content is AI-generated.
|
| 63 |
- Invisible watermarks can mark content as authentic.
|
| 64 |
-
- ...And vice versa! There are many possibilities for what watermarks can provide.
|
|
|
|
| 65 |
gr.Markdown("They are a useful tool for **AI provenance**.")
|
| 66 |
gr.Markdown()
|
| 67 |
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).""")
|
|
@@ -72,10 +80,19 @@ with gr.Blocks(css=css) as demo:
|
|
| 72 |
gr.Image('files/watermark_example.png', visible=False)
|
| 73 |
with gr.Column():
|
| 74 |
gr.Image('files/watermark_example.png', show_label=False, show_download_button=False, elem_id='example', container=False, interactive=False)
|
| 75 |
-
gr.Markdown('**Code:**')
|
|
|
|
|
|
|
| 76 |
gr.Code('import gradio as gr\n\nwatermarked_video = gr.Video(original_video_file, watermark=watermark_file)', lines=3)
|
| 77 |
with gr.Column():
|
| 78 |
gr.Image('files/watermark_example.png', visible=False)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 79 |
with gr.Row():
|
| 80 |
with gr.Column():
|
| 81 |
gr.Markdown("**Inputs**: Video and watermark file")
|
|
|
|
| 44 |
|
| 45 |
a = os.path.join(os.path.dirname(__file__), "files/barkley_balloon.mp4")
|
| 46 |
b = os.path.join(os.path.dirname(__file__), "files/eiffel_tower.mp4")
|
| 47 |
+
c = os.path.join(os.path.dirname(__file__), "files/bird.bmp")
|
| 48 |
+
d = os.path.join(os.path.dirname(__file__), "files/groot.jpeg")
|
| 49 |
w1 = os.path.join(os.path.dirname(__file__), "files/AI_generated.png")
|
| 50 |
w2 = os.path.join(os.path.dirname(__file__), "files/hf-logo.png")
|
| 51 |
w3 = os.path.join(os.path.dirname(__file__), "files/forest_qr_watermarking.png")
|
| 52 |
w4 = os.path.join(os.path.dirname(__file__), "files/cheetah1.jpg")
|
| 53 |
+
w5 = os.path.join(os.path.dirname(__file__), "files/frog.jpg")
|
| 54 |
+
w6 = os.path.join(os.path.dirname(__file__), "files/Human_generated.png")
|
| 55 |
+
|
| 56 |
+
def generate_image(original_image, watermark):
|
| 57 |
+
return gr.Image(original_image, watermark=watermark)
|
| 58 |
|
| 59 |
def generate_video(original_video, watermark):
|
| 60 |
return gr.Video(original_video, watermark=watermark)
|
|
|
|
| 68 |
gr.Markdown("""They can provide information directly, or provide a link for more information.
|
| 69 |
- Visible watermarks are useful to disclose when content is AI-generated.
|
| 70 |
- Invisible watermarks can mark content as authentic.
|
| 71 |
+
- ...And vice versa! There are many possibilities for what watermarks can provide.
|
| 72 |
+
- Watermarks can also provide information about content created by people.""")
|
| 73 |
gr.Markdown("They are a useful tool for **AI provenance**.")
|
| 74 |
gr.Markdown()
|
| 75 |
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).""")
|
|
|
|
| 80 |
gr.Image('files/watermark_example.png', visible=False)
|
| 81 |
with gr.Column():
|
| 82 |
gr.Image('files/watermark_example.png', show_label=False, show_download_button=False, elem_id='example', container=False, interactive=False)
|
| 83 |
+
gr.Markdown('**Image Watermark Code:**')
|
| 84 |
+
gr.Code('import gradio as gr\n\nwatermarked_image = gr.Video(original_image_file, watermark=watermark_file)', lines=3)
|
| 85 |
+
gr.Markdown('**Video Watermark Code:**')
|
| 86 |
gr.Code('import gradio as gr\n\nwatermarked_video = gr.Video(original_video_file, watermark=watermark_file)', lines=3)
|
| 87 |
with gr.Column():
|
| 88 |
gr.Image('files/watermark_example.png', visible=False)
|
| 89 |
+
with gr.Row():
|
| 90 |
+
with gr.Column():
|
| 91 |
+
gr.Markdown("**Inputs**: Image and watermark file")
|
| 92 |
+
with gr.Column():
|
| 93 |
+
gr.Markdown("**Output**: Watermarked image")
|
| 94 |
+
gr.Interface(generate_image, [gr.Image(), gr.Image(type='filepath', image_mode=None)], gr.Image(),
|
| 95 |
+
examples=[[c, w1], [d, w2], [w4, w5], [c, w6]])
|
| 96 |
with gr.Row():
|
| 97 |
with gr.Column():
|
| 98 |
gr.Markdown("**Inputs**: Video and watermark file")
|