Beispiel #1
0
def run_tensorflow2():
    ## running for our dataset
    Images = []
    dataset_folder_path = 'train_1/'

    for filename in os.listdir(dataset_folder_path):
        if filename.endswith(".jpg") or filename.endswith(".png"):
            Images.append(filename)

    # print (Images)
    np.random.shuffle(Images)
    # print (Images)
    Style_Images, Content_Images = Images[: round(0.50 * len(Images))], Images[round(0.50 * len(Images)):]
    no_images = 100;

    with tf.device("/cpu:0"):

        i = 0;
        for content_path, style_path in zip(Style_Images, Content_Images):
            print("Path", content_path, style_path)
            content_path = dataset_folder_path + "/" + content_path;
            content_map_path = content_path.split('.')[0] + "_sem.jpg";
            style_path = dataset_folder_path + "/" + style_path;
            style_map_path = style_path.split('.')[0] + "_sem.jpg";

            best, best_loss = run_style_transfer(content_path, style_path,content_map_path=content_map_path,style_map_path=style_map_path, num_iterations=25)
            show_results(results, best, content_path, style_path)
            if i == no_images:
                break
            i += 1
Beispiel #2
0
def run_tensorflow():
    with tf.device("/gpu:0"):
        imshow(deprocess_img(load_and_process_img(content_path)), squeze=False)
        plt.show()
        best, best_loss = run_style_transfer(content_path, style_path,
                                             style_map_path, content_map_path, num_iterations=15)
        show_results(results, best, content_path, style_path)
Beispiel #3
0
    def run_tensorflow(self, content_path, style_path):
        with tf.device(self.device_name):
            best, best_loss = self.run_style_transfer(
                content_path,
                style_path,
                style_map_path,
                content_map_path,
                num_iterations=self.iterations)

            show_results(self.results, best, content_path, style_path)
Beispiel #4
0
    def run_tensorflow(self, content_path, style_path):
        with tf.device(self.device_name):
            content_map_path = content_path.split('.')[0] + "_color_mask.png"
            style_map_path = style_path.split('.')[0] + "__color_mask.png"

            best, best_loss = self.run_style_transfer(
                content_path,
                style_path,
                style_map_path,
                content_map_path,
                num_iterations=self.iterations)
            show_results(self.results, best, content_path, style_path)
Beispiel #5
0
    def run_tensorflow2(self):
        ## running for our dataset
        Images = []
        sImages = []

        dataset_folder_path = 'final_content'
        sdataset_folder_path = 'style'

        for filename in os.listdir(dataset_folder_path):
            if filename.endswith(".jpg") or filename.endswith(".png"):
                Images.append(filename)

        for filename in os.listdir(sdataset_folder_path):
            if filename.endswith(".jpg") or filename.endswith(".png"):
                sImages.append(filename)

        # print (Images)
        np.random.shuffle(Images)
        np.random.shuffle(sImages)
        # print (Images)
        Style_Images, Content_Images = sImages, Images
        no_images = 100

        with tf.device(self.device_name):

            i = 0
            for style_path, content_path in zip(Style_Images, Content_Images):
                print("Path", content_path, style_path)

                content_path = dataset_folder_path + "/" + content_path
                style_path = sdataset_folder_path + "/" + style_path
                content_map_path = content_path.split(
                    '.')[0] + "_color_mask.jpg"
                style_map_path = style_path.split('.')[0] + "_color_mask.jpg"

                best, best_loss = self.run_style_transfer(
                    content_path,
                    style_path,
                    content_map_path=content_map_path,
                    style_map_path=style_map_path,
                    num_iterations=self.iterations)

                show_results(self.results, best, content_path, style_path)
                if i == no_images:
                    break
                i += 1
Beispiel #6
0
    def run_tensorflow2(self):
        ## running for our dataset
        ## running for our dataset
        Images = []
        sImages = []

        dataset_folder_path = 'final_content'
        sdataset_folder_path = 'style'

        for filename in os.listdir(dataset_folder_path):
            if filename.endswith(".jpg") or filename.endswith(".png"):
                Images.append(filename)

        for filename in os.listdir(sdataset_folder_path):
            if filename.endswith(".jpg") or filename.endswith(".png"):
                sImages.append(filename)

        print (Images)
        np.random.shuffle(Images)
        np.random.shuffle(sImages)
        print (sImages)
        Style_Images, Content_Images = sImages , Images

        no_images=100;

        with tf.device(self.device_name):
            i=0;
            print("fadsf")
            for style_path ,content_path in zip(Style_Images, Content_Images):
                print(content_path, style_path)
                content_path = dataset_folder_path + "/" + content_path;
                style_path = sdataset_folder_path + "/" + style_path;

                best, best_loss = self.run_style_transfer(content_path, style_path, num_iterations=self.iterations)
                show_results(self.results,best, content_path, style_path)
                if i==no_images:
                    break;
                i+=1