Загрузка набора данных для обучения модели - PullRequest
0 голосов
/ 12 апреля 2020
#load the data 
def load_photos(filename):
    file = load_doc("C:/Users/Project/Flickr8k_text/Flickr_8k.trainImages.txt")
    photos = file.split("\n")[:-1]
    return photos

def load_clean_descriptions(filename, photos): 
    #loading clean_descriptions
    file = load_doc("C:/Users/Project/descriptions.txt")
    descriptions = {}
    for line in file.split("\n"):
        words = line.split()
        if len(words)<1 :
            continue
        image, image_caption = words[0], words[1:]
        if image in photos:
            if image not in descriptions:
                descriptions[image] = []
            desc = '<start> ' + " ".join(image_caption) + ' <end>'
            descriptions[image].append(desc)
    return descriptions

def load_features(filename):
    #loading all features
    all_features = load(open("C:/Users/Project/features.p","rb"))
    #selecting only needed features
    features = {k:all_features[k] for k in photos}
    return features
filename = dataset_text + "/" + "C:/Users/Project/Flickr8k_text\Flickr8k.token.txt"
#"C:/Users/Project/Flickr8k_text/Flickr_8k.trainImages.txt"
#train = loading_data(filename)
train_imgs = load_photos(filename)
train_descriptions = load_clean_descriptions(filename,photos)
train_features = load_features(train_imgs)

Ошибка:

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-111-e33556710077> in <module>
      8 #"C:/Users/Project/Flickr8k_text/Flickr_8k.trainImages.txt"
      9 #train = loading_data(filename)
---> 10 train_imgs = load_photos(filename)
     11 train_descriptions = load_clean_descriptions(filename,photos)
     12 train_features = load_features(train_imgs)

<ipython-input-108-32aceb470773> in load_photos(filename)
      1 #load the data
      2 def load_photos(filename):
----> 3     file = load_doc("C:/Users/Project/Flickr8k_text/Flickr_8k.trainImages.txt")
      4     photos = file.split("\n")[:-1]
      5     return photos

TypeError: load_doc() takes 0 positional arguments but 1 was given

Я работаю над "Генерацией подписи изображения с использованием Lstm & Cnn", и я поражен в обучении модели, если кто-то заинтересован помочь мне, пожалуйста, прокомментируйте ниже Примечание : Я использую правильный набор данных и пути для обучения модели Пожалуйста, повторите для заметки

...