[开源]ACG2vec 系列之 CUGAN_TF——运行在浏览器上的动漫超分工具(Real-CUGAN 的 tensorflow 实现)

查看 59|回复 2
作者:OysterQAQ   
介绍

在线预览(目前包含文本搜索、以图搜图、文本搜图、图片分数预测):https://cheerfun.dev/acg2vec/
开源仓库:https://github.com/OysterQAQ/ACG2vec
演示页前端开源仓库:https://github.com/wewewe131/acg2vec-frontend
以上两个仓库求个 star QAQ🌟🌟🌟

当前最优秀的动漫领域超分模型之一Real-CUGAN的 tensorflow 实现,依赖tfjs框架完成自适应后端的能运行在浏览器上的动漫超分工具。
原版实现分为切块后超分与整图超分,两种都以实现,但切块超分版本转为 tfjs 模型后在网页运行不正常,已向tfjs仓库提交issue。目前预览版本是整图超分版本,由于内存限制,限制了原始图片大小( 512x512 以内),后续 issue 解决将发布切块超分,大概率将不会有限制。
This module is an implementation of one of the current leading anime super-resolution models in the field, Real-CUGAN, using TensorFlow. It relies on the tfjs framework to create an adaptive backend, enabling it to run as an anime super-resolution tool in web browsers.
The original implementation offers two versions: chunk-based super-resolution and full-image super-resolution, both of which have been implemented. However, the chunk-based super-resolution version encounters issues when converted into a tfjs model and run in a web browser. An issue has been raised in the tfjs repository to address this problem.
The current preview version focuses on full-image super-resolution but has limitations on the original image size (up to 512x512) due to memory constraints. Once the issue is resolved, the chunk-based super-resolution version is likely to be released without such limitations.
预览

效果
输入

无降噪输出

保守输出

降噪输出

pytorch 模型迁移到 tensorflow 应该注意的点

  • 图片处理默认维度顺序: tensorflow 为 nhwc ,pytorch 为 nchw ,卷积权重维度顺序也不相同

  • tensorflow 转置卷积无法自定义 padding: Conv2DTranspose 层 padding 设为 0 ,后续使用 slice 手动 crop 输出

  • tf.pad 无法接受负数:使用 tf.slice 作为替代

  • 多尺寸输入导致无法 batch:无解

  • 延迟设置输入尺寸运行时获取 size:这是 tensorflow 图模型的限制

  • python 操作逻辑最好翻译为 tensorflow 分支选择 api

  • TensorArray:TensorArray 是图模式中 python list 替代品,TensorArray 在 eager 模式 TensorArray.write(i, x)可以直接生效,而在 graph 模式时需要将引用赋值给自身

    TensorFlow, the, tfjs, real-cugan

  • subframe75361   
    想 star 发现已经点过了😂
    OysterQAQ
    OP
      
    @subframe75361 🤩感谢
    您需要登录后才可以回帖 登录 | 立即注册

    返回顶部