noumanjavaid commited on
Commit
a9fa887
·
verified ·
1 Parent(s): 112d812

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +80 -80
app.py CHANGED
@@ -1,80 +1,80 @@
1
- import gradio as gr
2
- from image import add_and_detect_watermark_image
3
- from video import add_and_detect_watermark_video
4
- from detect import detect_watermark_image
5
-
6
- # Image Interface
7
- image_inputs = [
8
- gr.Image(type="numpy", label="Upload Image"),
9
- gr.Textbox(label="Watermark Text")
10
- ]
11
-
12
- image_outputs = [
13
- gr.Image(type="numpy", label="Watermarked Image"),
14
- gr.Image(type="numpy", label="Watermark Highlight"),
15
- gr.File(label="Download Watermarked Image"),
16
- gr.File(label="Download Watermark Highlight")
17
- ]
18
-
19
- def process_image(image, text):
20
- watermarked_image, highlight, watermarked_image_path, highlight_path = add_and_detect_watermark_image(image, text)
21
- return watermarked_image, highlight, watermarked_image_path, highlight_path
22
-
23
- image_interface = gr.Interface(
24
- fn=process_image,
25
- inputs=image_inputs,
26
- outputs=image_outputs,
27
- title="Image Watermark Application",
28
- description="Upload an image and add a watermark text. Detect watermark and highlight its position."
29
- )
30
-
31
- # Video Interface
32
- video_inputs = [
33
- gr.Video(label="Upload Video"),
34
- gr.Textbox(label="Watermark Text")
35
- ]
36
-
37
- video_outputs = [
38
- gr.Video(label="Watermarked Video"),
39
- gr.Video(label="Watermark Highlight"),
40
- gr.File(label="Download Watermarked Video"),
41
- gr.File(label="Download Watermark Highlight")
42
- ]
43
-
44
- def process_video(video, text):
45
- watermarked_video_path, highlight_video_path, _, _ = add_and_detect_watermark_video(video, text)
46
- return watermarked_video_path, highlight_video_path, watermarked_video_path, highlight_video_path
47
-
48
- video_interface = gr.Interface(
49
- fn=process_video,
50
- inputs=video_inputs,
51
- outputs=video_outputs,
52
- title="Video Watermark Application",
53
- description="Upload a video and add a watermark text. Detect watermark and highlight its position."
54
- )
55
-
56
- # Forensic Watermark Detection Interface
57
- detect_inputs = [
58
- gr.Image(type="numpy", label="Upload Image")
59
- ]
60
-
61
- detect_outputs = [
62
- gr.Image(type="numpy", label="Watermark Detection Result")
63
- ]
64
-
65
- detect_interface = gr.Interface(
66
- fn=detect_watermark_image,
67
- inputs=detect_inputs,
68
- outputs=detect_outputs,
69
- title="Forensic Watermark Detection",
70
- description="Upload an image to detect forensic watermarks."
71
- )
72
-
73
- # Combine interfaces in tabs
74
- app = gr.TabbedInterface(
75
- interface_list=[image_interface, video_interface, detect_interface],
76
- tab_names=["Image", "Video", "Detect"]
77
- )
78
-
79
- if __name__ == "__main__":
80
- app.launch()
 
1
+ import gradio as gr
2
+ from image import add_and_detect_watermark_image
3
+ from video import add_and_detect_watermark_video
4
+ from detect import detect_watermark_image
5
+
6
+ # Image Interface
7
+ image_inputs = [
8
+ gr.Image(type="numpy", label="Upload Image"),
9
+ gr.Textbox(label="Watermark Text")
10
+ ]
11
+
12
+ image_outputs = [
13
+ gr.Image(type="numpy", label="Watermarked Image"),
14
+ gr.Image(type="numpy", label="Watermark Highlight"),
15
+ gr.File(label="Download Watermarked Image"),
16
+ gr.File(label="Download Watermark Highlight")
17
+ ]
18
+
19
+ def process_image(image, text):
20
+ watermarked_image, highlight, watermarked_image_path, highlight_path = add_and_detect_watermark_image(image, text)
21
+ return watermarked_image, highlight, watermarked_image_path, highlight_path
22
+
23
+ image_interface = gr.Interface(
24
+ fn=process_image,
25
+ inputs=image_inputs,
26
+ outputs=image_outputs,
27
+ title="Centurion Watermark Application",
28
+ description="Upload an image and add a watermark text. Detect watermark and highlight its position."
29
+ )
30
+
31
+ # Video Interface
32
+ video_inputs = [
33
+ gr.Video(label="Upload Video"),
34
+ gr.Textbox(label="Watermark Text")
35
+ ]
36
+
37
+ video_outputs = [
38
+ gr.Video(label="Watermarked Video"),
39
+ gr.Video(label="Watermark Highlight"),
40
+ gr.File(label="Download Watermarked Video"),
41
+ gr.File(label="Download Watermark Highlight")
42
+ ]
43
+
44
+ def process_video(video, text):
45
+ watermarked_video_path, highlight_video_path, _, _ = add_and_detect_watermark_video(video, text)
46
+ return watermarked_video_path, highlight_video_path, watermarked_video_path, highlight_video_path
47
+
48
+ video_interface = gr.Interface(
49
+ fn=process_video,
50
+ inputs=video_inputs,
51
+ outputs=video_outputs,
52
+ title="Centurion Watermark Application",
53
+ description="Upload a video and add a watermark text. Detect watermark and highlight its position."
54
+ )
55
+
56
+ # Forensic Watermark Detection Interface
57
+ detect_inputs = [
58
+ gr.Image(type="numpy", label="Upload Image")
59
+ ]
60
+
61
+ detect_outputs = [
62
+ gr.Image(type="numpy", label="Watermark Detection Result")
63
+ ]
64
+
65
+ detect_interface = gr.Interface(
66
+ fn=detect_watermark_image,
67
+ inputs=detect_inputs,
68
+ outputs=detect_outputs,
69
+ title="Forensic Watermark Detection",
70
+ description="Upload an image to detect forensic watermarks."
71
+ )
72
+
73
+ # Combine interfaces in tabs
74
+ app = gr.TabbedInterface(
75
+ interface_list=[image_interface, video_interface, detect_interface],
76
+ tab_names=["Image", "Video", "Detect"]
77
+ )
78
+
79
+ if __name__ == "__main__":
80
+ app.launch()