如何使用bash shell遍历数据集



我在一个计算机视觉深度学习项目中运行代码,我可以成功运行demo。现在我想用demo创建一个新的大数据集。运行一张图片的命令如下:

cd /root/.virtualenvs/hmr2.0/hmr2.0-master/src/visualise/
python3 demo.py --image=im00001.jpg --model=base_model --setting=paired-joints --joint_type=cocoplus --init_toes=false

中有一个数据集
cd /root/.virtualenvs/hmr2.0/hmr2.0-master/src/visualise/images, including 10000 pictures. They are named im00001.jpg, im00002.jpg to im09999.jpg, im10000.jpg.

我如何编写一个bash shell来运行所有10000个图像并生成具有相应名称的文件?

对于这样的任务,我通常这样做

cd /root/.virtualenvs/hmr2.0/hmr2.0-master/src/visualise
for fff in images/*.jpg; do
python3 demo.py --image=$fff --model=base_model --setting=paired-joints --joint_type=cocoplus --init_toes=false
done

如果该目录中有其他jpg文件,则必须替换"images/*.jpg"更具体的

如果for fff in images/*.jpg由于大量图像而无法工作,您可以将其替换为

ls -1 images/*.jpg | while read fff; do