【发布时间】:2020-10-29 16:07:00
【问题描述】:
问候,
问题: 我陷入了一个循环。我希望循环选择图像并将其与 csv 列(名称)进行比较(如果存在),然后进一步调整大小。图片是拉链的,我先把它们从拉链里拿出来;
from zipfile import ZipFile
file_name = "human_detection_images.zip"
with ZipFile(file_name, 'r') as zip:
zip.extractall()
print('Done')
PATH_TO_TEST_IMAGES_DIR = pathlib.Path('/content/human_detection_images')
TEST_IMAGE_PATHS = sorted(list(PATH_TO_TEST_IMAGES_DIR.glob("*.jpg")))
TEST_IMAGE_PATHS
然后我上传 csv,其中包含图像的标签和名称(与文件夹相同但不按顺序排列)。
import pandas as pd
import numpy as np
data1 = pd.read_csv('/content/csvnew.csv')
df = pd.DataFrame(data1)
df.shape,df.columns
现在我需要运行一个循环来选择 1 x 1 图像并将其与 csv 中的名称进行比较。如果相似,它会调整图像大小。调整大小代码可用,
for image_path in TEST_IMAGE_PATHS:
if TEST_IMAGE_PATHS == df['names']:
print("done") #error here: it prints nothing
# return False
imgs = read_given_images("./",TEST_IMAGE_PATHS)
points = df['labels']
points = np.array(points)
# resizing starts
我需要有关循环的帮助。如果有人请..
【问题讨论】:
标签: python-3.x image loops comparison