Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

[WIP]]Vision #8649

Merged
merged 9 commits into from
Nov 14, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix lint
  • Loading branch information
yajiedesign committed Nov 13, 2017
commit 6089084f424cf40fa94e5ce47996ccfe0462c25e
2 changes: 0 additions & 2 deletions python/mxnet/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -420,8 +420,6 @@ def _init_op_module(root_namespace, module_name, make_op_func):
hdl = OpHandle()
check_call(_LIB.NNGetOpHandle(c_str(name), ctypes.byref(hdl)))
op_name_prefix = _get_op_name_prefix(name)
if op_name_prefix == "_image_":
print(1)
module_name_local = module_name
if len(op_name_prefix) > 0:
func_name = name[len(op_name_prefix):]
Expand Down
103 changes: 48 additions & 55 deletions src/operator/image/random_brightness-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,10 @@
#ifndef MXNET_OPERATOR_IMAGE_RANDOM_BRIGHTNESS_INL_H_
#define MXNET_OPERATOR_IMAGE_RANDOM_BRIGHTNESS_INL_H_

#include <vector>
#include <mxnet/base.h>
#include "mxnet/op_attr_types.h"
#include <opencv2/core/mat.hpp>
#include "mxnet/op_attr_types.h"

namespace mxnet {
namespace op {
Expand All @@ -42,70 +43,62 @@ namespace op {


template<typename xpu>
static void RandomBrightness(const nnvm::NodeAttrs& attrs,
const OpContext& ctx,
const std::vector<TBlob>& inputs,
const std::vector<OpReqType>& req,
const std::vector<TBlob>& outputs) {
static void RandomBrightness(const nnvm::NodeAttrs &attrs,
const OpContext &ctx,
const std::vector<TBlob> &inputs,
const std::vector<OpReqType> &req,
const std::vector<TBlob> &outputs) {
auto input = inputs[0];
cv::Mat m;

int hight = input.shape_[0];
int weight = input.shape_[1];
int channel = input.shape_[2];
switch (input.type_flag_)
{
case mshadow::kFloat32:
{
typedef float DType;
m = cv::Mat(hight, weight, CV_MAKETYPE(CV_32F, channel), input.dptr<DType>());
}
break;
case mshadow::kFloat64:
{
typedef double DType;
m = cv::Mat(hight, weight, CV_MAKETYPE(CV_64F, channel), input.dptr<DType>());
}
break;
case mshadow::kFloat16:
{
typedef mshadow::half::half_t DType;
switch (input.type_flag_) {
case mshadow::kFloat32: {
typedef float DType;
m = cv::Mat(hight, weight, CV_MAKETYPE(CV_32F, channel), input.dptr<DType>());
}
break;
case mshadow::kFloat64: {
typedef double DType;
m = cv::Mat(hight, weight, CV_MAKETYPE(CV_64F, channel), input.dptr<DType>());
}
break;
case mshadow::kFloat16: {
typedef mshadow::half::half_t DType;

}
break;
case mshadow::kUint8: {
typedef uint8_t DType;
m = cv::Mat(hight, weight, CV_MAKETYPE(CV_8U, channel), input.dptr<DType>());
}
break;
case mshadow::kInt8: {
typedef int8_t DType;
m = cv::Mat(hight, weight, CV_MAKETYPE(CV_8S, channel), input.dptr<DType>());
}
break;
case mshadow::kInt32: {
typedef int32_t DType;
m = cv::Mat(hight, weight, CV_MAKETYPE(CV_32S, channel), input.dptr<DType>());
}
break;
case mshadow::kInt64: {
typedef int64_t DType;
}
break;
default:
LOG(FATAL) << "Unknown type enum " << input.type_flag_;

}
break;
case mshadow::kUint8:
{
typedef uint8_t DType;
m = cv::Mat(hight, weight, CV_MAKETYPE(CV_8U, channel), input.dptr<DType>());
}
break;
case mshadow::kInt8:
{
typedef int8_t DType;
m = cv::Mat(hight, weight, CV_MAKETYPE(CV_8S, channel), input.dptr<DType>());
}
break;
case mshadow::kInt32:
{
typedef int32_t DType;
m = cv::Mat(hight, weight, CV_MAKETYPE(CV_32S, channel), input.dptr<DType>());
}
break;
case mshadow::kInt64:
{
typedef int64_t DType;
}
break;
default:
LOG(FATAL) << "Unknown type enum " << input.type_flag_;

}
std::default_random_engine generator;
const RandomBrightnessParam& param = nnvm::get<RandomBrightnessParam>(attrs.parsed);
const RandomBrightnessParam &param = nnvm::get<RandomBrightnessParam>(attrs.parsed);
float alpha_b = 1.0 + std::uniform_real_distribution<float>(-param.max_brightness, param.max_brightness)(generator);
m.convertTo(m, -1, alpha_b, 0);
}
}
}
} // namespace op
} // namespace mxnet

#endif
#endif // MXNET_OPERATOR_IMAGE_RANDOM_BRIGHTNESS_INL_H_