File size: 1,248 Bytes
23f56a9
 
 
864e9e3
 
 
 
e055d9e
864e9e3
 
 
23f56a9
 
864e9e3
23f56a9
 
4dc9189
23f56a9
 
 
 
 
29136da
 
 
 
 
 
 
864e9e3
29136da
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
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

with gr.Blocks() as app:
    with gr.Tab("Add Watermark"):
        cho = gr.Radio(choices=["stegan","pnginfo"])
        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()
                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()