自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(118)
  • 收藏
  • 关注

原创 C++ opencv实现letterbox

【代码】C++ opencv实现letterbox。

2023-10-11 00:03:05 738

原创 生成伪随机数

【代码】生成伪随机数。

2023-08-24 22:05:41 110

原创 CoordAtt注意力网络结构

【代码】CoordAtt注意力网络结构。

2023-08-16 16:22:54 620

原创 yolov5-5.0 onnx格式下网络结构图

2023-07-21 15:37:10 217

原创 打印网络名称以及相应shape

【代码】打印网络名称以及相应shape。

2023-07-21 15:04:09 55

原创 c++:iota

【代码】c++:iota。

2023-06-21 09:47:58 186

原创 apt install opencv 的CMakeLists.txt

opencv.pc文件的地址,然后使用以下方式便可以正常连接opencv的动态库。

2023-05-30 14:45:39 111

原创 yolov5 -V5.0 focus 结构

【代码】yolov5 -V5.0 focus 结构。

2023-05-08 22:11:02 323 1

原创 pytorch 打印层信息

【代码】pytorch 打印层信息。

2023-04-21 16:26:33 119

原创 python 保存json

简单的代码测试

2022-06-16 13:15:09 2652

原创 yoloV4模型转onnx

def pth2onnx(cfgDir,pthDir,imgSize): model=Darknet(cfgDir,imgSize) checkpoint = torch.load(pthDir) print(model) model.load_state_dict(checkpoint['model']) model.eval() dummy_input = torch.randn(1, 3, 416, 416) input_names = ["i.

2022-01-25 19:58:14 2486

原创 3-4:设备属性的使用

API:main.cu#include"book.h"int main(void){ cudaDeviceProp prop; int dev; HANDLE_ERROR(cudaGetDevice(&dev)); printf("ID of current CUDA device: %d\n",dev); memset(&prop,0,sizeof(cudaDeviceProp)); prop.major=1;

2022-01-23 00:35:21 928

原创 3-3:查询设备

#include "book.h"int main(void){ cudaDeviceProp prop; int count; HANDLE_ERROR(cudaGetDeviceCount(&count)); for (int i = 0; i < count; i++) { HANDLE_ERROR(cudaGetDeviceProperties(&prop, i)); printf(" ---.

2022-01-23 00:29:19 527

原创 3.2.3 传递参数

main.cu:#include<stdio.h>#include"book.h"__global__ void add(int a,int b,int *c){ *c=a+b;}int main(){ int c; int *dev_c; HANDLE_ERROR(cudaMalloc((void**)& dev_c,sizeof(int))); add<<<1,1>>>(2,7,.

2022-01-22 22:42:16 384

原创 STDC分割网络:onnx推理

def STDCProcess(img): mean = [0.485, 0.456, 0.406] std = [0.229, 0.224, 0.225] img = cv2.resize(img, (256, 256)) img = img.astype(np.float32) img = img[:, :, ::-1]# BGR2RGB img = (img / 255.0 - mean) / std img = np.transpose(i.

2022-01-17 16:50:47 2782

原创 linux: dirent.h 使用

头文件:dirent.h代码:void direntTest(){ std::string rootPath="/home/.../test/samples"; std::vector<std::string> imageNames; auto dir=opendir(rootPath.c_str()); if((dir)!= nullptr) { struct dirent *entry; entry=r

2022-01-13 13:49:18 1034

原创 yaml-cpp 使用

void testYamlLibs(){ const std::string yamlFilePath="/home/tc/.../test/config.yaml"; YAML::Node root=YAML::LoadFile(yamlFilePath); YAML::Node config=root["imgs"]; int height=config["height"].as<int>(); int width=config["width"]..

2022-01-13 11:09:35 698

原创 计算函数执行时间chrono

auto t_start=std::chrono::high_resolution_clock::now(); label= readImageNetLabel(fileDir); auto t_end=std::chrono::high_resolution_clock::now(); float total_cost=std::chrono::duration<float,std::milli>(t_end-t_start).count(); std...

2022-01-12 15:43:00 175

原创 C++ STL:map,string

#include <iostream>#include "map"#include "string"#include "fstream"std::map<int,std::string> readImageNetLabel(const std::string &fileName){ std::map<int,std::string> imagenetLabel; std::ifstream file(fileName); if.

2022-01-12 15:15:10 352

原创 docker命令备忘

2022-01-06 20:04:39 267

原创 Skimage:img_as_float

参考:skimage_Scikit image_参考手册_非常教程Python skimage.img_as_float方法代码示例 - 纯净天空 相应的例程代码

2022-01-04 15:16:26 3570

原创 离线数据增强

def imgAug(imgDir,dstImg): params = [0.5, 0.6, 0.7, 0.8, 0.9, 1.1, 1.2, 1.3, 1.4, 1.5] gaussParams=[3,5] imgNames=[img for img in os.listdir(imgDir)] for name in imgNames: img = Image.open(os.path.join(imgDir,name)) brightE.

2021-12-28 17:37:22 1541

原创 离线数据增强 PIL

使用一幅图像可得到600到900张图像def imgAug(imgDir,name,dstImg): params = [0.5, 0.6, 0.7, 0.8, 0.9, 1.1, 1.2, 1.3, 1.4, 1.5] img = Image.open(os.path.join(imgDir,name)) brightEnhance = ImageEnhance.Brightness(img) contrastEnhance = ImageEnhance.Contr.

2021-12-24 15:13:33 1542

原创 python:图像重命名

def ImgRename(rootDir): for root,dirs,files in os.walk(rootDir): for dir in dirs: subDir=os.path.join(root,dir) names=[name for name in os.listdir(subDir)] for i, name in enumerate(names): ra.

2021-12-20 10:57:05 939

原创 python:datetime格式化输出

from datetime import datetimetimeStamp=datetime.now().strftime("%Y-%m-%d %H:%M:%S")print(timeStamp)# 2021-12-18 15:11:14参考:Python datetime 格式化字符串:strftime() - 时间&煮雨~ - 博客园

2021-12-18 15:17:34 4060

原创 pytorch API:随机裁剪

def imgAugTest(imgDir): img=Image.open(imgDir) print('the size of raw img:{}'.format(img.size)) cropImg=transforms.RandomResizedCrop(224)(img) print('the size of new img {}'.format(cropImg.size)) cropImg01=transforms.RandomResizedCrop(.

2021-12-17 15:46:04 1002

原创 Pytorch API:学习率调整

def StepLRTest(): model=AlexNet(num_classes=2) optimizer=optim.SGD(params=model.parameters(),lr=0.01) scheduler=lr_scheduler.MultiStepLR(optimizer,milestones=[5,20,40,80],gamma=0.1) plt.figure() x=list(range(100)) y=[] for ep.

2021-12-13 16:32:38 1381

原创 借助PIL库实现图像旋转

def imgRotate(imgDir): img=Image.open(imgDir) img90=img.transpose(Image.ROTATE_90) img180=img.transpose(Image.ROTATE_180) img270=img.transpose(Image.ROTATE_270) img180.save('img1.jpg') plt.figure(figsize=(10,10)) plt.suptitle('.

2021-12-10 17:54:38 2968

原创 opencv:SIFT 校正

def SIFT(inpic,template): sift = cv2.xfeatures2d.SIFT_create() grayPic=cv2.cvtColor(inpic,cv2.COLOR_BGR2GRAY) img1 = grayPic[100:1000,:] img2 = template[100:1000,:] kp1, des1 = sift.detectAndCompute(img1,None) kp2, des2 = sift.dete.

2021-12-07 15:19:54 445 1

原创 opencv:图像直方图均衡化

def calcGrayHist(image): rows,cols=image.shape grayHist=np.zeros([256],np.uint64) for r in range(rows): for c in range(cols): grayHist[image[r][c]]+=1 return grayHistdef equalHist(imgDir): imgGray=cv2.imread(img.

2021-12-02 22:59:48 2191

原创 opencv:gamma变换

gamma变换是对图像像素值归一化到[0,1]后,对像素值进行幂运算。def gammaTransform(imgDir): imgGray=cv2.imread(imgDir,cv2.IMREAD_GRAYSCALE) cv2.imshow("raw",imgGray) imgGrayNorm=imgGray/255 gamma=2 dst=np.power(imgGrayNorm,gamma) cv2.imshow("test",dst)

2021-12-02 21:43:14 1867

原创 opencv:线性变换

def linearTrans(imgDir): imgGray=cv2.imread(imgDir,cv2.IMREAD_GRAYSCALE) cv2.imshow("raw",imgGray) a=0.2 dst=float(2)*imgGray dst[dst>25]=255 # 将数组dst中大于25的值均设置为255  dst=np.round(dst) dst=dst.astype(np.uint8) #成员函数astype的作用改.

2021-12-02 21:39:51 2709

原创 opencv:图像归一化

def histNorm(imgDir): imgGray=cv2.imread(imgDir,cv2.IMREAD_GRAYSCALE) cv2.imshow("raw",imgGray) maxPixelsValue=np.max(imgGray) minPixelsValue=np.min(imgGray) outMin, outMax=0,255 a=float(outMax-outMin)/(maxPixelsValue-minPixelsV.

2021-12-02 21:32:37 3643

原创 opencv:计算直方图

def calcGrayHist(image): rows,cols=image.shape grayHist=np.zeros([256],np.uint64) for r in range(rows): for c in range(cols): grayHist[image[r][c]]+=1 return grayHistdef showHist(imgDir): img=cv2.imread(imgDir).

2021-12-02 20:55:22 178

原创 opencv:仿射变换

opencv API :cv2.warpAffinedef warpAffineTest(imgDir): img=cv2.imread(imgDir,cv2.IMREAD_GRAYSCALE) h,w=img.shape[:2] A1=np.array([[0.5,0,0],[0,0.5,0]],np.float32)# 缩小2倍 d1=cv2.warpAffine(img,A1,(h,w),borderValue=125) cv2.imshow(".

2021-11-30 22:02:11 900

原创 PYTHON:离线数据扩增

从网上找的一个数据扩增方式,出处不记得了。# -*- coding:utf-8 -*-"""数据增强 1. 翻转变换 flip 2. 随机修剪 random crop 3. 色彩抖动 color jittering 4. 平移变换 shift 5. 尺度变换 scale 6. 对比度变换 contrast 7. 噪声扰动 noise 8. 旋转变换/反射变换 Rotation/reflection"""from PIL import Image

2021-11-15 11:34:40 395

原创 PYTHON:调用FFMPEG

import subprocessimport os#ffmpeg -i /data/video_1.mp4 -f image2 -vf fps=fps=1/60 -qscale:v 2 /data/mp4-%05d.jpgdef videoFileName(videoDir,framesDir,ffmpegCmd): videoFiles=os.listdir(videoDir) for video in videoFiles: sinVideoDir=os..

2021-11-15 11:31:28 1399

原创 PYTHON:由标签文件生成训练集,测试集图像列表以及量化图像列表

import osimport randomdef trainTestGen(mainDir,val_percent): image_labels = [f for f in os.listdir(os.path.join(mainDir,'labels'))] # 存放labels的路径 train_file = open(mainDir + '/train.txt', 'w') val_file = open(mainDir + '/val.txt', 'w') .

2021-11-05 10:47:49 315

原创 PYTHON:将图像缩放至固定尺寸,并生成相应的路径列表

import cv2 as cvimport osdef resize_img(src_dir, dst_dir, imgList416, img_size): ''' :param src_dir: train.txt dir :param dst_dir: 416*416 img save dir :param imgList416: 416*416 img list txt file :param img_size: img scale :re.

2021-11-05 10:11:18 481

原创 YOLO:darknet model 推理 备忘

#include <iostream>#include <string>#ifdef linux#define OPENCV#define GPU#endif#include "yolo_v2_class.hpp" // imported functions from DLL#include "opencv2/opencv.hpp" // C++#include <opencv2/highgui/highgui.hpp>void draw_box.

2021-10-28 16:08:19 239

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除