Comments (2)
or can you provide the code for converting lmdb to images in one folder
from fudanocr.
or can you provide the code for converting lmdb to images in one folder
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()
from fudanocr.
Related Issues (20)
- 数据集请求 HOT 2
- 请问text-focused-Transformers model和datasets如何下载 HOT 1
- VCTR dataset read error
- 请问在竖直文本识别那篇论文中,有没有提供预训练模型呢 HOT 2
- How to download VCTR dataset? HOT 2
- How to extract only image after super resolution?
- CCR-CLIP pretraining HOT 2
- About CCR-CLIP pretrained HOT 1
- inference of orientation-independent-CTR ?
- CCR-CLIP使用印刷字体进行增强 HOT 1
- Fix link for Baidu download in text-focused-Transformers/
- train.py的坑:容易误删已训练模型 HOT 2
- lmdb can not find my file. HOT 2
- 关于Chinese-CLIP复现中的几点疑惑,期待答复!
- Question about CCR-CLIP experiment and code HOT 4
- 字典里面的字符是不是不够啊?除了没有逗号,有时候会出现字典里没有这个汉字。 HOT 4
- 是否有HWDB 1.0-1.2 的lmdb数据集 HOT 1
- Please guide, how to perform inference on a single image and get the improved output image?
- For text-focused-transforemer, which version of MMCV and MMSeg should i choose? HOT 1
- Any code about 'Towards Accurate Video Text Spotting with Text-wise Semantic Reasoning'?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fudanocr.