chelsea234 / hifi_ifdl Goto Github PK
View Code? Open in Web Editor NEWHierarchical Fine-Grained Image Forgery Detection and Localization (CVPR2023)
Hierarchical Fine-Grained Image Forgery Detection and Localization (CVPR2023)
Are there any plans for a google colab notebook, with my GPU and the sizes of the datasets it's very hard to run it on my local machine, if yes, when can we expect it? Thank you!
Great work, I'll keep waiting your dataset!
Hello, this problem occurred when using the latest weights you provided. Can you help me?
weights/HRNet weight-loading succeeds: weights/HRNet/225000.pth
weights/HRNet_params: 6361208
weights/NLCDetection weight-loading fails
weights/NLCDetection_params: 528923
hello! i notice that inside the inpainting.txt file you gave are some lines really confuse me .
there are lines ,such as s_1.jpg ,s_1t.jpg ...... and also some coco dataset files name . i notice that the former is from the coverage dataset.
but for coverage dataset filename :s_1.jpg ...... is a real image ,and also coco dataset are real images ,but inpainting.txt belongs to fake images set . i think they should not inside the inpating.txt .
and can you give the copy_move.txt and inpating.txt files ? thank you very much!!!
Dear author, hello! I find your project very interesting. I downloaded the qualitative results you provided and noticed that some of the predicted results in the images seem to differ from the results posted in your paper. Could you please let me know if there's an issue with my operation?
Tried to evaluate the model on CASIA dataset following Quick Usage. And I've got pretty bad results, so I'm wondering what I'm doing wrong? According to the paper CASIA dataset should be covered pretty well.
These are my results:
For CASIA1
Actual
Fake Real
Predicted Fake 71 156
Real 729 765
For CASIA2
Actual
Fake Real
Predicted Fake 732 313
Real 4391 7124
Here's the script which I used:
import os
import sys
from HiFi_Net import HiFi_Net
HiFi = HiFi_Net() # initialize
fake = 0
real = 0
def run():
if len(sys.argv) != 2:
print("Usage: python demo.py <path_to_dir>")
sys.exit(1)
processed = 0
img_dir = sys.argv[1]
for root, dirs, files in os.walk(img_dir):
for file in files:
filepath = os.path.join(root, file)
ext = os.path.splitext(filepath)[-1].lower()
if ext in {".jpg", ".jpeg", ".png", ".tiff", ".tif", ".bmp"}:
process_file(filepath)
processed += 1
if processed % 100 == 0:
print(f"Processed {processed} images")
print(f"Fake: {fake}, Real: {real}")
print(f"Processed {processed} images")
print(f"Fake: {fake}, Real: {real}")
def process_file(img_path: str):
global fake, real
## detection
res3, prob3 = HiFi.detect(img_path, verbose=False)
# print(res3, prob3)
if res3 == 0:
real += 1
else:
fake += 1
run()
I've tried to simply add some copy-and-move operations on "sample_2":
I use the inference script and weights provided, but it only shows the old manipulations and ignores the new ones.
The output mask with input image
I have tested on several real photos by simply adding texts, still not work.
hello,Thank you for your work.
I have a trouble when I run bash HiFi_Net_loc.sh
RuntimeError: Attempting to deserialize object on a CUDA device but torch.cuda.is_available() is False. If you are running on a CPU-only machine, please use torch.load with map_location=torch.device('cpu') to map your storages to the CPU.
what should I do to make it correct,thank you so much
In order for others to reproduce or create derivative works, the repo should be assigned a permissive license. By default full prohibitive copyright applies.
THANKS FOR YOUR WONDERFUL WORK.
I test the model by HiFi_Net.py,but got ped_mask.png which is all black and the confidence is outputed correctly.
Can u tell me the reason?
Can you provide the list and ground truth of the CopyMove dataset, please? I attempted to download the BusterNet dataset, but without success.
Additionally,I didn't see datasets for splice, inpainting, STYL2, and STYL3 in the datasets you provided. Could you please provide them as well?.
Thank you very much.
When I use the code:
from HiFi_Net import HiFi_Net
from PIL import Image
import numpy as np
import os
HiFi = HiFi_Net() # initialize
img_path = 'asset/sample_1.jpg'
root = "/eva_data0/denny/textual_inversion/debug/0_real/"
paths = [os.path.join(root, f) for f in os.listdir(root)]
for img_path in paths:
print(img_path)
# detection
res3, prob3 = HiFi.detect(img_path)
# print(res3, prob3) 1 1.0
HiFi.detect(img_path, verbose=True)
I got the error below when loading the weights of NLCDetection:
Error(s) in loading state_dict for DataParallel:
Missing key(s) in state_dict: "module.getmask.getmask.0.weight", "module.getmask.getmask.0.bias", "module.getmask.getmask.2.weight", "module.getmask.getmask.2.bias".
Unexpected key(s) in state_dict: "module.FPN_LOC.smooth_s4.0.weight", "module.FPN_LOC.smooth_s4.0.bias", "module.FPN_LOC.smooth_s4.1.weight", "module.FPN_LOC.smooth_s4.1.bias",
"module.FPN_LOC.smooth_s3.0.weight", "module.FPN_LOC.smooth_s3.0.bias", "module.FPN_LOC.smooth_s3.1.weight", "module.FPN_LOC.smooth_s3.1.bias", "module.FPN_LOC.smooth_s2.0.weight", "m
odule.FPN_LOC.smooth_s2.0.bias", "module.FPN_LOC.smooth_s2.1.weight", "module.FPN_LOC.smooth_s2.1.bias", "module.FPN_LOC.smooth_s1.0.weight", "module.FPN_LOC.smooth_s1.0.bias", "module
.FPN_LOC.smooth_s1.1.weight", "module.FPN_LOC.smooth_s1.1.bias", "module.FPN_LOC.fpn1.0.weight", "module.FPN_LOC.fpn1.1.weight", "module.FPN_LOC.fpn1.1.bias", "module.FPN_LOC.fpn1.1.ru
nning_mean", "module.FPN_LOC.fpn1.1.running_var", "module.FPN_LOC.fpn1.1.num_batches_tracked", "module.FPN_LOC.fpn2.0.weight", "module.FPN_LOC.fpn2.1.weight", "module.FPN_LOC.fpn2.1.bi
as", "module.FPN_LOC.fpn2.1.running_mean", "module.FPN_LOC.fpn2.1.running_var", "module.FPN_LOC.fpn2.1.num_batches_tracked", "module.FPN_LOC.fpn3.0.weight", "module.FPN_LOC.fpn3.1.weig
ht", "module.FPN_LOC.fpn3.1.bias", "module.FPN_LOC.fpn3.1.running_mean", "module.FPN_LOC.fpn3.1.running_var", "module.FPN_LOC.fpn3.1.num_batches_tracked", "module.FPN_LOC.fpn4.0.weight
", "module.FPN_LOC.fpn4.1.weight", "module.FPN_LOC.fpn4.1.bias", "module.FPN_LOC.fpn4.1.running_mean", "module.FPN_LOC.fpn4.1.running_var", "module.FPN_LOC.fpn4.1.num_batches_tracked",
"module.getmask.conv_1.weight", "module.getmask.conv_1.bias", "module.getmask.conv_2.weight", "module.getmask.conv_2.bias".
size mismatch for module.getmask.g.weight: copying a param with shape torch.Size([1024, 1024, 1, 1]) from checkpoint, the shape in current model is torch.Size([288, 288, 1, 1]).
size mismatch for module.getmask.g.bias: copying a param with shape torch.Size([1024]) from checkpoint, the shape in current model is torch.Size([288]).
size mismatch for module.getmask.theta.weight: copying a param with shape torch.Size([1024, 1024, 1, 1]) from checkpoint, the shape in current model is torch.Size([288, 288, 1,
1]).
size mismatch for module.getmask.theta.bias: copying a param with shape torch.Size([1024]) from checkpoint, the shape in current model is torch.Size([288]).
size mismatch for module.getmask.phi.weight: copying a param with shape torch.Size([1024, 1024, 1, 1]) from checkpoint, the shape in current model is torch.Size([288, 288, 1, 1
]).
size mismatch for module.getmask.phi.bias: copying a param with shape torch.Size([1024]) from checkpoint, the shape in current model is torch.Size([288]).
size mismatch for module.getmask.W_s.weight: copying a param with shape torch.Size([64, 64, 1, 1]) from checkpoint, the shape in current model is torch.Size([18, 18, 1, 1]).
size mismatch for module.getmask.W_s.bias: copying a param with shape torch.Size([64]) from checkpoint, the shape in current model is torch.Size([18]).
size mismatch for module.branch_cls_level_1.branch_cls.0.weight: copying a param with shape torch.Size([32, 317, 3, 3]) from checkpoint, the shape in current model is torch.Size([32, 271, 3, 3]).
I've downloaded the "HRNet" and "NLCDetection" folders and put then into the "weights" folder, any ideas for solving the problem?
Thank you in advance!
Hi, is there another download path for the dataset? Thank you for your time.
你好,请问数据集还有其他下载路径吗 ?谢谢
Thanks for your nice work! I wonder to test the model on the Coverage datasets. Can you share the code for model fine-tuning?
Hey, I set up the config.py and downloaded the weights from gdrive and when I run the eval.py code provided I get really odd localizations. I'm trying to run it on the Korus realistic tampered dataset which is ~220 1080x1920 TIFF images heres my code
from HiFi_Net import HiFi_Net
from PIL import Image
import numpy as np
import os
HiFi = HiFi_Net() # initialize
img_dir = 'korus/tampered/'
# ## detection
for item in os.listdir(img_dir):
## localization
full_path = os.path.join(img_dir,item)
binary_mask = HiFi.localize(full_path)
binary_mask = Image.fromarray((binary_mask*255.).astype(np.uint8))
binary_mask.save(f'{item}')
Note: I also try running like this but replace korus/tampered with IMD2020/tampered and get similarly weird prediction maps do you have an idea of what I might be messing up?
Hi , I want to know what kind of GPU device is required to train this model
Hello! I realized that the txt files of the datasets are not provided in your code, especially the test datasets (e.g. CASIA, NIST), which makes it impossible for me to run the training and test code, and I am not clear about the specific data division, can you provide the relevant txt files please?
btw, I would like to know exactly which parts of the dataset you used for model training?
Good job on creating the dataset. Can you release the groundtruth mask images and original pristine images for the CopyMove images in Dataset Link? There are only 100K forged images in the CopyMove folder.
博主您好,很感谢您分享代码与学识。我想要在本地复现,权重与环境均以配置好,可我发现之前的本地训练文件train.py被更新删除了,现在我该如何训练本地模型,“要将预训练模型应用于图像,然后获得结果,请运行 ./data_dir ./viz_eval”,是需要运行之前的train文件嘛。谢谢您的解惑。
When was the image determined to be true/false? Was it during the first time on theta4? Also, I would like to know how the Hierarchy Path Prediction works to determine the classification of each level. Is there any good data to assist in understanding?
你好,首先感谢您的开源代码。我在使用的过程中,检测结果出现了全黑的情况,我使用的是“Quick Usage on Detection and Localization:”这个标题下的权重文件和代码。即使是检测代码中“asset”文件夹下的“sample_4.jpg”图片,检测结果也是不正常的,为全白颜色,请问这是什么错误导致的呢?
Hello, I have some questions to ask you.
How much data did you use for training? Did you use the entire HiFi_IFDL data set?
How long have you used to train HiFi-Net?
Looking forward to your answer
When I run the train.sh
command, I noticed that different datasets require different txt files containing the image lists. Can you provide the corresponding txt files?
Thank you for your work! When I run HIFI_Net.py
=> loading HRNet pretrained model models/hrnet_w18_small_v2.pth
no pretrain dict length is: 183
pretrained dict length is: 874
weights/HRNet weight-loading succeeds: weights/HRNet/750001.pth
weights/HRNet_params: 6361208
weights/NLCDetection weight-loading succeeds: weights/NLCDetection/750001.pth
weights/NLCDetection_params: 528923
/root/autodl-tmp/HiFi_Net.py:75: DeprecationWarning: Starting with ImageIO v3 the behavior of this function will switch to that of iio.v3.imread. To keep the current behavior (and make this warning disappear) use import imageio.v2 as imageio
or call imageio.v2.imread
directly.
image = imageio.imread(image_name)
Traceback (most recent call last):
File "/root/autodl-tmp/HiFi_Net.py", line 215, in
inference(args.img_path)
File "/root/autodl-tmp/HiFi_Net.py", line 185, in inference
res3, prob3 = HiFi.detect(img_path)
File "/root/autodl-tmp/HiFi_Net.py", line 136, in detect
img_input = self._transform_image(image_name)
File "/root/autodl-tmp/HiFi_Net.py", line 75, in _transform_image
image = imageio.imread(image_name)
File "/root/miniconda3/lib/python3.8/site-packages/imageio/init.py", line 97, in imread
return imread_v2(uri, format=format, **kwargs)
File "/root/miniconda3/lib/python3.8/site-packages/imageio/v2.py", line 360, in imread
result = file.read(index=0, **kwargs)
File "/root/miniconda3/lib/python3.8/site-packages/imageio/plugins/pillow.py", line 252, in read
image = self._apply_transforms(
File "/root/miniconda3/lib/python3.8/site-packages/imageio/plugins/pillow.py", line 335, in _apply_transforms
meta = self.metadata(index=self._image.tell(), exclude_applied=False)
File "/root/miniconda3/lib/python3.8/site-packages/imageio/plugins/pillow.py", line 537, in metadata
if self._image.getexif():
File "/root/miniconda3/lib/python3.8/site-packages/PIL/Image.py", line 1423, in getexif
self._exif.load_from_fp(self.fp, self.tag_v2._offset)
File "/root/miniconda3/lib/python3.8/site-packages/PIL/Image.py", line 3531, in load_from_fp
self.fp.seek(offset)
AttributeError: 'NoneType' object has no attribute 'seek'
could you please tell where is the wrong?
Hello, thank for your response.
I'm executing in the cmd window.
CUDA_NUM=0
CUDA_VISIBLE_DEVICES=$CUDA_NUM python HiFi_Net_loc.py
As a result, an error is reported in the program.
File "F:\MachineLearning\HiFi_IFDL\utils\load_edata.py", line 109, in __init__
with open(join(ddir, 'vallist.txt')) as f:
FileNotFoundError: [Errno 2] No such file or directory: '/user/guoxia11/cvl/semi
_supervise_local/2021/05_25_SCCM/Dataset/finetune_dataset/columbia/vallist.txt'
I think the error is due to the fact that there is no vallist file under that path, I want to know how to get the file, thanks for the answer.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.