Spaces:
Build error
Build error
yangwu
commited on
Commit
•
9c59d94
1
Parent(s):
a1073cf
update
Browse files- .gitattributes +1 -0
- 2680.jpg +0 -0
- README.md +6 -5
- app.py +85 -46
- image_forgery_detection/__init__.py +2 -0
- image_forgery_detection/__pycache__/__init__.cpython-37.pyc +0 -0
- image_forgery_detection/__pycache__/__init__.cpython-38.pyc +0 -0
- image_forgery_detection/datasets/__init__.py +2 -0
- image_forgery_detection/datasets/__pycache__/__init__.cpython-37.pyc +0 -0
- image_forgery_detection/datasets/__pycache__/__init__.cpython-38.pyc +0 -0
- image_forgery_detection/datasets/builder.cpython-38-x86_64-linux-gnu.so +3 -0
- image_forgery_detection/datasets/dct_pipelines.cpython-38-x86_64-linux-gnu.so +3 -0
- image_forgery_detection/datasets/pipelines.cpython-38-x86_64-linux-gnu.so +3 -0
- image_forgery_detection/models/__init__.py +21 -0
- image_forgery_detection/models/__pycache__/__init__.cpython-37.pyc +0 -0
- image_forgery_detection/models/__pycache__/__init__.cpython-38.pyc +0 -0
- image_forgery_detection/models/builder.cpython-38-x86_64-linux-gnu.so +3 -0
- image_forgery_detection/models/deeplabv3.cpython-38-x86_64-linux-gnu.so +3 -0
- image_forgery_detection/models/detector.cpython-38-x86_64-linux-gnu.so +3 -0
- image_forgery_detection/models/fpn.cpython-38-x86_64-linux-gnu.so +3 -0
- image_forgery_detection/models/hooks.cpython-38-x86_64-linux-gnu.so +3 -0
- image_forgery_detection/models/init.cpython-38-x86_64-linux-gnu.so +3 -0
- image_forgery_detection/models/losses.cpython-38-x86_64-linux-gnu.so +3 -0
- image_forgery_detection/models/network_CAT.cpython-38-x86_64-linux-gnu.so +3 -0
- image_forgery_detection/models/objectformer_detector.cpython-38-x86_64-linux-gnu.so +3 -0
- image_forgery_detection/models/pan.cpython-38-x86_64-linux-gnu.so +3 -0
- image_forgery_detection/models/psccnet.cpython-38-x86_64-linux-gnu.so +3 -0
- image_forgery_detection/models/psccnet_detector.cpython-38-x86_64-linux-gnu.so +3 -0
- image_forgery_detection/models/pvtv2.cpython-38-x86_64-linux-gnu.so +3 -0
- image_forgery_detection/models/seg_hrnet.cpython-38-x86_64-linux-gnu.so +3 -0
- image_forgery_detection/models/transforensics.cpython-38-x86_64-linux-gnu.so +3 -0
- image_forgery_detection/models/transforensics_detector.cpython-38-x86_64-linux-gnu.so +3 -0
- image_forgery_detection/models/utils.cpython-38-x86_64-linux-gnu.so +3 -0
- models/config.py +145 -0
- models/latest.pth +3 -0
- requirements.txt +23 -0
.gitattributes
CHANGED
@@ -13,6 +13,7 @@
|
|
13 |
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
14 |
*.npy filter=lfs diff=lfs merge=lfs -text
|
15 |
*.npz filter=lfs diff=lfs merge=lfs -text
|
|
|
16 |
*.onnx filter=lfs diff=lfs merge=lfs -text
|
17 |
*.ot filter=lfs diff=lfs merge=lfs -text
|
18 |
*.parquet filter=lfs diff=lfs merge=lfs -text
|
|
|
13 |
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
14 |
*.npy filter=lfs diff=lfs merge=lfs -text
|
15 |
*.npz filter=lfs diff=lfs merge=lfs -text
|
16 |
+
*.so filter=lfs diff=lfs merge=lfs -text
|
17 |
*.onnx filter=lfs diff=lfs merge=lfs -text
|
18 |
*.ot filter=lfs diff=lfs merge=lfs -text
|
19 |
*.parquet filter=lfs diff=lfs merge=lfs -text
|
2680.jpg
DELETED
Binary file (122 kB)
|
|
README.md
CHANGED
@@ -1,3 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
---
|
2 |
title: Text Image Forgery Detection
|
3 |
emoji: 🐢
|
@@ -9,9 +15,4 @@ app_file: app.py
|
|
9 |
pinned: false
|
10 |
license: mit
|
11 |
---
|
12 |
-
# Introduction
|
13 |
-
We opened the inference API of our text image forgery detetion model, we are very glad you could try it. Unfortunately, we cannot open the model code for business reasons.
|
14 |
-
|
15 |
-
# Notes
|
16 |
-
In order to ensure that the model can predict correctly, the forged image you submit has not been reprocessed, such as resizing, cropping, network transmission, etc.
|
17 |
|
|
|
1 |
+
# Introduction
|
2 |
+
We opened the inference API of our text image forgery detetion model, we are very glad you could try it. Unfortunately, we cannot open the model code for business reasons.
|
3 |
+
|
4 |
+
# Notes
|
5 |
+
In order to ensure that the model can predict correctly, the forged image you submit has not been reprocessed, such as resizing, cropping, network transmission, etc.
|
6 |
+
|
7 |
---
|
8 |
title: Text Image Forgery Detection
|
9 |
emoji: 🐢
|
|
|
15 |
pinned: false
|
16 |
license: mit
|
17 |
---
|
|
|
|
|
|
|
|
|
|
|
18 |
|
app.py
CHANGED
@@ -1,51 +1,90 @@
|
|
1 |
import gradio as gr
|
2 |
-
import json
|
3 |
-
import requests
|
4 |
import os
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
51 |
|
|
|
1 |
import gradio as gr
|
|
|
|
|
2 |
import os
|
3 |
+
import sys
|
4 |
+
import numpy as np
|
5 |
+
import numpy as np
|
6 |
+
import torch.backends.cudnn as cudnn
|
7 |
+
import torch.utils.data
|
8 |
+
import torch.nn.functional as F
|
9 |
+
import torchvision.transforms as transforms
|
10 |
+
from mmcv.utils import Config
|
11 |
+
sys.path.append('.')
|
12 |
+
from image_forgery_detection import build_detector
|
13 |
+
from image_forgery_detection import Compose
|
14 |
|
15 |
|
16 |
+
transform_pil = transforms.Compose([
|
17 |
+
transforms.ToPILImage(),
|
18 |
+
])
|
19 |
+
|
20 |
+
|
21 |
+
def predict(f_path):
|
22 |
+
print(f_path)
|
23 |
+
|
24 |
+
results = dict(img_info=dict(filename=f_path, ann=dict(seg_map='None')))
|
25 |
+
results['seg_fields'] = []
|
26 |
+
results['img_prefix'] = None
|
27 |
+
results['seg_prefix'] = None
|
28 |
+
|
29 |
+
inputs = pipelines(results)
|
30 |
+
|
31 |
+
img = inputs['img'].data
|
32 |
+
img_meta = inputs['img_metas'].data
|
33 |
+
if 'dct_vol' in inputs:
|
34 |
+
dct_vol = inputs['dct_vol'].data
|
35 |
+
qtables = inputs['qtables'].data
|
36 |
+
|
37 |
+
with torch.no_grad():
|
38 |
+
img = img.unsqueeze(dim=0)
|
39 |
+
if 'dct_vol' in inputs:
|
40 |
+
dct_vol = dct_vol.unsqueeze(dim=0)
|
41 |
+
qtables = qtables.unsqueeze(dim=0)
|
42 |
+
cls_pred, seg_pred = model(img, dct_vol, qtables, [img_meta, ], return_loss=False, rescale=True)
|
43 |
+
else:
|
44 |
+
cls_pred, seg_pred = model(img, [img_meta, ], return_loss=False, rescale=True)
|
45 |
+
cls_pred = cls_pred[0]
|
46 |
+
seg = seg_pred[0, 0]
|
47 |
+
seg = np.array(transform_pil(torch.from_numpy(seg)))
|
48 |
+
thresh_int = 255 * thresh
|
49 |
+
seg[seg>=thresh_int] = 255
|
50 |
+
seg[seg<thresh_int] = 0
|
51 |
+
|
52 |
+
return '{:.3f}'.format(cls_pred), seg
|
53 |
+
|
54 |
+
|
55 |
+
if __name__ == '__main__':
|
56 |
+
model_path = './models/latest.pth'
|
57 |
+
cfg = Config.fromfile('./models/config.py')
|
58 |
+
|
59 |
+
global model
|
60 |
+
global pipelines
|
61 |
+
global thresh
|
62 |
+
|
63 |
+
thresh = 0.5
|
64 |
+
if hasattr(cfg.model.base_model, 'backbone'):
|
65 |
+
cfg.model.base_model.backbone.pretrained = None
|
66 |
+
else:
|
67 |
+
cfg.model.base_model.pretrained = None
|
68 |
+
model = build_detector(cfg.model)
|
69 |
+
if os.path.exists(model_path):
|
70 |
+
checkpoint = torch.load(model_path, map_location='cpu')['state_dict']
|
71 |
+
model.load_state_dict(checkpoint, strict=True)
|
72 |
+
print("load %s finish" % (os.path.basename(model_path)))
|
73 |
+
else:
|
74 |
+
print("%s not exist" % model_path)
|
75 |
+
exit(1)
|
76 |
+
model.eval()
|
77 |
+
|
78 |
+
pipelines = Compose(cfg.data.val[0].pipeline)
|
79 |
+
|
80 |
+
iface = gr.Interface(
|
81 |
+
predict,
|
82 |
+
inputs=gr.inputs.Image(label="Upload image to detect", type="filepath"),
|
83 |
+
# outputs=['text', 'image'],
|
84 |
+
outputs=[gr.outputs.Textbox(type="text", label="image forgery score"),
|
85 |
+
gr.outputs.Image(type="numpy", label="predict mask")],
|
86 |
+
title="Forged? Or Not?",
|
87 |
+
)
|
88 |
+
# iface.launch(server_name='0.0.0.0', share=True)
|
89 |
+
iface.launch()
|
90 |
|
image_forgery_detection/__init__.py
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
from .models import *
|
2 |
+
from .datasets import *
|
image_forgery_detection/__pycache__/__init__.cpython-37.pyc
ADDED
Binary file (261 Bytes). View file
|
|
image_forgery_detection/__pycache__/__init__.cpython-38.pyc
ADDED
Binary file (231 Bytes). View file
|
|
image_forgery_detection/datasets/__init__.py
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
from .builder import PIPELINES
|
2 |
+
from .pipelines import Compose
|
image_forgery_detection/datasets/__pycache__/__init__.cpython-37.pyc
ADDED
Binary file (299 Bytes). View file
|
|
image_forgery_detection/datasets/__pycache__/__init__.cpython-38.pyc
ADDED
Binary file (279 Bytes). View file
|
|
image_forgery_detection/datasets/builder.cpython-38-x86_64-linux-gnu.so
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:b6258d802b4f33ec6c10d44a65c053e0d8548c4bee5a2b9272605ff975768993
|
3 |
+
size 393312
|
image_forgery_detection/datasets/dct_pipelines.cpython-38-x86_64-linux-gnu.so
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:a14714f357f77eaf39d03107bdd528ae7fb31cd95d3051f369e9832784c88f36
|
3 |
+
size 5123688
|
image_forgery_detection/datasets/pipelines.cpython-38-x86_64-linux-gnu.so
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:b131c8a66922abb17feb48af0e944eeb3cf51fe7f02833975f155f10ba247bb6
|
3 |
+
size 9644960
|
image_forgery_detection/models/__init__.py
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from .builder import build_detector, build_loss, build_base_model, build_backbone
|
2 |
+
from .detector import Detector
|
3 |
+
from .losses import BinaryDiceLoss, CrossEntropyLoss, FocalLoss
|
4 |
+
from .pan import PAN
|
5 |
+
from .deeplabv3 import DeepLabV3, DeepLabV3Plus
|
6 |
+
from .fpn import FPN
|
7 |
+
from .hooks import CosineAnnealingWarmRestartsLrUpdaterHook
|
8 |
+
from .pvtv2 import PVTv2B2, PVTv2B0
|
9 |
+
from .transforensics import TransForensics, TransForensics_v2, TransForensics_v3, TransForensics_v4
|
10 |
+
from .transforensics_detector import TransForensicsDetector
|
11 |
+
from .psccnet import PSCCNet
|
12 |
+
from .psccnet_detector import PSCCDetector
|
13 |
+
from .network_CAT import CAT_Net, CAT_Net_ORI
|
14 |
+
|
15 |
+
|
16 |
+
__all__ = ['build_detector', 'build_loss', 'build_base_model', 'FocalLoss',
|
17 |
+
'Detector', 'BinaryDiceLoss', 'CrossEntropyLoss', 'PAN', 'DeepLabV3',
|
18 |
+
'DeepLabV3Plus', 'FPN', 'CosineAnnealingWarmRestartsLrUpdaterHook',
|
19 |
+
'PVTv2B2', 'PVTv2B0',
|
20 |
+
'build_backbone',
|
21 |
+
'TransForensics', 'TransForensicsDetector', 'TransForensics_v2', 'TransForensics_v3']
|
image_forgery_detection/models/__pycache__/__init__.cpython-37.pyc
ADDED
Binary file (790 Bytes). View file
|
|
image_forgery_detection/models/__pycache__/__init__.cpython-38.pyc
ADDED
Binary file (1.25 kB). View file
|
|
image_forgery_detection/models/builder.cpython-38-x86_64-linux-gnu.so
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:095d781a5d958833a1d6a5eaf9100e4a2a56f3d479b2b2f1509737d0b9e8e3fb
|
3 |
+
size 233224
|
image_forgery_detection/models/deeplabv3.cpython-38-x86_64-linux-gnu.so
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:d1a18f7b931b6deb0e66188537e25c5f6bf74948329d82f67d405c7d0ec10805
|
3 |
+
size 1918176
|
image_forgery_detection/models/detector.cpython-38-x86_64-linux-gnu.so
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:8bd163965de6519576821e9de6b2a5ce670f8eb07cda52f0bec9c44c74acd1c7
|
3 |
+
size 1158392
|
image_forgery_detection/models/fpn.cpython-38-x86_64-linux-gnu.so
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:6e6de24e7362e067b596bf08395e8d45c833608c88fe1172eb6a5b565ffd8867
|
3 |
+
size 1234352
|
image_forgery_detection/models/hooks.cpython-38-x86_64-linux-gnu.so
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:e922056f65a26e7a452110e9e4ddbae2574e6161196a0236661421ebd46db481
|
3 |
+
size 222424
|
image_forgery_detection/models/init.cpython-38-x86_64-linux-gnu.so
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:ec936df0f17d020e8ec1a8e04785b6afa31927df7a5cdcb3372512763837c24c
|
3 |
+
size 395232
|
image_forgery_detection/models/losses.cpython-38-x86_64-linux-gnu.so
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:d403fa5f59c942536833b8d74cd1e47d9a362ca4da3844d5a486f22eb1f70667
|
3 |
+
size 2052920
|
image_forgery_detection/models/network_CAT.cpython-38-x86_64-linux-gnu.so
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:ae5eae15fc2e5b2b85d2bb1c56bbe9e8e2bf1a2b3502ad85eb95d90835070fef
|
3 |
+
size 9384992
|
image_forgery_detection/models/objectformer_detector.cpython-38-x86_64-linux-gnu.so
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:8ffe63d1de50262518cac62f1cf4886f1b3ad2ef8aa71a007c0ed99564effbad
|
3 |
+
size 1178560
|
image_forgery_detection/models/pan.cpython-38-x86_64-linux-gnu.so
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:e73cc6e52a824cd1bde0da432835e05f64a6ee5f49c1b98307c20525560c1e48
|
3 |
+
size 1503648
|
image_forgery_detection/models/psccnet.cpython-38-x86_64-linux-gnu.so
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:579504b1d0225e486402c48d205c172969a7b88437eadf7ad1fa2d60dd1f8e98
|
3 |
+
size 4484208
|
image_forgery_detection/models/psccnet_detector.cpython-38-x86_64-linux-gnu.so
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:ddb1e329705db03395cb0ddf4b8d6ead50ca54b6a80ee2c66571d447a0c0010d
|
3 |
+
size 7240984
|
image_forgery_detection/models/pvtv2.cpython-38-x86_64-linux-gnu.so
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:9e788058cb21600674711a857c5c8845a8bc0cf5bda87017a8d56d385f53b506
|
3 |
+
size 4404952
|
image_forgery_detection/models/seg_hrnet.cpython-38-x86_64-linux-gnu.so
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:1d034ff3fc49a2d8032314fe1ca1ad33637c76392da0abacd2d948618866075b
|
3 |
+
size 3270904
|
image_forgery_detection/models/transforensics.cpython-38-x86_64-linux-gnu.so
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:7a673782ed78d9a9ad33583f5d22b4168c87b46e0daefa156de72eb830497ec6
|
3 |
+
size 7428232
|
image_forgery_detection/models/transforensics_detector.cpython-38-x86_64-linux-gnu.so
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:d049068cd538a5ec8811ca6411b06acc8824438d9ab1eeac3811281a618369cc
|
3 |
+
size 2900224
|
image_forgery_detection/models/utils.cpython-38-x86_64-linux-gnu.so
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:481324afcbd357d0efee758dbefdf19de8915cd031e70281e0ccf6f1ded0f394
|
3 |
+
size 364432
|
models/config.py
ADDED
@@ -0,0 +1,145 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
work_dir = 'records/guoshoucai_auto_gen_ps_with_tianchi_psccnet_baseline_dct_balance_scale_0_05_1_0_15_epochs_cls_weight_1_5_more_negs_seed_4567'
|
2 |
+
dataset_type = 'MaskSegDatasetv2'
|
3 |
+
img_norm_cfg = dict(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225])
|
4 |
+
input_size = (512, 512)
|
5 |
+
train_pre_pipeline = [
|
6 |
+
dict(type='LoadImageFromFile'),
|
7 |
+
dict(
|
8 |
+
type='LoadAnnotations', binary=True, train=True, img_label_binary=True)
|
9 |
+
]
|
10 |
+
train_post_pipeline = [
|
11 |
+
dict(type='SimpleResize', size=(512, 512)),
|
12 |
+
dict(type='RandomFlip', prob=0.5),
|
13 |
+
dict(
|
14 |
+
type='Normalizev2',
|
15 |
+
mean=[0.485, 0.456, 0.406],
|
16 |
+
std=[0.229, 0.224, 0.225]),
|
17 |
+
dict(type='DefaultFormatBundle'),
|
18 |
+
dict(type='Collect', keys=['img', 'gt_semantic_seg', 'img_label'])
|
19 |
+
]
|
20 |
+
test_pipeline = [
|
21 |
+
dict(type='LoadImageFromFile'),
|
22 |
+
dict(type='SimpleResize', size=(512, 512)),
|
23 |
+
dict(
|
24 |
+
type='Normalizev2',
|
25 |
+
mean=[0.485, 0.456, 0.406],
|
26 |
+
std=[0.229, 0.224, 0.225]),
|
27 |
+
dict(type='ImageToTensor', keys=['img']),
|
28 |
+
dict(type='Collect', keys=['img'])
|
29 |
+
]
|
30 |
+
data = dict(
|
31 |
+
samples_per_gpu=1,
|
32 |
+
workers_per_gpu=4,
|
33 |
+
train=dict(
|
34 |
+
type='MaskSegDatasetv2',
|
35 |
+
data_root='/mnt/disk1/data/image_forgery/text_forgery',
|
36 |
+
ann_path='guoshoucai_auto_gen_ps_with_tianchi_1.txt',
|
37 |
+
pipeline=[[{
|
38 |
+
'type': 'LoadImageFromFile'
|
39 |
+
}, {
|
40 |
+
'type': 'LoadAnnotations',
|
41 |
+
'binary': True,
|
42 |
+
'train': True,
|
43 |
+
'img_label_binary': True
|
44 |
+
}],
|
45 |
+
[{
|
46 |
+
'type': 'SimpleResize',
|
47 |
+
'size': (512, 512)
|
48 |
+
}, {
|
49 |
+
'type': 'RandomFlip',
|
50 |
+
'prob': 0.5
|
51 |
+
}, {
|
52 |
+
'type': 'Normalizev2',
|
53 |
+
'mean': [0.485, 0.456, 0.406],
|
54 |
+
'std': [0.229, 0.224, 0.225]
|
55 |
+
}, {
|
56 |
+
'type': 'DefaultFormatBundle'
|
57 |
+
}, {
|
58 |
+
'type': 'Collect',
|
59 |
+
'keys': ['img', 'gt_semantic_seg', 'img_label']
|
60 |
+
}]]),
|
61 |
+
val=[
|
62 |
+
dict(
|
63 |
+
type='MaskSegDatasetv2',
|
64 |
+
data_root=
|
65 |
+
'/mnt/disk1/data/image_forgery/text_forgery/guoshoucai_auto_gen/test_forged_with_ps',
|
66 |
+
ann_path='test_1.txt',
|
67 |
+
test_mode=True,
|
68 |
+
pipeline=[
|
69 |
+
dict(type='LoadImageFromFile'),
|
70 |
+
dict(type='SimpleResize', size=(512, 512)),
|
71 |
+
dict(
|
72 |
+
type='Normalizev2',
|
73 |
+
mean=[0.485, 0.456, 0.406],
|
74 |
+
std=[0.229, 0.224, 0.225]),
|
75 |
+
dict(type='ImageToTensor', keys=['img']),
|
76 |
+
dict(type='Collect', keys=['img'])
|
77 |
+
],
|
78 |
+
dataset_name='guoshoucai_text',
|
79 |
+
gt_seg_map_loader_cfg=dict(binary=True, img_label_binary=True)),
|
80 |
+
dict(
|
81 |
+
type='MaskSegDatasetv2',
|
82 |
+
data_root=
|
83 |
+
'/mnt/disk1/data/image_forgery/text_forgery/tianchi_text_forgory',
|
84 |
+
ann_path='val.txt',
|
85 |
+
test_mode=True,
|
86 |
+
pipeline=[
|
87 |
+
dict(type='LoadImageFromFile'),
|
88 |
+
dict(type='SimpleResize', size=(512, 512)),
|
89 |
+
dict(
|
90 |
+
type='Normalizev2',
|
91 |
+
mean=[0.485, 0.456, 0.406],
|
92 |
+
std=[0.229, 0.224, 0.225]),
|
93 |
+
dict(type='ImageToTensor', keys=['img']),
|
94 |
+
dict(type='Collect', keys=['img'])
|
95 |
+
],
|
96 |
+
dataset_name='tianchi',
|
97 |
+
gt_seg_map_loader_cfg=dict(binary=True, img_label_binary=True))
|
98 |
+
])
|
99 |
+
norm_cfg = dict(type='SyncBN', requires_grad=True)
|
100 |
+
model = dict(
|
101 |
+
type='PSCCDetector',
|
102 |
+
base_model=dict(
|
103 |
+
type='PSCCNet',
|
104 |
+
crop_size=(512, 512),
|
105 |
+
pretrained=
|
106 |
+
'/home/yangwu/.cache/torch/checkpoints/hrnet_w18_small_v2.pth'),
|
107 |
+
train_cfg=dict(
|
108 |
+
seg_loss=dict(type='BCELoss', reduction='none'),
|
109 |
+
seg_loss_weights=(1.0, 1.0),
|
110 |
+
mask_loss_weights=(1.0, 1.0, 1.0, 1.0),
|
111 |
+
cls_loss=dict(
|
112 |
+
type='CrossEntropyLoss',
|
113 |
+
use_sigmoid=False,
|
114 |
+
class_weight=(1.0, 1.0)),
|
115 |
+
p_balance_scale=0.05,
|
116 |
+
n_balance_scale=1.0),
|
117 |
+
test_cfg=dict())
|
118 |
+
optimizer = dict(type='Adam', lr=0.0001, weight_decay=1e-05)
|
119 |
+
optimizer_config = dict()
|
120 |
+
lr_config = dict(policy='CosineAnnealing', min_lr=1e-07, by_epoch=False)
|
121 |
+
runner = dict(type='IterBasedRunner', max_iters=121960)
|
122 |
+
checkpoint_config = dict(by_epoch=False, interval=4065, max_keep_ckpts=1)
|
123 |
+
evaluation = dict(
|
124 |
+
interval=4065,
|
125 |
+
metric='mFscore',
|
126 |
+
pre_eval=True,
|
127 |
+
mean=False,
|
128 |
+
thresh=0.5,
|
129 |
+
img_thresh=0.5)
|
130 |
+
log_config = dict(
|
131 |
+
interval=50,
|
132 |
+
hooks=[
|
133 |
+
dict(type='TextLoggerHook', by_epoch=False),
|
134 |
+
dict(type='TensorboardLoggerHook')
|
135 |
+
])
|
136 |
+
ext_test_dataset = ['CASIA1']
|
137 |
+
dist_params = dict(backend='nccl')
|
138 |
+
log_level = 'INFO'
|
139 |
+
load_from = None
|
140 |
+
resume_from = None
|
141 |
+
workflow = [('train', 1)]
|
142 |
+
cudnn_benchmark = True
|
143 |
+
find_unused_parameters = False
|
144 |
+
auto_resume = False
|
145 |
+
gpu_ids = range(0, 4)
|
models/latest.pth
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:879c5772b8827818873cb59b82885ea7fc4ea14e93050439d6540cfd6d837ed6
|
3 |
+
size 44506265
|
requirements.txt
CHANGED
@@ -1 +1,24 @@
|
|
1 |
requests
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
requests
|
2 |
+
torch
|
3 |
+
torchvision
|
4 |
+
pytorch-lightning
|
5 |
+
lightning-bolts
|
6 |
+
tqdm
|
7 |
+
wandb
|
8 |
+
segmentation_models_pytorch
|
9 |
+
albumentations==0.4.3
|
10 |
+
pandas
|
11 |
+
loguru
|
12 |
+
matplotlib
|
13 |
+
tensorboard
|
14 |
+
mmcv
|
15 |
+
docutils
|
16 |
+
PyYAML
|
17 |
+
prettytable
|
18 |
+
pytesseract
|
19 |
+
sklearn
|
20 |
+
einops
|
21 |
+
pyclipper
|
22 |
+
shapely
|
23 |
+
lmdb
|
24 |
+
jpegio
|