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

做网站商城公司做的网站怎么维护

做网站商城,公司做的网站怎么维护,工装装饰公司,wordpress 知识库模板准备 官方教程#xff1a; 任意风格的快速风格转换 模型下载地址#xff1a; https://tfhub.dev/google/magenta/arbitrary-image-stylization-v1-256/2 学习 加载要处理的内容图片和风格图片 # 用于将图像裁剪为方形def crop_center(image):# 图片原始形状shape image…准备 官方教程 任意风格的快速风格转换 模型下载地址 https://tfhub.dev/google/magenta/arbitrary-image-stylization-v1-256/2 学习 加载要处理的内容图片和风格图片 # 用于将图像裁剪为方形def crop_center(image):# 图片原始形状shape image.shape# 新形状new_shape min(shape[1], shape[2])offset_y max(shape[1]-shape[2], 0) // 2offset_x max(shape[2]-shape[1], 0) // 2# 返回新图片image tf.image.crop_to_bounding_box(image, offset_y, offset_x, new_shape, new_shape)return image# 加载并预处理图片def load_image(image_url, image_size(256, 256), preserve_aspect_ratioTrue):# 缓存图像文件image_path tf.keras.utils.get_file(os.path.basename(image_url)[-128:], image_url)# 加载并转换为float32 numpy数组添加批次维度并规范化为范围[01]。img tf.io.decode_image(tf.io.read_file(image_path),channels3, dtypetf.float32)[tf.newaxis, ...]img crop_center(img)img tf.image.resize(img, image_size, preserve_aspect_ratioTrue)return img# 展示图片def show_n(images, titles(,)):n len(images)image_sizes [image.shape[1] for image in images]w (image_sizes[0] * 6) // 320plt.figure(figsize(w * n, w))gs gridspec.GridSpec(1, n, width_ratiosimage_sizes)for i in range(n):plt.subplot(gs[i])plt.imshow(images[i][0], aspectequal)plt.axis(off)plt.title(titles[i] if len(titles) i else )plt.show()content_image_url https://scpic3.chinaz.net/files/default/imgs/2023-11-16/6e397d19e172be9f_s.jpg style_image_url https://scpic3.chinaz.net/files/default/imgs/2023-11-05/d217bbaf821e3a73_s.jpg output_image_size 384# 调整内容图像的大小 content_img_size (output_image_size, output_image_size) # 样式图片大小 style_img_size (256, 256) # 加载并展示图片 content_image load_image(content_image_url, content_img_size) style_image load_image(style_image_url, style_img_size) style_image tf.nn.avg_pool(style_image, ksize[3, 3], strides[1, 1], paddingSAME) show_n([content_image, style_image], [Content image, Style image])加载模型进行风格迁移 # 加载模型 hub_module hub.load(./magenta_arbitrary-image-stylization-v1-256_2) # 风格迁移 outputs hub_module(tf.constant(content_image), tf.constant(style_image)) stylized_image outputs[0] # 展示迁移后的图片 show_n([content_image, style_image, stylized_image], titles[Original content image, Style image, Stylized image])加载本地图片 加载本地图片的话只需要将加载网络图片的代码改成下面的 def load_image(image_url, image_size(256, 256), preserve_aspect_ratioTrue):# 缓存图像文件# image_path tf.keras.utils.get_file(# os.path.basename(image_url)[-128:], image_url)# 加载并转换为float32 numpy数组添加批次维度并规范化为范围[01]。img tf.io.decode_image(tf.io.read_file(image_url),channels3, dtypetf.float32)[tf.newaxis, ...]img crop_center(img)img tf.image.resize(img, image_size, preserve_aspect_ratioTrue)return img下面的效果图是基于一只狗和梵高的星空生成的 完整代码 # import os from matplotlib import gridspec import matplotlib.pylab as plt import numpy as np import tensorflow as tf import tensorflow_hub as hub# 用于将图像裁剪为方形def crop_center(image):# 图片原始形状shape image.shape# 新形状new_shape min(shape[1], shape[2])offset_y max(shape[1]-shape[2], 0) // 2offset_x max(shape[2]-shape[1], 0) // 2# 返回新图片image tf.image.crop_to_bounding_box(image, offset_y, offset_x, new_shape, new_shape)return image# 加载并预处理图片def load_image(image_url, image_size(256, 256), preserve_aspect_ratioTrue):# 缓存图像文件# image_path tf.keras.utils.get_file(# os.path.basename(image_url)[-128:], image_url)# 加载并转换为float32 numpy数组添加批次维度并规范化为范围[01]。img tf.io.decode_image(tf.io.read_file(image_url),channels3, dtypetf.float32)[tf.newaxis, ...]img crop_center(img)img tf.image.resize(img, image_size, preserve_aspect_ratioTrue)return img# 展示图片def show_n(images, titles(,)):n len(images)image_sizes [image.shape[1] for image in images]w (image_sizes[0] * 6) // 320plt.figure(figsize(w * n, w))gs gridspec.GridSpec(1, n, width_ratiosimage_sizes)for i in range(n):plt.subplot(gs[i])plt.imshow(images[i][0], aspectequal)plt.axis(off)plt.title(titles[i] if len(titles) i else )plt.show()content_image_url image/dog.png style_image_url image/fangao.png output_image_size 384# 调整内容图像的大小 content_img_size (output_image_size, output_image_size) # 样式图片大小 style_img_size (256, 256) # 加载图片 content_image load_image(content_image_url, content_img_size) style_image load_image(style_image_url, style_img_size) style_image tf.nn.avg_pool(style_image, ksize[3, 3], strides[1, 1], paddingSAME) # 展示图片 # show_n([content_image, style_image], [Content image, Style image])# 加载模型 hub_module hub.load(./magenta_arbitrary-image-stylization-v1-256_2) # 风格迁移 outputs hub_module(tf.constant(content_image), tf.constant(style_image)) stylized_image outputs[0] # 展示迁移后的图片 show_n([content_image, style_image, stylized_image], titles[Original content image, Style image, Stylized image])
http://www.dnsts.com.cn/news/76309.html

