本项目利用PaddleRS超分模块处理低分辨率无人机影像,再结合PaddleSeg训练的Segformer模型提升分割效果。先通过DRN模型超分重建低质影像,再与直接用低分辨率影像的分割结果对比。虽无标注数据计算指标,但人眼判别显示,超分后预测结果更优,尤其在细节呈现上更接近人工标注真值。
☞☞☞AI 智能聊天, 问答助手, AI 智能搜索, 免费无限量使用 DeepSeek R1 模型☜☜☜

%cd /home/aistudio/import matplotlib.pyplot as pltfrom PIL import Image
output = Image.open(r"work/example/Seg/UDD6_result/added_prediction/000161.JPG")
plt.figure(figsize=(18,12))#设置窗口大小plt.imshow(output), plt.axis('off')/home/aistudio
(<matplotlib.image.AxesImage at 0x7f1e4d90f390>, (-0.5, 4095.5, 2159.5, -0.5))
<Figure size 1296x864 with 1 Axes>
img = Image.open(r"work/example/Seg/gt_result/data_05_2_14.png")
lq = Image.open(r"work/example/Seg/lq_result/added_prediction/data_05_2_14.png")
sr = Image.open(r"work/example/Seg/sr_result/added_prediction/data_05_2_14.png")
plt.figure(figsize=(18, 12))
plt.subplot(1,3,1), plt.title('GT')
plt.imshow(img), plt.axis('off')
plt.subplot(1,3,2), plt.title('predict_LR')
plt.imshow(lq), plt.axis('off')
plt.subplot(1,3,3), plt.title('predict_SR')
plt.imshow(sr), plt.axis('off')
plt.show()<Figure size 1296x864 with 3 Axes>
add_lb = Image.open(r"work/example/Seg/gt_result/data_05_2_19.png")
lb = Image.open(r"work/example/Seg/gt_label/data_05_2_19.png")
img = Image.open(r"work/ValData/DJI300/data_05_2_19.png")
plt.figure(figsize=(18, 12))
plt.subplot(1,3,1), plt.title('image')
plt.imshow(img), plt.axis('off')
plt.subplot(1,3,2), plt.title('label')
plt.imshow(lb), plt.axis('off')
plt.subplot(1,3,3), plt.title('add_label')
plt.imshow(add_lb), plt.axis('off')
plt.show()<Figure size 1296x864 with 3 Axes>
# 从github上克隆仓库!git clone https://github.com/PaddleCV-SIG/PaddleRS.git
正克隆到 'PaddleRS'... remote: Enumerating objects: 2325, done. remote: Counting objects: 100% (2325/2325), done. remote: Compressing objects: 100% (1086/1086), done. remote: Total 2325 (delta 1233), reused 2245 (delta 1182), pack-reused 0 接收对象中: 100% (2325/2325), 3.22 MiB | 2.49 MiB/s, 完成. 处理 delta 中: 100% (1233/1233), 完成. 检查连接... 完成。
# 安装依赖,大概一分多钟%cd PaddleRS/ !pip install -r requirements.txt
# 进行图像超分处理,使用的模型为DRNimport osimport paddleimport numpy as npfrom PIL import Imagefrom paddlers.models.ppgan.apps.drn_predictor import DRNPredictor# 输出预测结果的文件夹output = r'../work/example' # 待输入的低分辨率影像位置input_dir = r"../work/ValData/DJI300" paddle.device.set_device("gpu:0") # 若是cpu环境,则替换为 paddle.device.set_device("cpu")predictor = DRNPredictor(output) # 实例化filenames = [f for f in os.listdir(input_dir) if f.endswith('.png')]for filename in filenames:
imgPath = os.path.join(input_dir, filename)
predictor.run(imgPath) # 预测 # 可视化import osimport matplotlib.pyplot as plt
%matplotlib inline
lq_dir = r"../work/ValData/DJI300" #低分辨率影像文件夹sr_dir = r"../work/example/DRN" #超分辨率影像所在文件夹img_list = [f for f in os.listdir(lq_dir) if f.endswith('.png')]
show_num = 3 # 展示多少对影像for i in range(show_num):
lq_box = (100, 100, 175, 175)
sr_box = (400, 400, 700, 700)
filename = img_list[i]
image = Image.open(os.path.join(lq_dir, filename)).crop(lq_box) # 读取低分辨率影像
sr_img = Image.open(os.path.join(sr_dir, filename)).crop(sr_box) # 读取超分辨率影像
plt.figure(figsize=(12, 8))
plt.subplot(1,2,1), plt.title('Input')
plt.imshow(image), plt.axis('off')
plt.subplot(1,2,2), plt.title('Output')
plt.imshow(sr_img), plt.axis('off')
plt.show()<Figure size 864x576 with 2 Axes>
<Figure size 864x576 with 2 Axes>
<Figure size 864x576 with 2 Axes>
%cd ..# clone PaddleSeg的项目!git clone https://gitee.com/paddlepaddle/PaddleSeg
/home/aistudio 正克隆到 'PaddleSeg'... remote: Enumerating objects: 16439, done. remote: Counting objects: 100% (1402/1402), done. remote: Compressing objects: 100% (811/811), done. remote: Total 16439 (delta 710), reused 1165 (delta 573), pack-reused 15037 接收对象中: 100% (16439/16439), 341.09 MiB | 10.14 MiB/s, 完成. 处理 delta 中: 100% (10574/10574), 完成. 检查连接... 完成。
# 安装依赖%cd /home/aistudio/PaddleSeg !pip install -r requirements.txt
# 对低分辨率的无人机影像进行预测!python predict.py \
--config ../work/segformer_b3_UDD.yml \
--model_path ../work/best_model/model.pdparams \
--image_path ../work/ValData/DJI300 \
--save_dir ../work/example/Seg/lq_result# 对使用DRN超分重建后的影像进行预测!python predict.py \
--config ../work/segformer_b3_UDD.yml \
--model_path ../work/best_model/model.pdparams \
--image_path ../work/example/DRN \
--save_dir ../work/example/Seg/sr_result# 展示部分预测的结果%cd /home/aistudio/import matplotlib.pyplot as pltfrom PIL import Imageimport os
img_dir = r"work/example/Seg/gt_result" #低分辨率影像文件夹lq_dir = r"work/example/Seg/lq_result/added_prediction"sr_dir = r"work/example/Seg/sr_result/added_prediction" # 超分辨率预测的结果影像所在文件夹img_list = [f for f in os.listdir(img_dir) if f.endswith('.png') ]for filename in img_list:
img = Image.open(os.path.join(img_dir, filename))
lq_pred = Image.open(os.path.join(lq_dir, filename))
sr_pred = Image.open(os.path.join(sr_dir, filename))
plt.figure(figsize=(12, 8))
plt.subplot(1,3,1), plt.title('GT')
plt.imshow(img), plt.axis('off')
plt.subplot(1,3,2), plt.title('LR_pred')
plt.imshow(lq_pred), plt.axis('off')
plt.subplot(1,3,3), plt.title('SR_pred')
plt.imshow(sr_pred), plt.axis('off')
plt.show()/home/aistudio
<Figure size 864x576 with 3 Axes>
<Figure size 864x576 with 3 Axes>
<Figure size 864x576 with 3 Axes>
<Figure size 864x576 with 3 Axes>
<Figure size 864x576 with 3 Axes>
以上就是PaddleRS:使用超分模块提高真实的低分辨率无人机影像的分割精度的详细内容,更多请关注php中文网其它相关文章!
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号