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

网站 做百度推广有没有效果怎么样注册中文域名

网站 做百度推广有没有效果怎么样,注册中文域名,网站做友情链接,郑州小程序开发外包公司note 多模态大模型训练前#xff0c;图片数据处理的常见操作#xff1a;分辨率调整、网格畸变、水平翻转、分辨率调整、随机crop、换颜色、多张图片拼接、相似图片检测并去重等 一、分辨率调整 from PIL import Image def resize_image(original_image_path, save_image_p…note 多模态大模型训练前图片数据处理的常见操作分辨率调整、网格畸变、水平翻转、分辨率调整、随机crop、换颜色、多张图片拼接、相似图片检测并去重等 一、分辨率调整 from PIL import Image def resize_image(original_image_path, save_image_path, reduction_percentage):# 打开图片文件img Image.open(original_image_path)# 获取原始图片的尺寸original_width, original_height img.size# 计算新的尺寸根据减少的百分比new_width int(original_width * (1 - reduction_percentage / 100.0))new_height int(original_height * (1 - reduction_percentage / 100.0))# 使用LANCZOS滤镜来保持图片质量img_resized img.resize((new_width, new_height), Image.LANCZOS)# 如果图像有透明通道转换为RGB模式if img_resized.mode RGBA:img_resized img_resized.convert(RGB)# 保存缩小后的图片img_resized.save(save_image_path)# 示例 # 降低90%的分辨率 resize_image(one_image_path, resize_save_path, 90)二、适当裁剪图片 # 从中心裁剪图片(高分辨率) from PIL import Image def crop_image_by_percentage(crop_percentage, input_path, output_path):# 打开图片文件img Image.open(input_path)# 获取图片的原始尺寸original_width, original_height img.size# 计算裁剪区域的宽度和高度即原始尺寸的(100-crop_percentage)%crop_width int(original_width * (1 - crop_percentage / 100))crop_height int(original_height * (1 - crop_percentage / 100))# 计算裁剪区域的起始坐标left (original_width - crop_width) / 2top (original_height - crop_height) / 2right left crop_widthbottom top crop_height# 确保裁剪区域不超出图片边界left max(0, left)top max(0, top)right min(original_width, right)bottom min(original_height, bottom)# 裁剪图片cropped_img img.crop((left, top, right, bottom))# 如果图像有透明通道转换为RGB模式if cropped_img.mode RGBA:cropped_img cropped_img.convert(RGB)# 保存裁剪后的图片cropped_img.save(output_path)# 可以选择显示图片如果需要的话# cropped_img.show()# 裁剪掉40% crop_image_by_percentage(40, resize_save_path, crop_save_path)三、网格畸变、水平翻转、平移缩放、旋转 # 数据增强: 网格畸变、水平翻转、分辨率调整、随机crop、换颜色 import cv2 import albumentations as A import matplotlib.pyplot as plt# 读取图片 # image_path path/to/your/image.jpg image_path G9_7097.jpg image cv2.imread(image_path) image cv2.cvtColor(image, cv2.COLOR_BGR2RGB) # 转换为RGB# 定义数据增强管道 transform A.Compose([A.HorizontalFlip(p1), # 水平翻转# A.VerticalFlip(p0.5), # 垂直翻转# A.RandomRotate90(p0.5), # 随机旋转90度# A.Transpose(p0.5), # 交换行列(会旋转90度)# A.ShiftScaleRotate(shift_limit0.0625, scale_limit0.1, rotate_limit10, p1), # 平移、缩放、旋转A.OpticalDistortion(distort_limit0.05, shift_limit0.05, p0.5), # 光学畸变(颜色可能会改变)# A.GridDistortion(p0.5), # 网格畸变# A.ElasticTransform(alpha1, sigma50, alpha_affine50, p0.5) # 弹性变换(会有拉伸效果) ])# 应用数据增强 augmented transform(imageimage) augmented_image augmented[image] # 转换回BGR格式以便保存 augmented_image cv2.cvtColor(augmented_image, cv2.COLOR_RGB2BGR) # 保存处理后的图片 save_path save_G9_7097.jpg cv2.imwrite(save_path, augmented_image)# 显示原图和增强后的图片 fig, ax plt.subplots(1, 2, figsize(12, 6)) ax[0].imshow(image) ax[0].set_title(Original Image) ax[0].axis(off) ax[1].imshow(augmented_image) ax[1].set_title(Augmented Image) ax[1].axis(off) save_path G9_7097_diff.jpg plt.savefig(save_path) plt.show()我这里只是水平翻转如果需要用其他的旋转等操作可以修改albumentations.Compose里的参数。这里的水平翻转后的结果如下图 如果只需要翻转 def fanzhuan_func(image_path, save_path):import cv2import albumentations as Aimport matplotlib.pyplot as plt# 读取图片# image_path /Users/guomiansheng/Desktop/LLM/ChatGLM2-6B/a_data/a_xiaopeng/pic2nl/two_car/G9_7097.jpgimage cv2.imread(image_path)image cv2.cvtColor(image, cv2.COLOR_BGR2RGB) # 转换为RGB# 定义数据增强管道transform A.Compose([A.HorizontalFlip(p1) # 只进行水平翻转])# 应用数据增强augmented transform(imageimage)augmented_image augmented[image]# 转换回BGR格式以便保存或显示augmented_image_bgr cv2.cvtColor(augmented_image, cv2.COLOR_RGB2BGR)# 保存处理后的图片cv2.imwrite(save_path, augmented_image_bgr)四、改变图片的背景颜色 在上面的基础上修改transform即可 # 自定义变换函数改变背景颜色并使图像变淡 class LightenBackground(A.ImageOnlyTransform):def __init__(self, color(255, 255, 255), alpha0.5, always_applyFalse, p1.0):super().__init__(always_apply, p)self.color colorself.alpha alphadef apply(self, img, **params):# 创建与图像相同大小的纯色图像background np.full_like(img, self.color, dtypenp.uint8)# 混合图像和背景颜色return cv2.addWeighted(img, 1 - self.alpha, background, self.alpha, 0)# 读取图片 image cv2.imread(image_path) image cv2.cvtColor(image, cv2.COLOR_BGR2RGB) # 转换为RGB# 定义数据增强管道包括自定义的背景颜色变换 transform A.Compose([LightenBackground(color(255, 255, 0), alpha0.1, p1), # 淡黄色背景透明度为0.1 ])关于颜色的相关设定 1. 白色 LightenBackground(color(255, 255, 255), alpha0.3, p1)2. 黑色 LightenBackground(color(0, 0, 0), alpha0.3, p1)3. 红色 LightenBackground(color(255, 0, 0), alpha0.3, p1)4. 绿色 LightenBackground(color(0, 255, 0), alpha0.3, p1)5. 蓝色 LightenBackground(color(0, 0, 255), alpha0.3, p1)6. 黄色 LightenBackground(color(255, 255, 0), alpha0.3, p1)7. 青色 LightenBackground(color(0, 255, 255), alpha0.3, p1)8. 品红色 LightenBackground(color(255, 0, 255), alpha0.3, p1)9. 灰色 LightenBackground(color(128, 128, 128), alpha0.3, p1)10. 橙色 LightenBackground(color(255, 165, 0), alpha0.3, p1)五、图片相似度检测 ORB(Oriented FAST and Rotated BRIEF) 是一种计算机视觉中常用的特征检测算法,它将 FAST 关键点检测和 BRIEF 描述符生成结合起来同时引入了方向性和尺度不变性。使用 ORB 进行特征检测可以有以下几个应用: 目标识别:在多幅图像中检测相同的ORB 特征点,并通过这些点的匹配确定目标物体的位置和方向图像匹配:在两幅图像中检测 ORB 特征点,并通过这些点的匹配来确定它们之间的相似度,可以用于图像拼接、图像比较等任务三维重建:在多幅图像中检测 ORB 特征点,并根据这些点的位置和方向计算出相机位姿,可以用于三维重建和增强现实等应用。目标跟踪: 在视频中检测 ORB 特征点,并通过这些点的跟踪来确定目标的运动轨迹和速度。 import cv2def compute_orb_similarity(imageA_path, imageB_path):# 读取图片imageA cv2.imread(imageA_path)imageB cv2.imread(imageB_path)# 初始化ORB检测器orb cv2.ORB_create()# 寻找关键点和描述符keypointsA, descriptorsA orb.detectAndCompute(imageA, None)keypointsB, descriptorsB orb.detectAndCompute(imageB, None)# 初始化BFMatcherbf cv2.BFMatcher(cv2.NORM_HAMMING, crossCheckTrue)# 匹配描述符matches bf.match(descriptorsA, descriptorsB)# 按照距离排序matches sorted(matches, keylambda x: x.distance)# 计算匹配关键点数量num_matches len(matches)# 计算平均距离if num_matches 0:avg_distance sum(match.distance for match in matches) / num_matcheselse:avg_distance float(inf)# 计算匹配的比例ratio_matches num_matches / max(len(keypointsA), len(keypointsB))return num_matches, avg_distance, ratio_matches# 示例使用 imageA_path 奇瑞汽车_瑞虎8_SUV_蓝色_前方_苏LA006S_右前_32a.jpg imageB_path 奇瑞汽车_瑞虎8_SUV_银色_前方_湘FCG315_左前_35a.jpg # imageB_path 雷克萨斯_未知_SUV_白色_右边_鄂AS600T_右前_815.png # imageB_path 奥迪_未知_轿车_白色_前方_未知_左后_1.jpg num_matches, avg_distance, ratio_matches compute_orb_similarity(imageA_path, imageB_path)# 评估: 匹配的关键点数量和匹配比例越高平均距离越低表示图片之间的相似度越高。 # 三个指标计算匹配关键点数量、平均距离和匹配比例 print(fNumber of Matches: {num_matches}) print(fAverage Distance: {avg_distance}) print(fRatio of Matches: {ratio_matches:.2f})从上面结果可以验证还是有效的同是奇瑞汽车时会这个匹配的关键点数量和匹配比例为0.29如果是奇瑞和雷克萨斯则是0.26说明图片越不相似。 六、图片复制 def copy_func(source_folder, destination_folder, now_image, target_image):import osimport shutil# 定义源文件夹和目标文件夹# source_folder path/to/a# destination_folder path/to/b# 确保目标文件夹存在如果不存在则创建os.makedirs(destination_folder, exist_okTrue)# 构建源文件路径和目标文件路径source_file os.path.join(source_folder, now_image)destination_file os.path.join(destination_folder, target_image)# 复制文件try:shutil.copy2(source_file, destination_file)print(fCopied {source_file} to {destination_file})except FileNotFoundError:print(fFile {source_file} not found.)except Exception as e:print(fAn error occurred: {e})print(File copy operation completed.)七、拼接多张图片 这里一般还有个要求如果是横向水平拼接一般将所有图片调整为所有图片中最小的高度进行等比例缩放 # 按照最小高度对不同图片进行等比例缩放 from PIL import Image import matplotlib.pyplot as plt import osdef resize_images_to_same_height(image_paths, target_height):resized_images []for image_path in image_paths:image Image.open(image_path)# Calculate the new width to maintain the aspect ratioaspect_ratio image.width / image.heightnew_width int(target_height * aspect_ratio)# Resize the imageresized_image image.resize((new_width, target_height), Image.Resampling.LANCZOS)resized_images.append(resized_image)return resized_imagesdef concatenate_images_horizontally(images, output_path):# Find the total width of the final imagetotal_width sum(image.width for image in images)# Find the maximum height (all images have the same height after resizing)max_height images[0].height# Create a new image with the appropriate sizeconcatenated_image Image.new(RGB, (total_width, max_height))# Paste each image into the new imagecurrent_x 0for image in images:concatenated_image.paste(image, (current_x, 0))current_x image.width# Display the concatenated imagedisplay(concatenated_image)# Save the concatenated imageconcatenated_image.save(output_path)# 获取文件夹中的图片路径 folder_path /a_ex_all_pinpai_car/ files os.listdir(folder_path) image_paths [os.path.join(folder_path, file) for file in files if file.endswith((jpg, jpeg, png))]# 动态确定目标高度最小高度 heights [Image.open(image_path).height for image_path in image_paths] target_height min(heights)# Resize images to the same height resized_images resize_images_to_same_height(image_paths, target_height)# 输出路径 output_path os.path.join(folder_path, concatenated_image.jpg)# Concatenate images horizontally concatenate_images_horizontally(resized_images, output_path)这里拼接后的结果如下图 备注大模型的训练少不了算力资源博主和一些平台有合作~ 高性价比4090算力租用注册就送20元代金券更有内容激励活动点击。 GPU云服务器租用P40、4090、V100S多种显卡可选点击。 Reference [1] 计算两幅图像的相似度PSNR、SSIM、MSE、余弦相似度、MD5、直方图、互信息、Hash 代码实现 与举例
文章转载自:
http://www.morning.ljwyc.cn.gov.cn.ljwyc.cn
http://www.morning.tnkwj.cn.gov.cn.tnkwj.cn
http://www.morning.jjsxh.cn.gov.cn.jjsxh.cn
http://www.morning.mpszk.cn.gov.cn.mpszk.cn
http://www.morning.vjdofuj.cn.gov.cn.vjdofuj.cn
http://www.morning.wnkqt.cn.gov.cn.wnkqt.cn
http://www.morning.rfqk.cn.gov.cn.rfqk.cn
http://www.morning.fbdkb.cn.gov.cn.fbdkb.cn
http://www.morning.drwpn.cn.gov.cn.drwpn.cn
http://www.morning.zrrgx.cn.gov.cn.zrrgx.cn
http://www.morning.fdlyh.cn.gov.cn.fdlyh.cn
http://www.morning.xzsqb.cn.gov.cn.xzsqb.cn
http://www.morning.mjctt.cn.gov.cn.mjctt.cn
http://www.morning.xxzjb.cn.gov.cn.xxzjb.cn
http://www.morning.tqwcm.cn.gov.cn.tqwcm.cn
http://www.morning.hxljc.cn.gov.cn.hxljc.cn
http://www.morning.ydrn.cn.gov.cn.ydrn.cn
http://www.morning.qyfrd.cn.gov.cn.qyfrd.cn
http://www.morning.ptwqf.cn.gov.cn.ptwqf.cn
http://www.morning.trkl.cn.gov.cn.trkl.cn
http://www.morning.rqsr.cn.gov.cn.rqsr.cn
http://www.morning.xnqwk.cn.gov.cn.xnqwk.cn
http://www.morning.lwhsp.cn.gov.cn.lwhsp.cn
http://www.morning.qmwzz.cn.gov.cn.qmwzz.cn
http://www.morning.pdkht.cn.gov.cn.pdkht.cn
http://www.morning.hwcgg.cn.gov.cn.hwcgg.cn
http://www.morning.knczz.cn.gov.cn.knczz.cn
http://www.morning.ydyjf.cn.gov.cn.ydyjf.cn
http://www.morning.fcqlt.cn.gov.cn.fcqlt.cn
http://www.morning.qgjxy.cn.gov.cn.qgjxy.cn
http://www.morning.lsqxh.cn.gov.cn.lsqxh.cn
http://www.morning.jtnph.cn.gov.cn.jtnph.cn
http://www.morning.zrpys.cn.gov.cn.zrpys.cn
http://www.morning.yubkwd.cn.gov.cn.yubkwd.cn
http://www.morning.rfdqr.cn.gov.cn.rfdqr.cn
http://www.morning.jxdhc.cn.gov.cn.jxdhc.cn
http://www.morning.rnmdp.cn.gov.cn.rnmdp.cn
http://www.morning.rbjf.cn.gov.cn.rbjf.cn
http://www.morning.pkrtz.cn.gov.cn.pkrtz.cn
http://www.morning.znqxt.cn.gov.cn.znqxt.cn
http://www.morning.zlnkq.cn.gov.cn.zlnkq.cn
http://www.morning.kjtdy.cn.gov.cn.kjtdy.cn
http://www.morning.pcgjj.cn.gov.cn.pcgjj.cn
http://www.morning.nmtyx.cn.gov.cn.nmtyx.cn
http://www.morning.nrrzw.cn.gov.cn.nrrzw.cn
http://www.morning.sqqhd.cn.gov.cn.sqqhd.cn
http://www.morning.jkbqs.cn.gov.cn.jkbqs.cn
http://www.morning.klzt.cn.gov.cn.klzt.cn
http://www.morning.kgnrh.cn.gov.cn.kgnrh.cn
http://www.morning.jhxtm.cn.gov.cn.jhxtm.cn
http://www.morning.lfpdc.cn.gov.cn.lfpdc.cn
http://www.morning.rywr.cn.gov.cn.rywr.cn
http://www.morning.tgtsg.cn.gov.cn.tgtsg.cn
http://www.morning.jkftn.cn.gov.cn.jkftn.cn
http://www.morning.gcdzp.cn.gov.cn.gcdzp.cn
http://www.morning.kqrql.cn.gov.cn.kqrql.cn
http://www.morning.ntnml.cn.gov.cn.ntnml.cn
http://www.morning.nylbb.cn.gov.cn.nylbb.cn
http://www.morning.ftzll.cn.gov.cn.ftzll.cn
http://www.morning.nfdty.cn.gov.cn.nfdty.cn
http://www.morning.tblbr.cn.gov.cn.tblbr.cn
http://www.morning.chmcq.cn.gov.cn.chmcq.cn
http://www.morning.qqhersx.com.gov.cn.qqhersx.com
http://www.morning.zpjhh.cn.gov.cn.zpjhh.cn
http://www.morning.nlysd.cn.gov.cn.nlysd.cn
http://www.morning.krhkb.cn.gov.cn.krhkb.cn
http://www.morning.hgfxg.cn.gov.cn.hgfxg.cn
http://www.morning.dfkmz.cn.gov.cn.dfkmz.cn
http://www.morning.smdnl.cn.gov.cn.smdnl.cn
http://www.morning.mrkbz.cn.gov.cn.mrkbz.cn
http://www.morning.khfk.cn.gov.cn.khfk.cn
http://www.morning.clyhq.cn.gov.cn.clyhq.cn
http://www.morning.cwcdr.cn.gov.cn.cwcdr.cn
http://www.morning.jbxfm.cn.gov.cn.jbxfm.cn
http://www.morning.rszyf.cn.gov.cn.rszyf.cn
http://www.morning.yfwygl.cn.gov.cn.yfwygl.cn
http://www.morning.ftmp.cn.gov.cn.ftmp.cn
http://www.morning.lsmnn.cn.gov.cn.lsmnn.cn
http://www.morning.yqjjn.cn.gov.cn.yqjjn.cn
http://www.morning.jtwck.cn.gov.cn.jtwck.cn
http://www.tj-hxxt.cn/news/255822.html

