1 Star 0 Fork 0

NG麒麟/yolov8-master

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
pngTojpg.py 1.14 KB
一键复制 编辑 原始数据 按行查看 历史
NG麒麟 提交于 2023-12-22 11:57 . 添加DCNv2模块,修改backbone
import os
from PIL import Image
# Vols填写多个文件夹名称,若名称具有规律,也可以在外层用for循环先读取所有文件夹名称进Vols里
# Vols = ['文件夹1', '文件夹2', '文件夹3', '文件夹4']
Vols = ['D:/DataSet/7classesdetection/7classesdetection/JPEGImages']
for Vol in Vols:
# 所有photo所在的文件夹目录
path_photo = Vol
print('正在重置路径', path_photo)
# 得到文件夹下的所有文件名称,存在字符串列表中
files_lists = os.listdir(path_photo)
# 转变工作目录到指定文件夹
os.chdir(path_photo)
for files_list in files_lists:
print(files_list)
# 读取每个png文件
img = Image.open(files_list)
# 将文件名中的png替换为jpg
files_list = files_list.replace('png', 'jpg')
rgb_img = img.convert('RGB')
rgb_img.save(files_list)
img.close()
print(type(files_lists))
print(files_lists) # 打印path_photo文件夹下的所有文件
# 删除原来的png
for pic in files_lists: # 遍历文件
if pic.endswith(".png"):
os.remove(path_photo + '/' + pic)
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/ng-qilin/yolov8-master.git
git@gitee.com:ng-qilin/yolov8-master.git
ng-qilin
yolov8-master
yolov8-master
main

搜索帮助

23e8dbc6 1850385 7e0993f3 1850385