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

芭乐站长统计 网站统计wordpress 源代码

芭乐站长统计 网站统计,wordpress 源代码,搜索引擎技巧,南京太阳宫网站建设一、什么是风格迁移#xff1f; 风格迁移#xff08;Style Transfer#xff09;是一种利用深度学习技术#xff0c;将一幅图像的内容与另一幅图像的艺术风格相结合#xff0c;生成新图像的技术。其核心思想是将图像的“内容”和“风格”分离#xff0c;再重新组合#…一、什么是风格迁移 风格迁移Style Transfer是一种利用深度学习技术将一幅图像的内容与另一幅图像的艺术风格相结合生成新图像的技术。其核心思想是将图像的“内容”和“风格”分离再重新组合创造出既有原始内容结构又具有新艺术风格的作品。 关键概念 内容Content 指图像的主体结构和细节例如照片中的人物、建筑或风景的轮廓、形状等。 风格Style 指图像的艺术特征如颜色分布、笔触纹理、光影效果等例如梵高的《星夜》中的漩涡笔触或莫奈的印象派色彩。 二、TensorFlow 的基本概念和使用场景 TensorFlow 是一个开源的深度学习框架由谷歌公司开发。它提供了丰富的工具和接口用于构建和训练人工神经网络模型。TensorFlow 的核心概念是张量tensors即多维数组用于表示数据。它的计算图computational graph机制可以将整个计算过程表示为数据流图便于优化和执行。 TensorFlow 的使用场景非常广泛涵盖了许多领域包括计算机视觉、自然语言处理、推荐系统等。一些常见的应用包括图像分类、目标检测、语音识别、机器翻译等。TensorFlow 提供了丰富的预训练模型和工具使得开发者可以快速搭建和训练复杂的深度学习模型。 总的来说TensorFlow 是一款功能强大的深度学习框架适用于各种复杂的机器学习任务可帮助开发者加快模型的开发和部署过程。 三、导入 TF2 和相关依赖项 import functools import osfrom matplotlib import gridspec import matplotlib.pylab as plt import numpy as np import tensorflow as tf import tensorflow_hub as hubprint(TF Version: , tf.__version__) print(TF Hub version: , hub.__version__) print(Eager mode enabled: , tf.executing_eagerly()) print(GPU available: , tf.config.list_physical_devices(GPU)) 输出如下  TF Version: 2.13.0 TF Hub version: 0.16.1 Eager mode enabled: True GPU available: [] 安装依赖可附上清华源仓库连接进行安装 # -i https://pypi.tuna.tsinghua.edu.cn/simple !pip3 install matplotlib !pip3 install tensorflow-hub # title Define image loading and visualization functions { display-mode: form }def crop_center(image):Returns a cropped square image.shape image.shapenew_shape min(shape[1], shape[2])offset_y max(shape[1] - shape[2], 0) // 2offset_x max(shape[2] - shape[1], 0) // 2image tf.image.crop_to_bounding_box(image, offset_y, offset_x, new_shape, new_shape)return image# functools.lru_cache(maxsizeNone) # def load_image(image_url, image_size(256, 256), preserve_aspect_ratioTrue): # Loads and preprocesses images. # # Cache image file locally. # image_path tf.keras.utils.get_file(os.path.basename(image_url)[-128:], image_url) # # Load and convert to float32 numpy array, add batch dimension, and normalize to range [0, 1]. # 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 imgfunctools.lru_cache(maxsizeNone) def load_image(image_path, image_size(256, 256), preserve_aspect_ratioTrue):print(floading image {image_path})Loads and preprocesses images.# Load and convert to float32 numpy array, add batch dimension, and normalize to range [0, 1].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 imgdef 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() 加载一些图像来看看效果 # title Load example images { display-mode: form }content_image_path data/input/thunderkun.jpg # param {type:string} style_image_path data/style/style28.jpg # param {type:string} output_image_size 384 # param {type:integer}# The content image size can be arbitrary. content_img_size (output_image_size, output_image_size) # The style prediction model was trained with image size 256 and its the # recommended image size for the style image (though, other sizes work as # well but will lead to different results). style_img_size (256, 256) # Recommended to keep it at 256.content_image load_image(content_image_path, content_img_size) style_image load_image(style_image_path, 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]) loading image data/input/thunderkun.jpg loading image data/style/style28.jpg 输出如下  四、导入 TF Hub 模块 # Load TF Hub module. hub_handle https://tfhub.dev/google/magenta/arbitrary-image-stylization-v1-256/2 hub_module hub.load(hub_handle) 该 Hub 模块用于图像风格化的签名为 outputs hub_module(content_image, style_image) stylized_image outputs[0] 其中content_image、style_image 和 stylized_image 预期是形状为 [batch_size, image_height, image_width, 3] 的四维张量。 在当前示例中我们仅提供单个图像因此批次维度为 1但是我们也可以使用同一模块同时处理更多图像。 图像的输入和输出值应在 [0, 1] 范围内。 内容与风格图像的形状不一定要匹配。输出图像形状与内容图像形状相同。 五、演示图像风格化 # Stylize content image with given style image. # This is pretty fast within a few milliseconds on a GPU. outputs hub_module(tf.constant(content_image), tf.constant(style_image)) stylized_image outputs[0] # Visualize input images and the generated stylized image. show_n([content_image, style_image, stylized_image], titles[Original content image, Style image, Stylized image]) 参考资料 任意风格的快速风格转换  |  TensorFlow Hub
http://www.w-s-a.com/news/896727/

相关文章:

  • 注册域名后网站建设百度指数的功能
  • 怎么做伪静态网站山西网站建设设计
  • 做小型企业网站多少钱衡阳市建设局网站
  • 金华专业网站建设公司网站建设空间和服务器方式
  • 自己做的网站在浏览器上显示不安全吗wordpress revolution slider
  • 西安网站建设推广优化搜索引擎营销
  • 互联网站备案管理工作方案 工信部注册深圳公司需要什么条件
  • 网站网站服务器网站建设 物流
  • 国外开发网站手机网站建设制作
  • 怎么把自己做的网站传网上青岛工程建设监理公司网站
  • 网站301跳转效果商丘网站公司
  • 公司网站建设西安网站的架构与建设
  • 食品科技学校网站模板花溪村镇建设银行网站
  • 图片渐隐 网站头部flash地方志网站建设自查报告
  • 深圳做商城网站视觉品牌网站建设
  • 永康电子商务网站建设弹幕网站怎么做
  • 百川网站企业做网站要注意哪些
  • 球迷类的网站如何做网站建设需要哪些素材
  • 请问有重庆有做网站吗电子政务系统网站建设的基本过程
  • 建设银行管方网站官网最新版cmsv6
  • 网站开发工程师需要会写什么深圳网站(建设信科网络)
  • 台州网站搭建网站建设需求计划
  • 网站app免费下载软件大全大连百度推广哪家好
  • 网站建设的面试要求iis做的网站手机怎么访问
  • 定州市住房保障和城乡建设局网站上海网站建设排行
  • 网站发帖百度收录网站改版后不收录
  • 昆明建设局网站号码网站开发 浏览器兼容性
  • 湖北专业网站建设大全室内设计联盟app下载
  • 网站建设的意义和作用江苏城市建设档案馆网站
  • 华为云速建站贴心的广州网站建设