Giter Site home page Giter Site logo

Comments (2)

yangapku avatar yangapku commented on May 22, 2024

您好,建议可以再参考下readme的预处理说明部分的描述哈。不论是您按照readme的说法自己一步步准备数据,还是直接下载了我们在readme中提供的预处理好的MUGE和Flickr30K-CN数据集,在数据集目录下(${DATAPATH}/datasets/${dataset_name}/,参考readme代码组织部分),应该都有TSV文件(如test_imgs.tsv)和LMDB文件(如test/imgs/data.lmdb),这两个地方都存放了imageid到图片内容的对应关系,都可以使用:

如果用TSV格式文件,TSV文件的格式在readme预处理部分已经给出,可以用imageid找到对应的行,然后对应到图片内容base64编码,然后用readme预处理部分的几行代码把base64还原原始图片

如果用LMDB格式文件,LMDB实际上是个在硬盘中存储的索引文件,您可以参考我们的检索任务示例notebook,找到采样观察数据的几行代码(准备工作→4.预处理数据),大概如下,也可以直接用imageid找到原图:

# 查看数据样例
# 查看query
!head -n 1 datapath/datasets/MUGE/valid_texts.jsonl # 验证集第一条样本

import lmdb
import base64
from io import BytesIO
from PIL import Image

# 查看image
image_ids = [286314, 141999, 183846]

lmdb_imgs = "datapath/datasets/MUGE/lmdb/valid/imgs"
env_imgs = lmdb.open(lmdb_imgs, readonly=True, create=False, lock=False, readahead=False, meminit=False)
txn_imgs = env_imgs.begin(buffers=True)
for image_id in image_ids:
    image_b64 = txn_imgs.get("{}".format(image_id).encode('utf-8')).tobytes()
    img = Image.open(BytesIO(base64.urlsafe_b64decode(image_b64)))
    img.show()

这两种办法都能看到imageid对应的图片哈,后者可以做到随机读取

如果有更多问题,欢迎继续留言。如果觉得Chinese-CLIP代码库对您有帮助,请您为我们点点star⭐️并推荐给身边的朋友们!

from chinese-clip.

597038837 avatar 597038837 commented on May 22, 2024

感谢

from chinese-clip.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.