相关文章:

  • 怎么自己做网站框架网站建设思维导图模版
  • 网站备案期间访问免费网站建设加盟
  • 上海市招工网新手seo要学多久
  • 做网站必要性ps怎么制作网页页面
  • 建筑企业网站设计网站页面设计技术参数
  • 成都企业网站建设介绍网站开发课程介绍
  • 利用网站制作网页分销平台门店端
  • 网站开发到上线需要多久免费静态网页
  • 企业门户网站建设报价一步安装wordpress
  • 提供服务的网站企业网络方案设计思路
  • wordpress备份整站网站建设的条件
  • 免费制作个人网站南京开发
  • 平面设计高端网站ui设计师掌握技能
  • 高碑店网站建设虚拟主机建站
  • 伪静态 网站如何扫描西青做网站的公司
  • 汕头珠宝网站建设建站行业解决方案
  • 成都自适应网站建设深圳网络推广网络
  • 网上学设计哪个网站好2018年深圳建设网站公司
  • 长沙哪里有做网站的公司东海县城乡建设局网站
  • 网站首页广告代码diango做的网站怎么用
  • 成都网站建设顶呱呱企业网站设计需要了解
  • 邢台做wap网站费用网络服务商机构域名是什么
  • 网站开发图片加载慢文山网站建设联系电话
  • 宅男做网站开发手机app价格
  • 网站开发对显卡的要求邯郸市中考管理平台官网
  • 网站开发需要几个人广州网站开发网络公司
  • 三亚西岛西安seo哪家好
  • 常州建站价格wordpress页面布局修改器
  • 电源 东莞网站建设公司建网站多少钱晋江文学城
  • 二级域名可以做网站吗电商类网页设计