Open gsygsy96 opened 7 years ago
Did you solve the problem? @shanYanGuan
Hi @mehameha998 and @zikai1 ,
In default, OpenCV can support the convertion from .webp
to .jpg
.
I provide the simple script to convert the image into .jpg
format.
# convert.py
from tqdm import tqdm
import argparse
import cv2
import os
parser = argparse.ArgumentParser()
parser.add_argument('--indir', help = "The path of the flat folder")
parser.add_argument('--outdir', help = "The path of the output folder")
args = parser.parse_args()
if not os.path.exists(args.outdir):
os.mkdir(args.outdir)
for img_name in tqdm(os.listdir(args.indir)):
img = cv2.imread(os.path.join(args.indir, img_name))
cv2.imwrite(os.path.join(args.outdir, img_name[:-5] + '.jpg'), img)
The procedure step is list below:
First, you should extract the mdb
file into flat format.
python2.7 data.py export <image db path> --out_dir <output directory> --flat
Next, run the following code to transfer the whole file into JPG format.
python3 convert.py --indir <output_directory> --outdir <final_output_directory>
Hi @mehameha998 and @zikai1 , In default, OpenCV can support the convertion from
.webp
to.jpg
. I provide the simple script to convert the image into.jpg
format.# convert.py from tqdm import tqdm import argparse import cv2 import os parser = argparse.ArgumentParser() parser.add_argument('--indir', help = "The path of the flat folder") parser.add_argument('--outdir', help = "The path of the output folder") args = parser.parse_args() if not os.path.exists(args.outdir): os.mkdir(args.outdir) for img_name in tqdm(os.listdir(args.indir)): img = cv2.imread(os.path.join(args.indir, img_name)) cv2.imwrite(os.path.join(args.outdir, img_name[:-5] + '.jpg'), img)
The procedure step is list below: First, you should extract the
mdb
file into flat format.python2.7 data.py export <image db path> --out_dir <output directory> --flat
Next, run the following code to transfer the whole file into JPG format.
python3 convert.py --indir <output_directory> --outdir <final_output_directory>
It doesn't work. Which version of opencv are you using?
$ python3 convert.py --indir bedroom_train_lmdb --outdir bedroom_train_lmdb
0%| | 0/18 [00:00<?, ?it/s]
Traceback (most recent call last):
File "convert.py", line 16, in <module>
cv2.imwrite(os.path.join(args.outdir, img_name[:-5] + '.jpg'), img)
cv2.error: OpenCV opencv/modules/imgcodecs/src/loadsave.cpp:740: error: (-215:Assertion failed) !_img.empty() in function 'imwrite'
Hi @mehameha998 and @zikai1 , In default, OpenCV can support the convertion from
.webp
to.jpg
. I provide the simple script to convert the image into.jpg
format.# convert.py from tqdm import tqdm import argparse import cv2 import os parser = argparse.ArgumentParser() parser.add_argument('--indir', help = "The path of the flat folder") parser.add_argument('--outdir', help = "The path of the output folder") args = parser.parse_args() if not os.path.exists(args.outdir): os.mkdir(args.outdir) for img_name in tqdm(os.listdir(args.indir)): img = cv2.imread(os.path.join(args.indir, img_name)) cv2.imwrite(os.path.join(args.outdir, img_name[:-5] + '.jpg'), img)
The procedure step is list below: First, you should extract the
mdb
file into flat format.python2.7 data.py export <image db path> --out_dir <output directory> --flat
Next, run the following code to transfer the whole file into JPG format.
python3 convert.py --indir <output_directory> --outdir <final_output_directory>
It doesn't work. Which version of opencv are you using?
$ python3 convert.py --indir bedroom_train_lmdb --outdir bedroom_train_lmdb 0%| | 0/18 [00:00<?, ?it/s] Traceback (most recent call last): File "convert.py", line 16, in <module> cv2.imwrite(os.path.join(args.outdir, img_name[:-5] + '.jpg'), img) cv2.error: OpenCV opencv/modules/imgcodecs/src/loadsave.cpp:740: error: (-215:Assertion failed) !_img.empty() in function 'imwrite'
I got the same error. Did you solve the problem?
I try to utilize this dataset to train my network.But After I export those dataset,I found those're .webp file. So could you tell me how to convert to .png? PS: When I directly train my network with lmdb files in the dataset,an error occurred .Maybe lmdb files have somthing wrong I guess. error:
F0326 01:27:43.210084 15934 data_transformer.cpp:734] Check failed: datum_channels > 0 (0 vs. 0)
If you want jpg format, you can modify the code directly in the export_images image_out_path = join(image_out_dir, key.decode('ascii') + '.jpg')
I try to utilize this dataset to train my network.But After I export those dataset,I found those're .webp file. So could you tell me how to convert to .png? PS: When I directly train my network with lmdb files in the dataset,an error occurred .Maybe lmdb files have somthing wrong I guess. error:
F0326 01:27:43.210084 15934 data_transformer.cpp:734] Check failed: datum_channels > 0 (0 vs. 0)