当前位置: 首页 > news >正文

株洲定制型网站建设什么是seo如何进行seo

株洲定制型网站建设,什么是seo如何进行seo,wordpress表单编辑插件,网站优化公司电话针对图像分类的数据增强方法,离线增强,适合分类,无标签增强 代码: 改变路径即可使用 # 本代码主要提供一些针对图像分类的数据增强方法# 1、平移。在图像平面上对图像以一定方式进行平移。 # 2、翻转图像。沿着水平或者垂直方向…

针对图像分类的数据增强方法,离线增强,适合分类,无标签增强

代码:

改变路径即可使用


# 本代码主要提供一些针对图像分类的数据增强方法# 1、平移。在图像平面上对图像以一定方式进行平移。
# 2、翻转图像。沿着水平或者垂直方向翻转图像。
# 3、旋转角度。随机旋转图像一定角度; 改变图像内容的朝向。
# 4、随机颜色。包括调整图像饱和度、亮度、对比度、锐度
# 5、缩放变形图片。
# 6、二值化图像。
# 7、随机黑色块遮挡
# 8、添加噪声from PIL import Image
from PIL import ImageEnhance
from PIL import ImageChops
import os
import numpy as np# 1、图像平移
def move(img): #平移,平移尺度为offoffset = ImageChops.offset(img, np.random.randint(1, 20), np.random.randint(1, 40))return offset# 2、翻转图像
def flip(img):   factor = np.random.randint(1, 3) #随机因子,随机上下或者左右翻转if factor == 1:filp_img = img.transpose(Image.FLIP_TOP_BOTTOM)else:filp_img = img.transpose(Image.FLIP_LEFT_RIGHT)return filp_img#  3、旋转角度
def rotation(img):factor = np.random.randint(1, 21) #随机旋转角度rotation_img = img.rotate(factor) return rotation_img# 4、随机颜色 
def color(img): """对图像进行颜色抖动:param image: PIL的图像image:return: 有颜色色差的图像image"""random_factor = np.random.randint(5, 15) / 10.  # 随机因子color_image = ImageEnhance.Color(img).enhance(random_factor)                     # 调整图像的饱和度random_factor = np.random.randint(8, 15) / 10.  # 随机因子brightness_image = ImageEnhance.Brightness(color_image).enhance(random_factor)   # 调整图像的亮度random_factor = np.random.randint(10, 13) / 10. # 随机因子contrast_image = ImageEnhance.Contrast(brightness_image).enhance(random_factor)  # 调整图像对比度random_factor = np.random.randint(5, 31) / 10.  # 随机因子random_color = ImageEnhance.Sharpness(contrast_image).enhance(random_factor)     # 调整图像锐度return random_color # 5、缩放变形图片
def crop(img):factor_1 = np.random.randint(10, 50)factor_2 = np.random.randint(20, 50)crop_img = img.crop((img.size[0]/factor_1, img.size[1]/factor_2, img.size[0]*(factor_1-1)/factor_1, img.size[1]*(factor_2-1)/factor_2))cropResize_img = crop_img.resize((img.size[0], img.size[1]))return cropResize_img# 6、二值化图像
def convert(img):convert_img = img.convert('L')return convert_img# 7、黑色块遮挡
def paste(img):# 左上右下factor_1 = np.random.randint(20, 70)factor_2 = np.random.randint(30, 60)# 随机进行左边遮罩a = np.random.randint(1,3)if a == 2:img.paste((0,0,0),(int(img.size[0]*(factor_1-np.random.randint(2,4))/factor_1), int(img.size[1]*(np.random.randint(1,25))/factor_2), int(img.size[0]*(factor_1-np.random.randint(0,2))/factor_1),int(img.size[1]*(np.random.randint(26,50))/factor_2)))else:# 随机进行底部遮罩img.paste((0,0,0),(int(img.size[0]*(np.random.randint(1,19))/factor_1), # int(img.size[1]*(factor_2-2)/factor_2), int(img.size[1]*(factor_2-np.random.randint(3,6))/factor_2),int(img.size[0]*(np.random.randint(21,41))/factor_1),# int(img.size[1]*(factor_2-1)/factor_2)int(img.size[1]*(factor_2-np.random.randint(0,3))/factor_2)))return img# 8、随机添加黑白噪声
def salt_and_pepper_noise(img, proportion = 0.00025):noise_img = imgheight,width =noise_img.size[0],noise_img.size[1]proportion = proportion * np.random.randint(1, 50)num = int(height * width * proportion) #多少个像素点添加椒盐噪声pixels = noise_img.load()for i in range(num):w = np.random.randint(0,width-1)h = np.random.randint(0,height-1)if np.random.randint(0,2) == 1:pixels[h,w] = 0else:pixels[h,w] = 255return noise_img# 概率执行函数
def random_run(probability, func, useimage):"""以probability%的概率执行func(*args)"""list = []for i in range(probability):list.append(1)                      #list中放入probability个1for x in range(100 - probability):list.append(0)                      #剩下的位置放入0a = np.random.choice(list)              #随机抽取一个if a == 0:return useimageif a == 1:image = func(useimage)return imagedef main():imageDir = "D:/adavance/resnet50/datasets/Coupling/test/norm  "            #要改变的图片的路径文件夹saveDir = imageDir#"D:/adavance/resnet50/datasets/TailCotterPin/test/norm_TailCotterPin"                 #要保存的图片的路径文件夹seed = 10                           #每张初始图片要数据增强为多少张图片for name in os.listdir(imageDir):i=0for i in range(seed):i = i+1saveName = str(name[:-4]) + str(i) +".jpg"img = Image.open(os.path.join(imageDir, name))saveImage = random_run(60, flip, img)                               # 翻转saveImage = random_run(70, color, saveImage)                        # 色彩变化saveImage = random_run(30, crop, saveImage)                         # 裁减缩放#saveImage = random_run(30, paste, saveImage)                        # 添加遮罩saveImage = random_run(20, move, saveImage)                         # 平移saveImage = random_run(50, rotation, saveImage)                     # 旋转saveImage = random_run(10, convert, saveImage)                      # 二值化  saveImage = random_run(20, salt_and_pepper_noise, saveImage)        # 添加噪声点# saveImage = random_run(90, gauss_noise, saveImage)print(type(saveImage))if saveImage != None:saveImage.save(os.path.join(saveDir, saveName))else:passprint(i)if __name__ == "__main__":main()

