Coder Social home page Coder Social logo

请问余老师,我看源码,图片在送入网络前会转成27通道,我需要训练单通道的图片,应该怎么修改呢 about libfacedetection.train HOT 4 CLOSED

shiqiyu avatar shiqiyu commented on June 8, 2024
请问余老师,我看源码,图片在送入网络前会转成27通道,我需要训练单通道的图片,应该怎么修改呢

from libfacedetection.train.

Comments (4)

Wwupup avatar Wwupup commented on June 8, 2024

Hello, the 27 channels you mentioned are implemented in C++to facilitate the conversion of 3x3 convolution calculation to 1x1 convolution calculation. Not related to the training program. If you want to train single channel pictures, you can change the input channel of head from 3 to 1 of the conv_head.

from libfacedetection.train.

zaidao2023 avatar zaidao2023 commented on June 8, 2024

您好,您提到的 27 个通道都是在 C++ 中实现的,以促进 3x3 卷积计算到 1x1 卷积计算的转换。与培训计划无关。如果要训练单通道图片,可以将头部的输入通道从 3 个更改为 1 个。conv_head

如果训练单通道图像完成,怎么转换模型到cpp里面?需要改哪些参数么

from libfacedetection.train.

Wwupup avatar Wwupup commented on June 8, 2024

@zaidao2023 你好,以下代码是用于导出首层卷积的,如果修改为单通道图像输入可以尝试修改这部分:

if (isfirst3x3x3):
w = conv.weight.detach().numpy().reshape((-1,27))
_w = w.copy()
for idx in range(out_channels):
for offest in range(27):
w[idx, (offest % 9) * 3 + offest // 9] = _w[idx, offest]
w_zeros = np.zeros((out_channels, 5))
w = np.hstack((w, w_zeros))
w = w.reshape(-1)

同时,由于输入维度改变,还要修改C++首层实现:
https://github.com/ShiqiYu/libfacedetection/blob/26afabbfb8ae3e910112c77def258328a6975744/src/facedetectcnn.cpp#L82-L125

实际上,想应用单通道图像还有一种最简单的做法,即在预处理时将单通道图像[h, w, 1] repeat到[h, w, 3]适应本项目即可。

from libfacedetection.train.

zaidao2023 avatar zaidao2023 commented on June 8, 2024

@zaidao2023 你好,以下代码是用于导出首层卷积的,如果修改为单通道图像输入可以尝试修改这部分:

if (isfirst3x3x3):
w = conv.weight.detach().numpy().reshape((-1,27))
_w = w.copy()
for idx in range(out_channels):
for offest in range(27):
w[idx, (offest % 9) * 3 + offest // 9] = _w[idx, offest]
w_zeros = np.zeros((out_channels, 5))
w = np.hstack((w, w_zeros))
w = w.reshape(-1)

同时,由于输入维度改变,还要修改C++首层实现:
https://github.com/ShiqiYu/libfacedetection/blob/26afabbfb8ae3e910112c77def258328a6975744/src/facedetectcnn.cpp#L82-L125
实际上,想应用单通道图像还有一种最简单的做法,即在预处理时将单通道图像[h, w, 1] repeat到[h, w, 3]适应本项目即可。

谢谢答复

from libfacedetection.train.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.