qfisch commited on
Commit
26ce92a
1 Parent(s): 6665b19

remove gradio file

Browse files
.gitignore DELETED
@@ -1 +0,0 @@
1
- .venv
 
 
app.py DELETED
@@ -1,43 +0,0 @@
1
- from ultralytics import YOLO
2
- import PIL
3
- from PIL import Image
4
- import gradio as gr
5
- import numpy as np
6
- import os
7
-
8
- def predict(input_img) -> tuple[np.ndarray | PIL.Image.Image | str, list[tuple[np.ndarray | tuple[int, int, int, int], str]]]:
9
- res = model(input_img)
10
- if len(res) == 0:
11
- return input_img, "No watermark detected"
12
- res = res[0]
13
- # convert res.boxes.xyxy to a tuple of (x1, y1, x2, y2)
14
- bbox = res.boxes.xyxy[0].tolist()
15
- bbox = (int(bbox[0]), int(bbox[1]), int(bbox[2]), int(bbox[3]))
16
- # convert res.boxes.cls to a string
17
- label = res.boxes.cls[0]
18
- str_label = "Watermark is a logo" if label == 0 else "Watermark is a text"
19
- print(bbox, str_label)
20
- return input_img, [(bbox, str_label)]
21
-
22
-
23
- gradio_app = gr.Interface(
24
- predict,
25
- inputs=gr.Image(label="Update your watermaked image", sources=['upload'], type="pil"),
26
- # output displays the image with the bounding boxes
27
- outputs=gr.AnnotatedImage(),
28
- title="Detect Watermark in Images",
29
- examples=[
30
- os.path.join(os.path.dirname(__file__), "samples/example_text1.jpg"),
31
- os.path.join(os.path.dirname(__file__), "samples/example_text2.jpg"),
32
- os.path.join(os.path.dirname(__file__), "samples/example_text3.jpg"),
33
- os.path.join(os.path.dirname(__file__), "samples/example_logo1.jpg"),
34
- os.path.join(os.path.dirname(__file__), "samples/example_logo2.jpg"),
35
- os.path.join(os.path.dirname(__file__), "samples/example_logo3.jpg"),
36
- ],
37
- allow_flagging="never"
38
- )
39
-
40
-
41
- if __name__ == "__main__":
42
- model = YOLO("best.pt")
43
- gradio_app.launch(debug=True)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
requirements.txt DELETED
@@ -1,2 +0,0 @@
1
- gradio
2
- ultralytics
 
 
 
samples/example_logo1.jpg DELETED
Binary file (64.8 kB)
 
samples/example_logo2.jpg DELETED
Binary file (51.8 kB)
 
samples/example_logo3.jpg DELETED
Binary file (28 kB)
 
samples/example_text1.jpg DELETED
Binary file (36.4 kB)
 
samples/example_text2.jpg DELETED
Binary file (29.5 kB)
 
samples/example_text3.jpg DELETED
Binary file (34.2 kB)