未验证 提交 ad9d219a 编写于 作者: W whs 提交者: GitHub

Rename core.LoDTensor to fluid.LoDTensor in ocr, gan and icnet (#2141)

上级 0a0021f3
...@@ -2,7 +2,6 @@ import argparse ...@@ -2,7 +2,6 @@ import argparse
import functools import functools
import os import os
from PIL import Image from PIL import Image
from paddle.fluid import core
import paddle.fluid as fluid import paddle.fluid as fluid
import paddle import paddle
import numpy as np import numpy as np
...@@ -51,7 +50,7 @@ def infer(args): ...@@ -51,7 +50,7 @@ def infer(args):
if len(image.shape) != 3: if len(image.shape) != 3:
continue continue
data = image.transpose([2, 0, 1])[np.newaxis, :].astype("float32") data = image.transpose([2, 0, 1])[np.newaxis, :].astype("float32")
tensor = core.LoDTensor() tensor = fluid.LoDTensor()
tensor.set(data, place) tensor.set(data, place)
fake_temp = exe.run(fetch_list=[fake.name], feed={"input": tensor}) fake_temp = exe.run(fetch_list=[fake.name], feed={"input": tensor})
......
...@@ -12,7 +12,6 @@ import numpy as np ...@@ -12,7 +12,6 @@ import numpy as np
from scipy.misc import imsave from scipy.misc import imsave
import paddle.fluid as fluid import paddle.fluid as fluid
import paddle.fluid.profiler as profiler import paddle.fluid.profiler as profiler
from paddle.fluid import core
import data_reader import data_reader
from utility import add_arguments, print_arguments, ImagePool from utility import add_arguments, print_arguments, ImagePool
from trainer import * from trainer import *
...@@ -82,8 +81,8 @@ def train(args): ...@@ -82,8 +81,8 @@ def train(args):
for data_A, data_B in zip(A_test_reader(), B_test_reader()): for data_A, data_B in zip(A_test_reader(), B_test_reader()):
A_name = data_A[1] A_name = data_A[1]
B_name = data_B[1] B_name = data_B[1]
tensor_A = core.LoDTensor() tensor_A = fluid.LoDTensor()
tensor_B = core.LoDTensor() tensor_B = fluid.LoDTensor()
tensor_A.set(data_A[0], place) tensor_A.set(data_A[0], place)
tensor_B.set(data_B[0], place) tensor_B.set(data_B[0], place)
fake_A_temp, fake_B_temp, cyc_A_temp, cyc_B_temp = exe.run( fake_A_temp, fake_B_temp, cyc_A_temp, cyc_B_temp = exe.run(
...@@ -168,8 +167,8 @@ def train(args): ...@@ -168,8 +167,8 @@ def train(args):
for i in range(max_images_num): for i in range(max_images_num):
data_A = next(A_reader) data_A = next(A_reader)
data_B = next(B_reader) data_B = next(B_reader)
tensor_A = core.LoDTensor() tensor_A = fluid.LoDTensor()
tensor_B = core.LoDTensor() tensor_B = fluid.LoDTensor()
tensor_A.set(data_A, place) tensor_A.set(data_A, place)
tensor_B.set(data_B, place) tensor_B.set(data_B, place)
s_time = time.time() s_time = time.time()
......
...@@ -115,7 +115,7 @@ def infer(args): ...@@ -115,7 +115,7 @@ def infer(args):
image_file, is_color=True).astype("float32") image_file, is_color=True).astype("float32")
image -= IMG_MEAN image -= IMG_MEAN
img = paddle.dataset.image.to_chw(image)[np.newaxis, :] img = paddle.dataset.image.to_chw(image)[np.newaxis, :]
image_t = fluid.core.LoDTensor() image_t = fluid.LoDTensor()
image_t.set(img, place) image_t.set(img, place)
result = exe.run(inference_program, result = exe.run(inference_program,
feed={"image": image_t}, feed={"image": image_t},
......
...@@ -18,7 +18,6 @@ from __future__ import division ...@@ -18,7 +18,6 @@ from __future__ import division
from __future__ import print_function from __future__ import print_function
import distutils.util import distutils.util
import numpy as np import numpy as np
from paddle.fluid import core
import six import six
...@@ -72,7 +71,7 @@ def to_lodtensor(data, place): ...@@ -72,7 +71,7 @@ def to_lodtensor(data, place):
lod.append(cur_len) lod.append(cur_len)
flattened_data = np.concatenate(data, axis=0).astype("int32") flattened_data = np.concatenate(data, axis=0).astype("int32")
flattened_data = flattened_data.reshape([len(flattened_data), 1]) flattened_data = flattened_data.reshape([len(flattened_data), 1])
res = core.LoDTensor() res = fluid.LoDTensor()
res.set(flattened_data, place) res.set(flattened_data, place)
res.set_lod([lod]) res.set_lod([lod])
return res return res
...@@ -80,17 +79,17 @@ def to_lodtensor(data, place): ...@@ -80,17 +79,17 @@ def to_lodtensor(data, place):
def get_feeder_data(data, place, for_test=False): def get_feeder_data(data, place, for_test=False):
feed_dict = {} feed_dict = {}
image_t = core.LoDTensor() image_t = fluid.LoDTensor()
image_t.set(data[0], place) image_t.set(data[0], place)
feed_dict["image"] = image_t feed_dict["image"] = image_t
if not for_test: if not for_test:
labels_sub1_t = core.LoDTensor() labels_sub1_t = fluid.LoDTensor()
labels_sub2_t = core.LoDTensor() labels_sub2_t = fluid.LoDTensor()
labels_sub4_t = core.LoDTensor() labels_sub4_t = fluid.LoDTensor()
mask_sub1_t = core.LoDTensor() mask_sub1_t = fluid.LoDTensor()
mask_sub2_t = core.LoDTensor() mask_sub2_t = fluid.LoDTensor()
mask_sub4_t = core.LoDTensor() mask_sub4_t = fluid.LoDTensor()
labels_sub1_t.set(data[1], place) labels_sub1_t.set(data[1], place)
labels_sub2_t.set(data[3], place) labels_sub2_t.set(data[3], place)
...@@ -105,8 +104,8 @@ def get_feeder_data(data, place, for_test=False): ...@@ -105,8 +104,8 @@ def get_feeder_data(data, place, for_test=False):
feed_dict["label_sub4"] = labels_sub4_t feed_dict["label_sub4"] = labels_sub4_t
feed_dict["mask_sub4"] = mask_sub4_t feed_dict["mask_sub4"] = mask_sub4_t
else: else:
label_t = core.LoDTensor() label_t = fluid.LoDTensor()
mask_t = core.LoDTensor() mask_t = fluid.LoDTensor()
label_t.set(data[1], place) label_t.set(data[1], place)
mask_t.set(data[2], place) mask_t.set(data[2], place)
feed_dict["label"] = label_t feed_dict["label"] = label_t
......
...@@ -18,7 +18,6 @@ from __future__ import division ...@@ -18,7 +18,6 @@ from __future__ import division
from __future__ import print_function from __future__ import print_function
import distutils.util import distutils.util
import numpy as np import numpy as np
from paddle.fluid import core
import paddle.fluid as fluid import paddle.fluid as fluid
import six import six
...@@ -73,14 +72,14 @@ def to_lodtensor(data, place): ...@@ -73,14 +72,14 @@ def to_lodtensor(data, place):
lod.append(cur_len) lod.append(cur_len)
flattened_data = np.concatenate(data, axis=0).astype("int32") flattened_data = np.concatenate(data, axis=0).astype("int32")
flattened_data = flattened_data.reshape([len(flattened_data), 1]) flattened_data = flattened_data.reshape([len(flattened_data), 1])
res = core.LoDTensor() res = fluid.LoDTensor()
res.set(flattened_data, place) res.set(flattened_data, place)
res.set_lod([lod]) res.set_lod([lod])
return res return res
def get_ctc_feeder_data(data, place, need_label=True): def get_ctc_feeder_data(data, place, need_label=True):
pixel_tensor = core.LoDTensor() pixel_tensor = fluid.LoDTensor()
pixel_data = None pixel_data = None
pixel_data = np.concatenate( pixel_data = np.concatenate(
list(map(lambda x: x[0][np.newaxis, :], data)), list(map(lambda x: x[0][np.newaxis, :], data)),
...@@ -98,7 +97,7 @@ def get_ctc_feeder_for_infer(data, place): ...@@ -98,7 +97,7 @@ def get_ctc_feeder_for_infer(data, place):
def get_attention_feeder_data(data, place, need_label=True): def get_attention_feeder_data(data, place, need_label=True):
pixel_tensor = core.LoDTensor() pixel_tensor = fluid.LoDTensor()
pixel_data = None pixel_data = None
pixel_data = np.concatenate( pixel_data = np.concatenate(
list(map(lambda x: x[0][np.newaxis, :], data)), list(map(lambda x: x[0][np.newaxis, :], data)),
...@@ -130,7 +129,7 @@ def get_attention_feeder_for_infer(data, place): ...@@ -130,7 +129,7 @@ def get_attention_feeder_for_infer(data, place):
init_scores = fluid.create_lod_tensor(init_scores_data, init_scores = fluid.create_lod_tensor(init_scores_data,
init_recursive_seq_lens, place) init_recursive_seq_lens, place)
pixel_tensor = core.LoDTensor() pixel_tensor = fluid.LoDTensor()
pixel_data = None pixel_data = None
pixel_data = np.concatenate( pixel_data = np.concatenate(
list(map(lambda x: x[0][np.newaxis, :], data)), list(map(lambda x: x[0][np.newaxis, :], data)),
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册