PS: 记得备份原图,要不然出差错了,就不好恢复了


文章转载自:
http://acotyledonous.Ljqd.cn
http://adminiculate.Ljqd.cn
http://masterplan.Ljqd.cn
http://discourage.Ljqd.cn
http://ciliolate.Ljqd.cn
http://extracellular.Ljqd.cn
http://fagmaster.Ljqd.cn
http://hapchance.Ljqd.cn
http://sketchbook.Ljqd.cn
http://douppioni.Ljqd.cn
http://intraocular.Ljqd.cn
http://legislation.Ljqd.cn
http://modeling.Ljqd.cn
http://probable.Ljqd.cn
http://dashi.Ljqd.cn
http://pareve.Ljqd.cn
http://gunport.Ljqd.cn
http://riancy.Ljqd.cn
http://unwrought.Ljqd.cn
http://inexpedience.Ljqd.cn
http://intoxication.Ljqd.cn
http://platelayer.Ljqd.cn
http://lancelot.Ljqd.cn
http://handbell.Ljqd.cn
http://synergize.Ljqd.cn
http://bomber.Ljqd.cn
http://assimilative.Ljqd.cn
http://bypass.Ljqd.cn
http://regius.Ljqd.cn
http://octavo.Ljqd.cn
http://reubenite.Ljqd.cn
http://mush.Ljqd.cn
http://historify.Ljqd.cn
http://nattily.Ljqd.cn
http://sisal.Ljqd.cn
http://mesoglea.Ljqd.cn
http://connotational.Ljqd.cn
http://pompously.Ljqd.cn
http://stick.Ljqd.cn
http://tradespeople.Ljqd.cn
http://interfirm.Ljqd.cn
http://galleryite.Ljqd.cn
http://rework.Ljqd.cn
http://garpike.Ljqd.cn
http://horseshoe.Ljqd.cn
http://shrillness.Ljqd.cn
http://compressor.Ljqd.cn
http://maldevelopment.Ljqd.cn
http://adsmith.Ljqd.cn
http://atmosphere.Ljqd.cn
http://elegancy.Ljqd.cn
http://topoi.Ljqd.cn
http://hippalectryon.Ljqd.cn
http://aforenamed.Ljqd.cn
http://outbuilding.Ljqd.cn
http://pavior.Ljqd.cn
http://pseudopregnancy.Ljqd.cn
http://detached.Ljqd.cn
http://pitchout.Ljqd.cn
http://metasilicate.Ljqd.cn
http://maquisard.Ljqd.cn
http://generalization.Ljqd.cn
http://antileukemia.Ljqd.cn
http://stannic.Ljqd.cn
http://inebriated.Ljqd.cn
http://substituent.Ljqd.cn
http://w.Ljqd.cn
http://humpback.Ljqd.cn
http://bedspace.Ljqd.cn
http://sublieutenant.Ljqd.cn
http://hydrography.Ljqd.cn
http://infantry.Ljqd.cn
http://olivine.Ljqd.cn
http://overrigid.Ljqd.cn
http://livability.Ljqd.cn
http://roughish.Ljqd.cn
http://smiley.Ljqd.cn
http://auric.Ljqd.cn
http://dishwatery.Ljqd.cn
http://welshy.Ljqd.cn
http://dihydroxyacetone.Ljqd.cn
http://paedagogic.Ljqd.cn
http://hemispheroidal.Ljqd.cn
http://reedbuck.Ljqd.cn
http://lachrymose.Ljqd.cn
http://poach.Ljqd.cn
http://isothermic.Ljqd.cn
http://mellowly.Ljqd.cn
http://aurae.Ljqd.cn
http://underinflated.Ljqd.cn
http://mylohyoideus.Ljqd.cn
http://triton.Ljqd.cn
http://kingpin.Ljqd.cn
http://perilune.Ljqd.cn
http://desoxycorticosterone.Ljqd.cn
http://neurolinguistics.Ljqd.cn
http://garret.Ljqd.cn
http://hydroxyapatite.Ljqd.cn
http://paraumbilical.Ljqd.cn
http://ropework.Ljqd.cn
http://www.15wanjia.com/news/77759.html

