Ejemplo n.º 1
0
    def __getitem__(self, index):
        name = self.df.iloc[index][0]

        data = {'name': name, 'x': lineToTensor(name)}

        if self.task == 'train':
            target = self.df.iloc[index][1]

            data.update(
                {'y': torch.tensor(self.class_dict[target], dtype=torch.long)})

        return data
Ejemplo n.º 2
0
def prepareTensors(labeled_pair):
    sequence,label = labeled_pair
    category_tensor = torch.tensor([label], dtype=torch.long)
    line_tensor = lineToTensor(sequence)
    category = categories[label]
    return category, sequence, category_tensor, line_tensor
Ejemplo n.º 3
0
    net = NameClassifier()
    try:
        net.load_from_checkpoint(
            os.path.join(model_dir, 'names_classifier.ckpt'))
    except:
        net.load_from_checkpoint(
            os.path.join(model_dir, 'names_classifier-v0.ckpt'))

    net.eval()

    while (1):
        name_line = input(
            '[🤗 Classifier - running] Enter the name : \n>>> ')
        try:
            if name_line in ['q', 'quit']:
                print('🤗 Bye !')
                break
            else:
                name_tensor = lineToTensor(name_line)

                pred = evaluate(name_tensor, net)

                c = classes[pred]

                print(
                    f"[Classifier] >>> {name_line} seems to be a {c} name i think...\n"
                )

        except Exception as e:
            print(f"[Error] {e}")