You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
61 lines
1.7 KiB
61 lines
1.7 KiB
#include "cropLayer.h"
|
|
|
|
#define LOG( X ) m_pLog->Log( "CropL", this, X )
|
|
#define LOG_ERROR( X ) m_pLog->Log( "CropL", this, _LOG_ERROR, X )
|
|
|
|
cropLayer::cropLayer(bool useGPU) :cortexLayer(CROP, useGPU){
|
|
m_fScale = 1.f;
|
|
m_bFlipped = false;
|
|
m_fAngle = 0.f;
|
|
m_fSaturation = 1.f;
|
|
m_fExposure = 1.f;
|
|
m_pGpuRand = NULL;
|
|
};
|
|
|
|
cropLayer::~cropLayer(){
|
|
if (m_pGpuRand != NULL) m_pPU->freeMem(m_pGpuRand);
|
|
};
|
|
|
|
bool cropLayer::create(uint32_t batch, uint32_t h, uint32_t w, uint32_t c, uint32_t crop_height, uint32_t crop_width, bool flip, float angle, float saturation, float exposure){
|
|
char tBuff[256];
|
|
sprintf(tBuff, "Crop Layer: %d x %d -> %d x %d x %d image\n", h, w, crop_height, crop_width, c);
|
|
LOG(tBuff);
|
|
|
|
m_nBatch = batch;
|
|
m_nIn_Height = h;
|
|
m_nIn_Width = w;
|
|
m_nIn_Channels = c;
|
|
m_fScale = (float)crop_height / h;
|
|
m_bFlipped = flip;
|
|
m_fAngle = angle;
|
|
m_fSaturation = saturation;
|
|
m_fExposure = exposure;
|
|
m_nOut_Width = crop_width;
|
|
m_nOut_Height = crop_height;
|
|
m_nOut_Channels = c;
|
|
m_nInput = m_nIn_Width * m_nIn_Height * m_nIn_Channels;
|
|
m_nOutput = m_nOut_Width * m_nOut_Height * m_nOut_Channels;
|
|
m_nOutputVol = m_nOutput * m_nBatch;
|
|
m_pOutput = (float*)calloc(m_nOutputVol, sizeof(float));
|
|
if (m_pOutput == NULL)return false;
|
|
#ifdef GPU
|
|
if (m_bUseGPU){
|
|
m_pGpuOutput = m_pPU->makeFloatArray(m_nOutputVol);
|
|
if (m_pGpuOutput = NULL){
|
|
free(m_pOutput); m_pOutput = NULL;
|
|
return false;
|
|
};
|
|
m_pGpuRand = m_pPU->makeFloatArray(m_nBatch*8);
|
|
if (m_pGpuRand = NULL){
|
|
free(m_pOutput); m_pOutput = NULL;
|
|
m_pPU->freeMem(m_pGpuOutput); m_pGpuOutput = NULL;
|
|
return false;
|
|
};
|
|
};
|
|
#endif
|
|
return true;
|
|
};
|
|
|
|
|
|
#undef LOG
|
|
#undef LOG_ERROR
|