Пример #1
0
    def addOutputs(self):
        Complete.addOutputs(self)
        self.addOutput(
            OutputVector(self.OUTPUT_WATERSHEDS_LAYER,
                         self.tr('watersheds_vector')))

        self.addOutput(
            OutputVector(self.OUTPUT_BLUESPOTS_LAYER,
                         self.tr('bluespots_vector')))
Пример #2
0
    def createOutput(self):
        Complete.createOutput(self)
        #Create vector files
        self.writeVectorOutput(
            'watersheds.shp',
            self.getOutputFromName(self.OUTPUT_WATERSHEDS_LAYER),
            self.getParameterValue(self.VECTOR_FORMAT))

        self.writeVectorOutput(
            'bluespots.shp',
            self.getOutputFromName(self.OUTPUT_BLUESPOTS_LAYER),
            self.getParameterValue(self.VECTOR_FORMAT))
Пример #3
0
class ExternalTask:

    fetch = FetchAndLock()
    complete = Complete()

    def subscribe(self, topic, lockduration, host):
        self.fetch.sendjson(topic=topic, lockduration=lockduration, host=host)

    def startautomation(self):
        if self.fetch.getresponsetext() != "[]":
            self.fetch.storereponseindict()
            return True
        else:
            return False

    def getvariable(self, str):
        return self.fetch.getvariable(str=str)

    def completeautomation(self, host):
        print(self.fetch.getid())
        print(self.complete.sendcomplete(guid=self.fetch.getid(), host=host))
        print(self.complete.getresponse())

#put local variable

    def putvariable(self, host, varname):
        json = {"value": "someValue", "type": "String"}

        putresponse = requests.put(
            'http://' + host + '/engine-rest/execution/' +
            self.fetch.getexecutionid() + '/localVariables/' + varname,
            json=json)
        print(putresponse)
        print(putresponse.text)
Пример #4
0
def start():
    print("Loading the files and preparing the system...")

    files_list = get_file_list(
        "technology_texts/python-3.8.4-docs-text/python-3.8.4-docs-text/c-api")
    # files_list = get_file_list("technology_texts/python-3.8.4-docs-text/python-3.8.4-docs-text/whatsnew")
    complete = Complete(Data(files_list))

    # complete = Complete(Data(["technology_texts/python-3.8.4-docs-text/python-3.8.4-docs-text/about.txt"]))

    print("The system is ready.")

    input_ = ' '.join((''.join(i for i in input("\n\nEnter your text: ")
                               if i in string.ascii_letters + ' ')).split())

    while (1):
        text = " "

        while text[-1] != '#':
            match_sentences = complete.get_best_k_completions(input_)

            if len(match_sentences) != 0:
                for sentence in match_sentences:
                    print(
                        f"{sentence.completed_sentence} ({files_list[sentence.source_text]} {sentence.offset})"
                    )
            else:
                print("there is no items")

            # print(input_, end="")
            text = input(input_)
            input_ += ' '.join(
                (''.join(i for i in text
                         if i in string.ascii_letters + ' ')).split())

        input_ = ' '.join(
            (''.join(i for i in input("\n\nEnter your text: ")
                     if i in string.ascii_letters + ' ')).split())
Пример #5
0
def load_data():
    files_list = get_file_list(data_path)
    return Complete(Data(files_list)), files_list
Пример #6
0
 def __init__(self):
     Complete.__init__(self)
Пример #7
0
# data.name = args.dataset
dataprocess.random_split(data, args.dataseed, args)

model = eval(args.complete).Model(data.num_nodes, dataset.num_features,
                                  dataset.num_classes, device, args).to(device)

optimizer_base = torch.optim.Adam(model.base_parameters(),
                                  lr=args.lr,
                                  weight_decay=args.wd)
optimizer_graph = torch.optim.Adam(model.graph_parameters(),
                                   lr=args.lr_graph,
                                   weight_decay=args.wd_graph)

complete_device = torch.device("cpu")

complete_model = Complete(sampled_edge_index, data, model, complete_device,
                          args)
compl_acc = 0.

model.train()
val_acc_epoch_list, best_val_acc = [], 0.
val_loss_epoch_list, best_val_loss = [], 1e10
final_test_acc = 0.
lr_base, lr_graph = args.lr, args.lr_graph

for epoch in range(args.epochs):
    # Optimize GCN
    train_loss = []
    for batch_data in dataprocess.dataloader(data,
                                             complete_model.loop_adj_part,
                                             args.batch_size, args.sparse):
        batch_data.to(device)
Пример #8
0
import PIL
import PIL.Image as Image

SEQUENCE_LENGTH = 1


def save_image(image, title, index):
    images = np.array([image])
    images = np.clip(np.rint((images + 1.0) / 2.0 * 255.0), 0.0,
                     255.0).astype(np.uint8)  # [-1,1] => [0,255]
    images = images.transpose(0, 2, 3, 1)  # NCHW => NHWC
    PIL.Image.fromarray(images[0], 'RGB').save(
        'img-' + str(index) + '-' + title + '.png')


complete = Complete()

# source_image shape (256, 256, 3)
# source_image = scipy.misc.imread('/source/bayeux1.png',
#                                  mode='RGB').astype(np.float)
source_image = scipy.misc.imread('/source/Black256.jpg',
                                 mode='RGB').astype(np.float)


# RESHAPE TEST IMAGE
# source_image shape (256, 256, 3)
# generated shape is (3, 256, 256)
reshaped_source_image = source_image.transpose(2, 0, 1)
reshaped_source_image = (reshaped_source_image / 255) * 2.0 - 1.0