File size: 1,628 Bytes
23f56a9
 
 
864e9e3
 
 
 
e055d9e
864e9e3
 
 
849dac3
 
 
 
 
 
 
da8c450
6725799
25dee1a
23f56a9
da8c450
23f56a9
 
da8c450
23f56a9
da8c450
23f56a9
 
 
da8c450
29136da
 
 
da8c450
29136da
 
da8c450
 
 
 
 
23f56a9
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import gradio as gr
import utils

def choose_encode(inp_im,inp_mark,cho):
    if cho == "stegan":
        out_im, out_msg = utils.encode(inp_im,inp_mark)
        return out_im,out_msg
    if cho == "pnginfo":
        out_im, out_msg = utils.png_encode(inp_im,inp_mark)
        return out_im,out_msg

css = """
footer { 
    visibility: hidden; 
}
"""

with gr.Blocks(css=css) as app:
    gr.Markdown("# Image Watermarking Tool")
    gr.Markdown("[![Visitors](https://api.visitorbadge.io/api/visitors?path=https%3A%2F%2Ffantos-watermark.hf.space&countColor=%23263759)](https://visitorbadge.io/status?path=https%3A%2F%2Ffantos-watermark.hf.space)")
    
    with gr.Tab("Add Watermark"):
        cho = gr.Radio(choices=["stegan", "pnginfo"], value="stegan")
        with gr.Row():
            with gr.Column():
                inp_im = gr.Image(label="Input Image", type="filepath")
                inp_mark = gr.Textbox(label="Watermark")
                mark_btn = gr.Button("Add Watermark")
                msg_box = gr.Textbox(label="System Message")
            with gr.Column():
                out_im = gr.Image(label="Watermarked Image")
    
    with gr.Tab("Detect Watermark"):
        with gr.Row():
            with gr.Column():
                det_im = gr.Image(label="Watermarked Image", type="filepath")
                det_btn = gr.Button("Detect")
            with gr.Column():
                det_msg = gr.Textbox(label="Detected Watermark", lines=6, max_lines=50)
    
    mark_btn.click(choose_encode, [inp_im, inp_mark, cho], [out_im, msg_box])
    det_btn.click(utils.decode, [det_im], det_msg)

app.launch()