We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
No description provided.
The text was updated successfully, but these errors were encountered:
or can you provide the code for converting lmdb to images in one folder
Sorry, something went wrong.
import cv2 import lmdb import numpy as np import os root_path = 'D:\Python_Project\TextSR\TextZoom-master\dataset\lmdb\str\TextZoom/' sub_path = 'test/medium/' save_path='./Images/' + sub_path # 图片存储路径 if not os.path.exists(save_path): os.mkdir(save_path) env = lmdb.open(root_path+sub_path) imgdir_list1 = [] imgdir_list2 = [] label_list = [] with env.begin(write=False) as txn: for key, value in txn.cursor(): type = key.decode('utf-8').split('-')[0] if key.decode('utf-8') == 'num-samples': print(key ,value) break if type!='label': if type.split('_')[1] == 'hr': # hr图像 image_name = key.decode('utf-8') image_buf = np.frombuffer(value, dtype=np.uint8) # # 将数据转换(解码)成图像格式 # # cv2.IMREAD_GRAYSCALE为灰度图,cv2.IMREAD_COLOR为彩色图 img = cv2.imdecode(image_buf, cv2.IMREAD_COLOR) cv2.imwrite(save_path + image_name + '.png', img) imgdir_list1.append(save_path + image_name + '.png') else: # lr图像 image_name = key.decode('utf-8') image_buf = np.frombuffer(value, dtype=np.uint8) # # 将数据转换(解码)成图像格式 # # cv2.IMREAD_GRAYSCALE为灰度图,cv2.IMREAD_COLOR为彩色图 img = cv2.imdecode(image_buf, cv2.IMREAD_COLOR) cv2.imwrite(save_path + image_name + '.png', img) imgdir_list2.append(save_path + image_name + '.png') else: # 标签 label_list.append(value.decode('utf-8')) print(key ,value) env.close()
No branches or pull requests
No description provided.
The text was updated successfully, but these errors were encountered: