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

自动全屏网站模板html好看的个人主页

自动全屏网站模板,html好看的个人主页,博客型网站建设,帝国网站整站迁移准备 官方教程#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://wiki.neutronadmin.com/news/310903/

相关文章:

  • 移动网站优化排名网页设计与制作教程第五版课后答案
  • 怎么做简单的网站首页搭建影视网站违法
  • 有色建设网站网站做的和别人一样违法
  • 网站建设怎么找到客户wordpress注册未发邮件
  • 泉州微信网站建设公司电子商务网站详细设计
  • 做网站前需要准备什么条件官方网站让第三方建设放心吗
  • 嘉兴做网站赚钱么做毕业设计网站的问题与展望
  • 西安专业做网站网站版面结构
  • 做调差问卷的网站建设网站要钱吗
  • 做网站一定要虚拟主机吗大学新校区建设网站
  • wordpress腾讯云插件seo从入门到精通
  • 国内做网站哪个好wordpress 运行卡
  • 做三国mod的网站广州百度网站快速排名
  • 郑州网站优化推广方案wordpress批量导入页面
  • 新公司做网站多少钱主流的网站建设的软件有哪些
  • 现在由哪些网站可以做外链如何写网站优化目标
  • 网站空间1g多少钱seo专员是干嘛的
  • 什么网站可以做ppt模板哪家云服务器性价比高
  • 企业网站推广方案网络营销作业wordpress增加页面分类
  • 中国山东网站建设wordpress死链接提交
  • 枣庄市建设局网站华为荣耀商城官网
  • 建设新农村网站自己做网站地址
  • 哪个网站可以做危险化学品供求世界排名前十位
  • 最新国际新闻事件今天做网站优化
  • 找做网站的人网站没备案怎么做广告联盟
  • 石家庄定制网站建设多少钱怎么设置wordpress底栏文字
  • 青岛网站排名哪家公司好计算机哪个专业最吃香女生
  • 顺德做网站推广哪家好免费注册网址
  • 女人与马做受网站化妆品备案查询网站
  • 可以专做福特配件吗外贸网站wordpress做分类网站