Giter VIP home page Giter VIP logo

Comments (8)

APPLE-XMT avatar APPLE-XMT commented on August 17, 2024

你好我想请问一下这个问题你解决了吗

from mimn.

ToriZumi avatar ToriZumi commented on August 17, 2024

为什么现在数据集文件都不一样了

from mimn.

Wangjii avatar Wangjii commented on August 17, 2024

不是没有读取到文件,是因为有几张图片的大小是1*1,过res50的时候会报错

from mimn.

pppxk avatar pppxk commented on August 17, 2024

不是没有读取到文件,是因为有几张图片的大小是1*1,过res50的时候会报错

请问这个问题您解决了嘛?

from mimn.

Wangjii avatar Wangjii commented on August 17, 2024

不是没有读取到文件,是因为有几张图片的大小是1*1,过res50的时候会报错

请问这个问题您解决了嘛?

因为没有其他途径获得完好的数据集,所以将有问题的图片跳过了。

from mimn.

pppxk avatar pppxk commented on August 17, 2024

不是没有读取到文件,是因为有几张图片的大小是1*1,过res50的时候会报错

请问这个问题您解决了嘛?

因为没有其他途径获得完好的数据集,所以将有问题的图片跳过了。

请问您有把所有图片的尺寸都改成224*224吗?我发现如果图片的分辨率很高的话也是会报这个错误的

from mimn.

triangleXIV avatar triangleXIV commented on August 17, 2024

他有些句子没有对应的图片,img这个列表是空的,直接len(img[0])就会报错

from mimn.

triangleXIV avatar triangleXIV commented on August 17, 2024

他有些句子没有对应的图片,img这个列表是空的,直接len(img[0])就会报错

自己研究了一下,将data_utils.py的read_img这个函数换成如下我重写的函数就行了,原理就是把所有数据都放到GPU上,之前的数据是放在内存上的,不好管理,8G显存3070读取整个数据集无报错。

def read_img(self, imgs_path):
    imgs = []
    with torch.no_grad():
        self.cnn_extractor.to('cuda')
        for j in range(len(imgs_path)):
            img_path = imgs_path[j].strip().replace('\'', '')
            try:
                img = Image.open('./datasets/img/' + img_path).convert('RGB')
                input = self.transform_img(img).unsqueeze(0).to('cuda')
                output = self.cnn_extractor(input).squeeze()
                imgs.append(output)
                img.close()
            except:
                error = 1
    torch.cuda.empty_cache()
    embed_dim_img = len(imgs[0])
    #embed_dim_img = 2048
    img_features = torch.zeros(self.max_img_len, embed_dim_img)
    num_imgs = len(imgs)
    if num_imgs >= self.max_img_len:
        for i in range(self.max_img_len):
            img_features[i,:] = imgs[i]
    else:
        for i in range(self.max_img_len):
            if i < num_imgs:
                # img_features[(self.max_img_len-num_imgs)+i,:] = imgs[i]
                img_features[i, :] = imgs[i]
            else:
                break
    return img_features, min(self.max_img_len, num_imgs)

from mimn.

Related Issues (9)

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.