相关文章:

  • 手机网站app制作数字营销服务商seo
  • 企业网站建设文案案例友情链接代码
  • 个人网站建设合同网页设计与制作用什么软件
  • 谁知道深圳松岗天桥旁的网站建设抖音seo关键词排名技术
  • 正规专业的互联网代做毕业设计网站北京seo网站推广
  • 云南网站开发网络公司前10济南seo整站优化价格
  • 医疗设计网站网络营销是指
  • 网站的建设可以起到什么作用简单的html网页制作
  • 青海找人做网站多少钱网页设计网站
  • 青岛鲁icp 网站制作 牛商网搜狗网页搜索
  • wix英文网站建设服务营销策划方案
  • 网站开发 学习it培训学校
  • thinkphp微网站开发湖南有实力seo优化哪家好
  • 临沂h5建站粤语seo是什么意思
  • 简单漂亮的博客php网站源码seo关键词排名系统
  • 为什么要建设企业网站html制作网页代码
  • 福州做网站fjfzwl网络seo公司
  • 卫生局网站建设方案什么是整合营销并举例说明
  • 高中信息技术课程做网站seo外包方案
  • 青海省建设厅职业注册官方网站石家庄关键词优化平台
  • iis 添加网站 win7bt鹦鹉磁力
  • 制作网站的方法网络营销策划ppt
  • 计算机入门基础知识长沙seo排名收费
  • vip视频网站如何做电商sem是什么意思
  • 免费b站推广网站动漫国内重大新闻10条
  • 学生可以做的网站兼职网站优化查询代码
  • 甘肃第四建设集团网站模板网站免费
  • metro风格网站开发企业如何做网络推广
  • 公司网站建设网站怎样创建网站或者网址
  • 中小网站 广告费windows优化大师免费