import os
import cv2 as cv
import numpy as np
import random
back_dir = "Z:/data/back"
back = []
for file in os.listdir(back_dir):
if file.split('.')[-1] not in ['jpg']:
continue
path = back_dir + "/" + file
back.append(path)
np.random.shuffle(back)
data_dir = "./data/phone"
dst_dir = "Z:/data/train_data/screen/screen_07"
annt_file = "screen_07.txt"
writer = open(annt_file, "w+")
file_count = 0
pixel_value = 20
for file in os.listdir(data_dir): # 5
path = data_dir + '/' + file
# image_name = file.split('/')[-1].split('.')[0]
src = cv.imread(path, cv.IMREAD_COLOR)
size_count = 0
for w_size in range(100, 241, 5): # 28
# w_size = np.random.choice(np.arange(120, 220, 5))
src = cv.resize(src, dsize=(w_size, w_size * 2)) # 手机尺寸比例
src_h, src_w, _ = src.shape
# cv.imshow("src", src)
points = [[0, 0, 1], [0, src_h, 1], [src_w, 0, 1], [src_w, src_h, 1]]
points = np
相关推荐
AI数据增强之:数据增强的技术原理与实现方法
AI数据增强之:数据增强的技术原理与实现方法 作者:禅与计算机程序设计艺术 / Zen and the Art of Computer Programming 关键词:数据增强, 数据扩充, 图像处理, 弱监督学习, 自动化标注, 训练样本质量 1.背景介绍
Python 人工智能实战:数据增强
作者:禅与计算机程序设计艺术 1.背景介绍 在机器学习领域中,数据的质量直接影响最终的结果,而数据质量的提升往往需要借助于数据增强的方法。数据增强是指对原始训练数据进行预处理和增广,从而扩充训练集规模并提高模型的泛化能力。在很多任务中,包括图像分类、文本分类、语言模型等,数据增强技术都会起到至关重要
数据集增强技术综述(Dataset Augmentation TechniquesA Survey)
作者:禅与计算机程序设计艺术 1.简介 数据集的增广(Data augmentation),即对训练数据进行扩展、增加、或减少样本数目的方法,是数据扩充方法的一种类别。通过这种方式可以让模型更充分地利用原始数据的信息,提高模型的泛化能力、鲁棒性、抗攻击性等性能指标。数据增广技术可应用于图像、文本、音频、
Python 深度学习实战:数据增强
1.背景介绍 随着深度学习的火热,数据集的数量越来越多,训练速度越来越快,模型性能也越来越好。然而,训练这些数据集需要大量的高质量、大量的数据,如何快速地产生训练数据就成了一个难题。数据的增强(Data Augmentation)就是一个很好的解决方案。通过对已有数据进行处理,生成新的数据来提升数据集的大小,并使模型在原始数据上更准确。 数据增强技术能
面试问题总结——关于OpenCV(一)
整理了一下网上和我面试中遇到的关于OpenCV相关的问题。 其中因为我的简历中有个项目用到了特征点检测相关的知识,所以整理了SIFT/SURF和FLANN。 有些知识点也不深入,对于写的不对的地方,欢迎指正。 关于OpenCV的内容 1.OpenCV中cv::Mat的深拷贝和浅拷贝问题 深拷贝:分配新内存的同时拷贝数据,当被赋值的容器被修改时,原始容器数据不会改变。 浅拷贝:仅拷贝数据,当被赋值容器修改时,原始容器数据也会做同样改变。 OpenCV的Mat时,有几种赋值方式分别为: 深.
基于OpenCV的多角度多尺度模板匹配算法:从原理到工程实践
模板匹配是计算机视觉中的基础技术,用于在图像中定位与预设模板相似的区域。其核心原理是通过滑动窗口计算相似度,但传统方法对目标的旋转和尺度变化敏感。为解决这一问题,多角度多尺度匹配算法应运而生,它通过构建模板金字塔和搜索图像金字塔,在离散的角度和尺度空间中进行穷举搜索,显著提升了算法的鲁棒性。该技术的工程价值在于平衡了精度与效率,适用于对实时性有要求的场景。在工业质检领域,零件常以任意角度出现在传送带上;在机器人视觉导航中,路标会因视角变化呈现不同尺度。本文介绍的LZC模板匹配算法,正是基于OpenCV实现的
OpenCV-android-sdk.zip|OpenCV-android-sdk.zip
这是CTS测试Rotation Vector CV Crosscheck必须安装的apk Since version 1.7 several packages of OpenCV Manager are built. Every package is targeted for some specific hardware platform and includes corresponding OpenCV binaries. So, in most cases OpenCV Manager uses built-in version of OpenCV.
别再为CAD和GIS数据对不上而头疼了!一份完整的ArcGIS for AutoCAD坐标系定义与数据套合指南
本文详细介绍了如何通过ArcGIS for AutoCAD插件解决CAD与GIS数据坐标系不匹配的问题,实现数据的精准套合。文章从坐标系冲突分析、插件核心功能解析到五步标准化工作流,提供了完整的解决方案,帮助工程师和设计师提升跨平台协作效率。
STM32硬件SPI驱动W5500以太网模块全流程(附避坑指南)
本文详细介绍了STM32硬件SPI驱动W5500以太网模块的全流程,包括硬件架构设计、SPI接口选型、官方驱动移植、网络协议栈配置与优化等关键步骤。通过实战案例和性能对比数据,帮助开发者快速实现稳定高效的网络连接,特别提供了常见问题排查指南和性能调优技巧。
手把手教你用Github提交CVE漏洞(附完整截图流程)
本文提供了在GitHub平台提交CVE漏洞的完整实战指南。从前期准备、目标搜寻与漏洞验证,到撰写规范的GitHub Issue进行披露,最后通过官方渠道完成CVE提交,手把手教你如何将安全研究成果转化为获得国际认可的CVE编号。
技术解析:PETR如何通过3D位置编码革新多视角3D目标检测
本文深入解析了PETR模型如何通过创新的3D位置编码技术革新多视角3D目标检测。它摒弃了DETR3D复杂的投影采样机制,通过3D坐标生成器和编码器,将3D几何信息直接注入2D图像特征,构建出3D感知特征。该方法简化了流程,提升了模型对空间关系的理解能力与训练稳定性,为自动驾驶等领域的精准感知提供了新思路。
手把手教你用LIO-SAM搞定激光雷达和IMU联合标定(附避坑指南)
本文详细介绍了使用LIO-SAM进行激光雷达与IMU联合标定的全流程,包括标定原理、工具选型、硬件配置、数据采集、LI_calib标定步骤及LIO-SAM集成验证。特别提供了避坑指南和参数优化技巧,帮助开发者高效完成传感器标定,提升自动驾驶和机器人定位精度。
PayPal支付集成完全指南:开源库实践
本文介绍了如何从零开始集成PayPal支付功能。首先概述了PayPal提供的多语言SDK和开源库,包括PHP、Python、Node.js等版本。然后详细说明了准备工作,包括注册开发者账号、获取API凭证和使用沙盒环境测试。文章以Node.js为例,演示了安装SDK、基础配置和实现支付流程的完整代码,包括创建订单和捕获支付两个核心功能。最后提及了订阅支付等高级功能,为开发者提供了完整的支付集成方案。通过清晰的代码示例和步骤说明,帮助开发者快速实现PayPal支付功能集成。
PVE虚拟机运行不流畅,出现卡顿。
🏆本文收录于《优快云问答解惑-专业版》专栏,主要记录项目实战过程中的Bug之前因后果及提供真实有效的解决方案,希望能够助你一臂之力,帮你早日登顶实现财富自由🚀;同时,欢迎大家关注&&收藏&&订阅!持续更新中,up!up!up!!
PD详解 扩展消息——Source_Capabilities_Extended Message
PD的协议层分为控制消息,数据消息还有扩展消息,今天大师匈讲一下扩展消息中的source_cap_extended。这个消息在扩展消息中算是比较关键的东西。 扩展消息中的source_cap_extended 大师匈先上图,然后逐一解释; 上面的图表说了source_cap_ext中包含了哪些内容。 我们注意到在source_cap扩展消息中是以字节为单位的,并不是像source_cap中以一个object为单位,当然有注意到PD标准spec中说明的扩展消息的话,那里有说明,在header之后的字节
Statistics and Machine Learning Toolbox
Statistics and Machine Learning Toolbox(带书签),MATLAB统计学习工具
廖雪峰Python教程[完整版]
廖雪峰的python教程整理的,已经排好版了,而且还是完整的,适合小白
数学建模模型总结
这是本人在两年内准备参加数学建模竞赛搜集到的模型资料,已经经过了本人的筛选和整理,希望能够对准备参加数学建模竞赛的学弟学妹们提供一些帮助!
深度学习工具包 DeepLearningToolbox
深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[](https://bitdeli.com/free "Bitdeli Badge")
1265



被折叠的 条评论
为什么被折叠?



