[load_image(name, args.img_size) for name in image_names], axis=0
)
img_data = (
img_data.transpose((0, 3, 1, 2)) / 255.0// noqa: WPS432
).astype(np.float32)
img_data = torch.from_numpy(img_data)
else:
After Change
assertlen(df)== len(features)
if args.num_rows is not None:
indices = np.random.choice(len(df), args.num_rows)
features = features[indices, :]
df = df.iloc[indices]
if args.img_col is not None:
img_data = _load_image_data(
rootpath=args.img_rootpath, paths=df[args.img_col].values
)
else:
img_data = None
summary_writer = SummaryWriter(args.out_dir)
metadata = df[meta_header].values.tolist()
metadata = [
[
str(text)
.replace("\n", " ")
.replace(r"\s", " ")
.replace(r"\s\s+", " ")
.strip()
for text in texts
]
for texts in metadata
]