Commit 0d5c21b8 authored by Rudolf Chrispens's avatar Rudolf Chrispens
Browse files

reworked a lot to get started with new model

parent 7b828692
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
{
    "python.pythonPath": "/usr/local/opt/python/bin/python3.6",
    "python.linting.pylintEnabled": true,
    "python.linting.pylintEnabled": false,
    "python.linting.flake8Enabled": true,
    "python.linting.enabled": true,
    "python.linting.pylintArgs": [
@@ -16,5 +16,6 @@
        "**/*.pyc": true,
        "cnn/":true,
        "rnn/":true,
        "**/__pycache__/":true,
    }
}
 No newline at end of file
+5 −0
Original line number Diff line number Diff line
from .coco_model import coco_model

__all__ = [
    'coco_model'
]
 No newline at end of file
+1 −1
Original line number Diff line number Diff line
@@ -14,7 +14,7 @@ from __future__ import division

import tensorflow as tf

class CaptionGenerator(object):
class coco_model(object):
    def __init__(self, word_to_idx, dim_feature=[196, 512], dim_embed=512, dim_hidden=1024, n_time_step=16,
                  prev2out=True, ctx2out=True, alpha_c=0.0, selector=True, dropout=True):
        """
+3 −6
Original line number Diff line number Diff line
# reader init
# from .basic_text_reader import basic_text_reader
# from .basic_text_reader import get_words_as_int
# from .basic_text_reader import get_integers_as_words
# from .basic_masa_reader import basic_masa_reader
from .helper import get_input_data
from .helper import get_vocabulary
from .helper import get_sequences
from .helper import check_folders
from .basic_masa_reader import basic_masa_reader
from .coco_reader import coco_reader

__all__ = [
    'get_input_data',
    'get_vocabulary',
    'get_sequences',
    'check_folders',
    'basic_masa_reader'
    'basic_masa_reader',
    'coco_reader'
]
+1 −15
Original line number Diff line number Diff line
@@ -6,30 +6,18 @@ import tensorflow as tf
from lstm.Readers import helper
import pickle

"""To run this code, you'll need to first download and extract the text dataset
    from here: http://www.fit.vutbr.cz/~imikolov/rnnlm/simple-examples.tgz. Change the
    data_path variable below to your local exraction path"""

# data_path = "C:\\Users\Andy\Documents\simple-examples\data"

# parser = argparse.ArgumentParser()
# parser.add_argument('run_opt', type=int, default=1, help='An integer: 1 to train, 2 to test')
# parser.add_argument('--data_path', type=str, default=data_path, help='The full path of the training data')
# args = parser.parse_args()

"""
with open('interface_train_30pics_per_category.picle', 'rb') as handle:
    data = picle.load(handle)
"""

class basic_masa_reader:
class coco_reader:
    def read_input(self, filename: str):
        with tf.gfile.GFile(helper.inputPath + filename, "r") as f:
            if(config.reader.verbose is True):
                print("")
            return f.read().replace("\n", "<eos>").split()


    def create_vocabulary(self, filename: str):
        data = self.read_input(filename + config.reader.input_data_type)

@@ -41,12 +29,10 @@ class basic_masa_reader:

        return word_to_id


    def file_to_word_ids(self, filename: str, word_to_id):
        data = self.read_input(filename + config.reader.input_data_type)
        return [word_to_id[word] for word in data if word in word_to_id]


    def load_data(self):
        # build the complete vocabulary, then convert text data to list of integers
        word_to_id = self.create_vocabulary(config.path.input_train)
Loading