相关文章:

  • 小网站文案响应式 购物网站模板
  • 河源网站建设公司网站建设技术标准
  • 网站的色彩wordpress制作网页教程
  • 营销网站建设资料上海人才市场档案存放中心
  • 8上的信息课做网站作业网页制作素材免费网站
  • 个体工商户做的网站能推广吗互联网行业最新资讯
  • 自己做网站网页归档淮安网站建设找谁好
  • 制作网站需要钱吗网站开发文章怎么分类
  • 建站网站排行榜商丘至开网络科技有限公司
  • 公司业绩怎么发到建设厅网站上莱芜seo推广
  • 栾城seo整站排名网站开发投资成本
  • 网站设计案例欣赏呈贡网站建设
  • html5素材网站福州模板建站代理
  • 南昌网站搭建建设定制怎么模仿一个网站
  • 专业的培训行业网站开发wordpress网址访问慢
  • 个人网站备案资料网站全屏广告
  • 网站建设费属于宣传费企业网站搜索引擎推广方法包括
  • 网站正在建设 mp4潜江市网站
  • 青岛网站制作设计建设一个蛋糕网站的背景与目的
  • 剑三做月饼活动网站定制一款软件需要多少钱
  • 建设网络道德教育网站的有效措施网站开发工程师要求
  • 南宁专业网站营销怎么建网站 手机版
  • 网上有哪些接单做效果图的网站企业网站推广的方法有
  • 视频网站cms系统企业 办公 网站模板下载
  • 电商网站界面规范深圳 公司网站建设
  • 互联网网站工程施工合同协议书范本
  • 宠物网站建设论文总结简单商业网站模板
  • jsp网站建设项目wordpress 1g1核1m
  • 菏泽网站建设服务wordpress邮件功能
  • 关于做公司网站杭州营销策划推广公司