Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When inference, do I need to convert image to jpg format first? #35

Open
wennyHou opened this issue May 15, 2023 · 3 comments
Open

When inference, do I need to convert image to jpg format first? #35

wennyHou opened this issue May 15, 2023 · 3 comments

Comments

@wennyHou
Copy link

When inference, do I need to convert image to jpg format first? Thanks

@CauchyComplete
Copy link
Collaborator

CAT-Net requires a JPEG image as input but the inference code automatically converts a non-JPEG image to JPEG at the very beginning.

@FathUMinUllah3797
Copy link

@CauchyComplete Do we need to convert all the images into jpg before training? If yes, why there are still images with .tiff and .png extension in the lists you provided. Please response to this query as I am getting the following error.

[LIBJPEG ERROR]: Not a JPEG file: starts with 0x49 0x49
[LIBJPEG] Error occurs during reading file.
Traceback (most recent call last):
File "D:\ImageManipulation\CAT-Net-main\CAT-Net-main\tools\train.py", line 233, in
main()
File "D:\ImageManipulation\CAT-Net-main\CAT-Net-main\tools\train.py", line 185, in main
trainloader, optimizer, model, writer_dict, final_output_dir)
File "D:\ImageManipulation\CAT-Net-main\CAT-Net-main\tools..\lib\core\function.py", line 58, in train
for i_iter, (images, labels, qtable) in enumerate(trainloader):
File "C:\Users\MSI\anaconda3\envs\cat\lib\site-packages\torch\utils\data\dataloader.py", line 521, in next
data = self._next_data()
File "C:\Users\MSI\anaconda3\envs\cat\lib\site-packages\torch\utils\data\dataloader.py", line 561, in _next_data
data = self._dataset_fetcher.fetch(index) # may raise StopIteration
File "C:\Users\MSI\anaconda3\envs\cat\lib\site-packages\torch\utils\data_utils\fetch.py", line 49, in fetch
data = [self.dataset[idx] for idx in possibly_batched_index]
File "C:\Users\MSI\anaconda3\envs\cat\lib\site-packages\torch\utils\data_utils\fetch.py", line 49, in
data = [self.dataset[idx] for idx in possibly_batched_index]
File "D:\ImageManipulation\CAT-Net-main\CAT-Net-main\tools..\Splicing\data\data_core.py", line 99, in getitem
return self.dataset_list[index//self.smallest].get_tamp(index%self.smallest)
File "D:\ImageManipulation\CAT-Net-main\CAT-Net-main\tools..\Splicing\data\dataset_CASIA.py", line 55, in get_tamp
return self._create_tensor(tamp_path, mask)
File "D:\ImageManipulation\CAT-Net-main\CAT-Net-main\tools..\Splicing\data\AbstractDataset.py", line 111, in _create_tensor
DCT_coef, qtables = self._get_jpeg_info(im_path)
File "D:\ImageManipulation\CAT-Net-main\CAT-Net-main\tools..\Splicing\data\AbstractDataset.py", line 44, in _get_jpeg_info
jpeg = jpegio.read(str(im_path))
File "C:\Users\MSI\anaconda3\envs\cat\lib\site-packages\jpegio\io.py", line 10, in read
obj.read(fpath)
File "jpegio\decompressedjpeg.pyx", line 62, in jpegio.decompressedjpeg.DecompressedJpeg.read
File "jpegio\decompressedjpeg.pyx", line 80, in jpegio.decompressedjpeg.DecompressedJpeg.read
OSError: An error has occurs in reading the file.
[LIBJPEG ERROR]: Improper call to JPEG library in state 0

@CauchyComplete
Copy link
Collaborator

In the inference dataset(dataset='arbitrary'), non-JPEG images are automatically converted to JPEG files and plugged into the model:

test_dataset = splicing_dataset(crop_size=None, grid_crop=True, blocks=('RGB', 'DCTvol', 'qtable'), DCT_channels=1, mode='arbitrary', read_from_jpeg=True) # full model

During training, we should manually convert them into JPEG files.

I implemented it like this for speed-up training because training uses converted files multiple times.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants