Visible Watermarking with Gradio
Last year, we shared a blogpost on watermarking, explaining what it means to watermark generative AI content, and why it's important. The need for watermarking has become even more critical as people all over the world have begun to generate and share AI-generated images, video, audio, and text. Images and video have become so realistic that they’re nearly impossible to distinguish from what you’d see captured by a real camera. Addressing this issue is multi-faceted, but there is one, clear, low-hanging fruit 🍇:
In order for people to know what's real and what's synthetic, use visible watermarks.
To help out, we at Hugging Face have made visible watermarking trivially easy: Whenever you create a Space like an app or a demo, you can use our in-house app-building library Gradio to display watermarks with a single command.
For images and video, simply add the watermark
parameter, like so:
gr.Image(my_generated_image, watermark=my_watermark_image)
gr.Video(my_generated_video, watermark=my_watermark_image)
See a demonstration of this in action: check out our example image and video watermarking Space.
Watermarks can be specified as filenames, and for images we additionally support open images or even numpy arrays, to work best with how you want to set up your interface. One option I particularly like is QR watermarks, which can be used to get much more information about the content, and can even be matched to the style of your image or video.
You can also add custom visible watermarks for AI-generated text, so that whenever it is copied, the watermark will appear. Like so:
gr.Chatbot(label=my_model_name, watermark=my_watermark_text, type="messages", show_copy_button=True, show_copy_all_button=True)
See a demonstration of this in action: check out our example chatbot watermarking Space.
This automatically adds attribution when users copy text from AI responses, further aiding in AI transparency and disclosure for text generation.
Try it all out today, build your own watermark, have fun!
Happy Coding!
Acknowledgements: Abubakar Abid and Yuvraj Sharma collaborated on this work and blog post.