Webpack build file size is big also production mode not work - webpack-4

Whole problem is whne i set mode to development in webPack config !
Log looks like this:
imgs/screen.png 231 bytes [emitted]
imgs/floor.png 1.74 KiB [emitted]
imgs/wallStock.jpg 77.1 KiB [emitted]
imgs/android-icon.png 16.4 KiB [emitted]
imgs/favicon-96x96.png 7.06 KiB [emitted]
/styles/favicon.ico 1.12 KiB [emitted]
imgs/gcheckmark.png 768 bytes [emitted]
imgs/microphone.png 545 bytes [emitted]
imgs/target.png 25.4 KiB [emitted]
imgs/share-files.png 774 bytes [emitted]
imgs/warning.png 1.3 KiB [emitted]
imgs/webcam.png 398 bytes [emitted]
visualjs2.js 1.84 MiB main [emitted] main
app.html 2.52 KiB [emitted]
/templates/register.html 1.1 KiB [emitted]
/templates/login.html 1.06 KiB [emitted]
[./node_modules/css-loader/index.js!./src/style/styles.css] ./node_modules/css-loader!./src/style/styles.css 9.28 KiB {main} [built]
[./src/app-icon.ts] 641 bytes {main} [built]
[./src/app.ts] 524 bytes {main} [built]
[./src/examples/platformer/platformer.ts] 839 bytes {main} [built]
[./src/examples/platformer/scripts/level1/level1.ts] 5.69 KiB {main} [built]
[./src/icon/permission/webcam.png] 61 bytes {main} [built]
[./src/libs/class/browser.ts] 5.02 KiB {main} [built]
[./src/libs/class/networking/network.ts] 24.9 KiB {main} [built]
[./src/libs/class/view-port.ts] 2.32 KiB {main} [built]
[./src/libs/class/visual-render.ts] 4.15 KiB {main} [built]
[./src/libs/client-config.ts] 2.15 KiB {main} [built]
[./src/libs/ioc.ts] 1.37 KiB {main} [built]
[./src/libs/multiplatform/global-event.ts] 1.48 KiB {main} [built]
[./src/libs/starter.ts] 4.71 KiB {main} [built]
[./src/style/styles.css] 1.06 KiB {main} [built]
Webpack config :
const CleanWebpackPlugin = require('clean-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const ExtractTextPlugin = require("extract-text-webpack-plugin");
const TypedocWebpackPlugin = require('typedoc-webpack-plugin');
module.exports = {
mode: "development",
watch: true,
entry: "./src/app.ts",
output: {
filename: "visualjs2.js",
path: __dirname + "/build"
},
devtool: "inline-source-map",
resolve: {
extensions: [".js", ".ts", ".tsx", ".json"]
},
module: {
rules: [
{ test: /\.tsx?$/, loader: "ts-loader" },
{
test: /\.(jpg|png)$/, loader: "file-loader", options: {
name: '[name].[ext]',
outputPath: "./imgs"
}
},
{ test: /\.css$/, loader: "style-loader!css-loader" },
{
test: /\.(ico)$/,
use: {
loader: 'file-loader',
options: {
name: '[name].[ext]',
outputPath: '/styles'
}
}
},
// All output '.js' files will have any sourcemaps re-processed by 'source-map-loader'.
{ enforce: "pre", test: /\.js$/, loader: "source-map-loader" }
]
},
plugins: [
// Make sure that the plugin is after any plugins that add images
new CleanWebpackPlugin(['build'], { /*exclude: ['index.html']*/ }),
new HtmlWebpackPlugin({
filename: 'app.html',
template: 'src/index.html'
}),
new HtmlWebpackPlugin({
filename: '/templates/register.html',
template: 'src/html-components/register.html'
}),
new HtmlWebpackPlugin({
filename: '/templates/login.html',
template: 'src/html-components/login.html'
}),
new ExtractTextPlugin("styles.css")
],
/*
new TypedocWebpackPlugin({
out: './api-doc',
module: 'amd',
target: 'es5',
exclude: '** /node_modules / ** / *.* ',
experimentalDecorators: true,
excludeExternals: true,
name: 'sn-theme',
mode: 'file',
theme: './sn-theme/',
includeDeclarations: false,
ignoreCompilerErrors: true,
})
*/
optimization: {
splitChunks: {
chunks: 'async',
minSize: 30000,
maxSize: 0,
minChunks: 2,
maxAsyncRequests: 5,
maxInitialRequests: 3,
automaticNameDelimiter: '~',
name: true,
cacheGroups: {
vendors: {
test: /[\\/]node_modules[\\/]/,
priority: -10
},
default: {
minChunks: 2,
priority: -20,
reuseExistingChunk: true
}
}
}
}
};
Optimisation work's.Any way only tsconfig.json-> mode : "commonjs" works.
Why visualjs2.js 1.84 MiB main file is so big !
Any suggestion?
mode : production results :
WARNING in asset size limit: The following asset(s) exceed the
recommended size limit (244 KiB). This can impact web performance.
Assets: visualjs2.js (1.52 MiB)
WARNING in entrypoint size limit: The following entrypoint(s) combined
asset size exceeds the recommended limit (244 KiB). This can impact
web performance. Entrypoints: main (1.52 MiB)
visualjs2.js
WARNING in webpack performance recommendations: You can limit the size
of your bundles by using import() or require.ensure to lazy load some
parts of your application. For more info visit
https://webpack.js.org/guides/code-splitting/
Error after setup webpack.config mode: "production"
(not important to much, for this problem is on webpack area):
visualjs2.js:1 Uncaught TypeError: Cannot read property 'getWidth' of
undefined
at new e (visualjs2.js:1)
at e.singlton (visualjs2.js:1)
at new e (visualjs2.js:1)
at Object. (visualjs2.js:1)
at Object. (visualjs2.js:1)
at n (visualjs2.js:1)
at visualjs2.js:1
at visualjs2.js:1
This is my package (dependency) :
"dependencies": {
"#types/matter-js": "^0.10.2",
"express": "^4.16.4",
"matter-attractors": "^0.1.6",
"matter-js": "^0.14.1",
"npm": "^5.8.0",
"tsconfig": "^7.0.0",
"tslint": "^5.9.1",
"websocket": "^1.0.28"
},
"devDependencies": {
"clean-webpack-plugin": "^0.1.19",
"css-loader": "^0.28.11",
"extract-text-webpack-plugin": "^4.0.0-beta.0",
"file-loader": "^1.1.11",
"html-webpack-plugin": "^3.2.0",
"source-map-loader": "^0.2.3",
"style-loader": "^0.21.0",
"ts-loader": "^4.4.2",
"typedoc": "^0.13.0",
"typedoc-webpack-plugin": "^1.1.4",
"typescript": "^2.9.2",
"webpack": "^4.25.1",
"webpack-cli": "^3.1.2"
},

Related

webpack4 mini-css-extract-plugin with bourbon

I have my scss file which imports a scss file which further imports bourbon and bourbon-neat. I even searched various issues on the forum but did not find the issue where in the scsss to css conversion, the case is to include bourbon.
webpack 4.28.1
mini-css-extract-plugin 0.5.0
I am seeing the following error:
Child mini-css-extract-plugin node_modules/css-loader/dist/cjs.js!node_modules/sass-loader/lib/loader.js??ref--5-2!src/component/styles/main.scss:enter code here
Entrypoint mini-css-extract-plugin = *
[./node_modules/css-loader/dist/cjs.js!./node_modules/sass-loader/lib/loader.js?!./src/component/styles/main.scss] ./node_modules/css-loader/dist/cjs.js!./node_modules/sass-loader/lib/loader.js??ref--5-2!./src/component/styles/main.scss 373 bytes {mini-css-extract-plugin} [built] [failed] [1 error]
ERROR in ./src/component/styles/main.scss (./node_modules/css-loader/dist/cjs.js!./node_modules/sass-loader/lib/loader.js??ref--5-2!./src/component/styles/main.scss)
Module build failed (from ./node_modules/sass-loader/lib/loader.js):
var path = require('path');
^
Invalid CSS after "v": expected 1 selector or at-rule, was "var path = require("
in /Users/../node_modules/bourbon/index.js (line 1, column 1)
My webpack.config.js file is here
const path = require('path');
const UglifyJSPlugin = require('uglifyjs-webpack-plugin');
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const OptimizeCSSAssetsPlugin = require("optimize-css-assets-webpack-plugin");
module.exports = {
entry: {
"app": ['whatwg-fetch',"./src/component/index.ts", "./src/component/styles/main.scss"],
"app-helper": "./src/component/helpers.ts"
},
output: {
path: path.resolve(__dirname, './src/component/dist'),
filename: "[name].bundle.js"
},
module: {
rules: [
{
test: /\.tsx?$/,
use: 'ts-loader',
exclude: /node_modules/
},
test: /\.(sa|sc|c)ss$/,
use: [
MiniCssExtractPlugin.loader,
'css-loader',
{
loader: "sass-loader",// compiles Sass to CSS
options: {
includePaths: [
'node_modules/bourbon/app/assets/stylesheets',
'node_modules/bourbon-neat/app/assets/stylesheets'
]
}
}
],
]
},
plugins: [
new MiniCssExtractPlugin({
filename: './src/component/dist/output-style.css',
})
],
optimization: {
minimizer:[
new UglifyJSPlugin({
cache: true,
parallel: true,
sourceMap: true // set to true if you want JS source maps
}),
new OptimizeCSSAssetsPlugin({})
]
}
}
Please provide your valuable suggestions.
This turns out to be an issue with sass-loader version 7.x . I changed sass-loader dependency back to 6.0.7 and it started working like charm. Here is the stackoverflow thread which helped
Angular 2 Node Bourbon Error

Uncaught Syntax Error when running Vue.Js Unit Tests with Karma

I'm trying to get unit testing set up for my Vue JS project with Karma and Mocha (with vue-cli, I originally used Jest but I'm switching to Karma). I try to run my test with karma start; karma run and I keep getting:
09 03 2018 17:02:49.778:INFO [karma]: Karma v2.0.0 server started at http://0.0.0.0:9876/
09 03 2018 17:02:49.786:INFO [launcher]: Launching browser Chrome with unlimited concurrency
09 03 2018 17:02:49.797:INFO [launcher]: Starting browser Chrome
09 03 2018 17:02:54.410:INFO [Chrome 64.0.3282 (Windows 10.0.0)]: Connected on socket mvbOII8qli3NiwBMAAAA with id 62867001
Chrome 64.0.3282 (Windows 10.0.0) ERROR
{
"message": "Uncaught SyntaxError: Unexpected identifier\nat specs/PdfView.spec.js:3:8\n\nSyntaxError: Unexpected identifier",
"str": "Uncaught SyntaxError: Unexpected identifier\nat specs/PdfView.spec.js:3:8\n\nSyntaxError: Unexpected identifier"
}
The test runner starts, but I'm guessing some config issue is preventing the test from running properly. Also, it's not this just one component that will give me those errors.
My karma.conf.js file:
var webpackConfig = require('../../build/webpack.test.conf')
module.exports = function karmaConfig (config) {
config.set({
browsers: ['Chrome'],
frameworks: ['mocha'],
reporters: ['spec', 'coverage'],
files: ['specs/**/*.spec.js'],
preprocessors: {
'test/unit/spec/**/*.spec.js': [ 'webpack', 'sourcemap' ]
},
plugins: [
// Launchers
'karma-chrome-launcher',
// Test Libraries
'karma-mocha',
// 'karma-sinon-chai',
// Preprocessors
'karma-webpack',
'karma-sourcemap-loader',
// Reporters
'karma-spec-reporter',
'karma-coverage'
],
webpack: webpackConfig,
webpackMiddleware: {
noInfo: true
},
singleRun: true,
coverageReporter: {
dir: './coverage',
reporters: [
{ type: 'lcov', subdir: '.' },
{ type: 'text-summary' }
]
}
})
}
My .babelrc file:
{
"presets": [
["env", {
"modules": false,
"targets": {
"browsers": ["> 1%", "last 2 versions", "not ie <= 8"]
}
}],
"stage-2"
],
"plugins": ["transform-vue-jsx", "transform-runtime"],
"env": {
"test": {
"presets": ["env", "stage-2"],
"plugins": ["transform-vue-jsx", "transform-es2015-modules-commonjs", "dynamic-import-node"]
}
}
}
My webpack.test.conf.js:
'use strict'
const utils = require('./utils')
const webpack = require('webpack')
const merge = require('webpack-merge')
const baseWebpackConfig = require('./webpack.base.conf')
const webpackConfig = merge(baseWebpackConfig, {
// use inline sourcemap for karma-sourcemap-loader
module: {
rules: utils.styleLoaders(),
loaders: [
{
test: /\.js$/,
loader: 'babel-loader',
exclude: /node_modules/
},
{
test: /\.vue$/,
loader: 'vue-loader'
}
]
},
devtool: '#inline-source-map',
resolveLoader: {
alias: {
// necessary to to make lang="scss" work in test when using vue-loader's ?inject option
// see discussion at https://github.com/vuejs/vue-loader/issues/724
'scss-loader': 'sass-loader'
}
},
plugins: [
new webpack.DefinePlugin({
'process.env': require('../config/test.env')
})
]
})
delete webpackConfig.entry
module.exports = webpackConfig
PdfView.spec.js
import Vue from 'vue';
import Test from '#/components/Submission/PdfView';
describe('Test', () => {
it(`should render`, () => {
const Constructor = Vue.extend(Test);
const comp = new Constructor({}).$mount();
expect(comp.$el.textContent)
.to.equal('Test Text');
});
});
Webpack ^3.6.0,
Karma ^2.0.0,
Vue ^2.5.2
It looks to me like the # in import Test from '#/components/Submission/PdfView'; is not being resolved. Try adding this to your webpack.test.conf.js:
resolve: {
alias: {
'#': resolve('src')
}
}

I add a new layer in caffe and there is an error about "layer_param_"

I'm new to Caffe and I want ot make a test about deconvolution. I add two new layers(unpooling layer and BN layer).
There is an error during test and this is information of error:
F0715 16:53:43.956820 5838 unpooling_layer.cpp:29] Check failed: !unpool_param.has_kernel_size() != !(unpool_param.has_kernel_h() && unpool_param.has_kernel_w()) Filter size is kernel_size OR kernel_h and kernel_w; not both
* Check failure stack trace: *
Aborted (core dumped)
This is the whole script:
I0715 16:53:43.953850 5838 upgrade_proto.cpp:53] Attempting to upgrade input file specified using deprecated V1LayerParameter: deconv.prototxt
I0715 16:53:43.954031 5838 upgrade_proto.cpp:61] Successfully upgraded file specified using deprecated V1LayerParameter
I0715 16:53:43.954062 5838 upgrade_proto.cpp:67] Attempting to upgrade input file specified using deprecated input fields: deconv.prototxt
I0715 16:53:43.954092 5838 upgrade_proto.cpp:70] Successfully upgraded file specified using deprecated input fields.
W0715 16:53:43.954098 5838 upgrade_proto.cpp:72] Note that future Caffe releases will only support input layers and not input fields.
I0715 16:53:43.954301 5838 net.cpp:51] Initializing net from parameters:
name: "Deconv_test"
state {
phase: TEST
level: 0
}
layer {
name: "input"
type: "Input"
top: "data"
input_param {
shape {
dim: 1
dim: 3
dim: 224
dim: 224
}
}
}
layer {
name: "conv1_1"
type: "Convolution"
bottom: "data"
top: "conv1_1"
param {
lr_mult: 1
decay_mult: 1
}
param {
lr_mult: 2
decay_mult: 0
}
convolution_param {
num_output: 64
pad: 1
kernel_size: 3
}
}
layer {
name: "bn1_1"
type: "BN"
bottom: "conv1_1"
top: "conv1_1"
}
layer {
name: "relu1_1"
type: "ReLU"
bottom: "conv1_1"
top: "conv1_1"
}
layer {
name: "conv1_2"
type: "Convolution"
bottom: "conv1_1"
top: "conv1_2"
param {
lr_mult: 1
decay_mult: 1
}
param {
lr_mult: 2
decay_mult: 0
}
convolution_param {
num_output: 64
pad: 1
kernel_size: 3
}
}
layer {
name: "bn1_2"
type: "BN"
bottom: "conv1_2"
top: "conv1_2"
}
layer {
name: "relu1_2"
type: "ReLU"
bottom: "conv1_2"
top: "conv1_2"
}
layer {
name: "pool1"
type: "Pooling"
bottom: "conv1_2"
top: "pool1"
top: "pool1_mask"
pooling_param {
pool: MAX
kernel_size: 2
stride: 2
}
}
layer {
name: "unpool1"
type: "Unpooling"
bottom: "pool1"
bottom: "pool1_mask"
top: "unpool1"
}
layer {
name: "deconv1_1"
type: "Deconvolution"
bottom: "unpool1"
top: "deconv1_1"
param {
lr_mult: 1
decay_mult: 1
}
param {
lr_mult: 2
decay_mult: 0
}
convolution_param {
num_output: 64
pad: 1
kernel_size: 3
weight_filler {
type: "gaussian"
std: 0.01
}
bias_filler {
type: "constant"
value: 0
}
}
}
layer {
name: "debn1_1"
type: "BN"
bottom: "deconv1_1"
top: "deconv1_1"
}
layer {
name: "derelu1_1"
type: "ReLU"
bottom: "deconv1_1"
top: "deconv1_1"
}
layer {
name: "deconv1_2"
type: "Deconvolution"
bottom: "deconv1_1"
top: "deconv1_2"
param {
lr_mult: 1
decay_mult: 1
}
param {
lr_mult: 2
decay_mult: 0
}
convolution_param {
num_output: 64
pad: 1
kernel_size: 3
weight_filler {
type: "gaussian"
std: 0.01
}
bias_filler {
type: "constant"
value: 0
}
}
}
layer {
name: "debn1_2"
type: "BN"
bottom: "deconv1_2"
top: "deconv1_2"
}
layer {
name: "derelu1_2"
type: "ReLU"
bottom: "deconv1_2"
top: "deconv1_2"
}
layer {
name: "seg-score-voc"
type: "Convolution"
bottom: "deconv1_2"
top: "seg-score"
param {
lr_mult: 1
decay_mult: 1
}
param {
lr_mult: 2
decay_mult: 0
}
convolution_param {
num_output: 21
kernel_size: 1
weight_filler {
type: "gaussian"
std: 0.01
}
bias_filler {
type: "constant"
value: 0
}
}
}
I0715 16:53:43.954690 5838 layer_factory.hpp:77] Creating layer input
I0715 16:53:43.954740 5838 net.cpp:84] Creating Layer input
I0715 16:53:43.954752 5838 net.cpp:380] input -> data
I0715 16:53:43.954807 5838 net.cpp:122] Setting up input
I0715 16:53:43.954823 5838 net.cpp:129] Top shape: 1 3 224 224 (150528)
I0715 16:53:43.954828 5838 net.cpp:137] Memory required for data: 602112
I0715 16:53:43.954839 5838 layer_factory.hpp:77] Creating layer conv1_1
I0715 16:53:43.954865 5838 net.cpp:84] Creating Layer conv1_1
I0715 16:53:43.954876 5838 net.cpp:406] conv1_1 <- data
I0715 16:53:43.954898 5838 net.cpp:380] conv1_1 -> conv1_1
I0715 16:53:43.955159 5838 net.cpp:122] Setting up conv1_1
I0715 16:53:43.955174 5838 net.cpp:129] Top shape: 1 64 224 224 (3211264)
I0715 16:53:43.955179 5838 net.cpp:137] Memory required for data: 13447168
I0715 16:53:43.955215 5838 layer_factory.hpp:77] Creating layer bn1_1
I0715 16:53:43.955237 5838 net.cpp:84] Creating Layer bn1_1
I0715 16:53:43.955246 5838 net.cpp:406] bn1_1 <- conv1_1
I0715 16:53:43.955265 5838 net.cpp:367] bn1_1 -> conv1_1 (in-place)
I0715 16:53:43.955569 5838 net.cpp:122] Setting up bn1_1
I0715 16:53:43.955579 5838 net.cpp:129] Top shape: 1 64 224 224 (3211264)
I0715 16:53:43.955585 5838 net.cpp:137] Memory required for data: 26292224
I0715 16:53:43.955611 5838 layer_factory.hpp:77] Creating layer relu1_1
I0715 16:53:43.955628 5838 net.cpp:84] Creating Layer relu1_1
I0715 16:53:43.955649 5838 net.cpp:406] relu1_1 <- conv1_1
I0715 16:53:43.955665 5838 net.cpp:367] relu1_1 -> conv1_1 (in-place)
I0715 16:53:43.955680 5838 net.cpp:122] Setting up relu1_1
I0715 16:53:43.955688 5838 net.cpp:129] Top shape: 1 64 224 224 (3211264)
I0715 16:53:43.955693 5838 net.cpp:137] Memory required for data: 39137280
I0715 16:53:43.955699 5838 layer_factory.hpp:77] Creating layer conv1_2
I0715 16:53:43.955723 5838 net.cpp:84] Creating Layer conv1_2
I0715 16:53:43.955730 5838 net.cpp:406] conv1_2 <- conv1_1
I0715 16:53:43.955749 5838 net.cpp:380] conv1_2 -> conv1_2
I0715 16:53:43.956133 5838 net.cpp:122] Setting up conv1_2
I0715 16:53:43.956148 5838 net.cpp:129] Top shape: 1 64 224 224 (3211264)
I0715 16:53:43.956153 5838 net.cpp:137] Memory required for data: 51982336
I0715 16:53:43.956182 5838 layer_factory.hpp:77] Creating layer bn1_2
I0715 16:53:43.956198 5838 net.cpp:84] Creating Layer bn1_2
I0715 16:53:43.956207 5838 net.cpp:406] bn1_2 <- conv1_2
I0715 16:53:43.956223 5838 net.cpp:367] bn1_2 -> conv1_2 (in-place)
I0715 16:53:43.956513 5838 net.cpp:122] Setting up bn1_2
I0715 16:53:43.956524 5838 net.cpp:129] Top shape: 1 64 224 224 (3211264)
I0715 16:53:43.956528 5838 net.cpp:137] Memory required for data: 64827392
I0715 16:53:43.956544 5838 layer_factory.hpp:77] Creating layer relu1_2
I0715 16:53:43.956558 5838 net.cpp:84] Creating Layer relu1_2
I0715 16:53:43.956567 5838 net.cpp:406] relu1_2 <- conv1_2
I0715 16:53:43.956583 5838 net.cpp:367] relu1_2 -> conv1_2 (in-place)
I0715 16:53:43.956598 5838 net.cpp:122] Setting up relu1_2
I0715 16:53:43.956604 5838 net.cpp:129] Top shape: 1 64 224 224 (3211264)
I0715 16:53:43.956609 5838 net.cpp:137] Memory required for data: 77672448
I0715 16:53:43.956615 5838 layer_factory.hpp:77] Creating layer pool1
I0715 16:53:43.956630 5838 net.cpp:84] Creating Layer pool1
I0715 16:53:43.956637 5838 net.cpp:406] pool1 <- conv1_2
I0715 16:53:43.956655 5838 net.cpp:380] pool1 -> pool1
I0715 16:53:43.956674 5838 net.cpp:380] pool1 -> pool1_mask
I0715 16:53:43.956704 5838 net.cpp:122] Setting up pool1
I0715 16:53:43.956715 5838 net.cpp:129] Top shape: 1 64 112 112 (802816)
I0715 16:53:43.956723 5838 net.cpp:129] Top shape: 1 64 112 112 (802816)
I0715 16:53:43.956727 5838 net.cpp:137] Memory required for data: 84094976
I0715 16:53:43.956734 5838 layer_factory.hpp:77] Creating layer unpool1
I0715 16:53:43.956753 5838 net.cpp:84] Creating Layer unpool1
I0715 16:53:43.956760 5838 net.cpp:406] unpool1 <- pool1
I0715 16:53:43.956775 5838 net.cpp:406] unpool1 <- pool1_mask
I0715 16:53:43.956789 5838 net.cpp:380] unpool1 -> unpool1
kernel_size:0has_kernel_h:0has_kernel_w:0
F0715 16:53:43.956820 5838 unpooling_layer.cpp:29] Check failed: !unpool_param.has_kernel_size() != !(unpool_param.has_kernel_h() && unpool_param.has_kernel_w()) Filter size is kernel_size OR kernel_h and kernel_w; not both
*** Check failure stack trace: ***
Aborted (core dumped)
I print the value of kernel_size, has_kernel_h and has_kernel_w. which are all 0.
This is my deploy.prototxt file.
Prototxt file
name: "Deconv_test"
input: "data"
input_dim: 1
input_dim: 3
input_dim: 224
input_dim: 224
#data:224*224
layers
{
bottom: "data"
top: "conv1_1"
name: "conv1_1"
type: CONVOLUTION
blobs_lr: 1 blobs_lr: 2
weight_decay: 1 weight_decay: 0
convolution_param {
num_output: 64
pad: 1
kernel_size: 3 }
}
#conv1_1
layers
{
bottom: 'conv1_1'
top: 'conv1_1'
name: 'bn1_1'
type: BN
bn_param {
scale_filler { type: 'constant' value: 1 }
shift_filler { type: 'constant' value: 0.001 }
bn_mode: INFERENCE}
}
layers {
bottom: "conv1_1"
top: "conv1_1"
name: "relu1_1"
type: RELU}
# conv1_2
layers
{
bottom: "conv1_1"
top: "conv1_2"
name: "conv1_2"
type: CONVOLUTION
blobs_lr: 1 blobs_lr: 2
weight_decay: 1 weight_decay: 0
convolution_param {
num_output: 64
pad: 1
kernel_size: 3 }
}
layers
{
bottom: 'conv1_2'
top: 'conv1_2'
name: 'bn1_2'
type: BN
bn_param {
scale_filler { type: 'constant' value: 1 }
shift_filler { type: 'constant' value: 0.001 }
bn_mode: INFERENCE }
}
layers {
bottom: "conv1_2"
top: "conv1_2"
name: "relu1_2"
type: RELU}
# pool1
layers
{
bottom: "conv1_2"
top: "pool1"
top:"pool1_mask"
name: "pool1"
type: POOLING
pooling_param {
pool: MAX
kernel_size: 2
stride: 2 }
}
# unpool1
layers
{
type: UNPOOLING
bottom: "pool1"
bottom: "pool1_mask"
top: "unpool1"
name: "unpool1"
unpooling_param {
unpool: MAX
kernel_size: 2
stride: 2
unpool_size: 224
}
}
# deconv1_1
layers {
bottom: 'unpool1'
top: 'deconv1_1'
name: 'deconv1_1'
type: DECONVOLUTION
blobs_lr: 1 blobs_lr: 2
weight_decay: 1 weight_decay: 0
convolution_param {
num_output:64
pad:1
kernel_size: 3
weight_filler { type: "gaussian" std: 0.01 }
bias_filler { type: "constant" value: 0 }
}
}
layers
{
bottom: 'deconv1_1'
top: 'deconv1_1'
name: 'debn1_1'
type: BN
bn_param {
scale_filler { type: 'constant' value: 1 }
shift_filler { type: 'constant' value: 0.001 }
bn_mode: INFERENCE }
}
layers {
bottom: 'deconv1_1'
top: 'deconv1_1'
name: 'derelu1_1'
type: RELU
}
# deconv1_2
layers
{
bottom: 'deconv1_1'
top: 'deconv1_2'
name: 'deconv1_2'
type: DECONVOLUTION
blobs_lr: 1
blobs_lr: 2
weight_decay: 1
weight_decay: 0
convolution_param {
num_output:64
pad:1
kernel_size: 3
weight_filler { type: "gaussian" std: 0.01 }
bias_filler { type: "constant" value: 0 }
}
}
layers
{
bottom: 'deconv1_2'
top: 'deconv1_2'
name: 'debn1_2'
type: BN
bn_param { scale_filler { type: 'constant' value: 1 }
shift_filler { type: 'constant' value: 0.001 }
bn_mode: INFERENCE } }
layers {
bottom: 'deconv1_2'
top: 'deconv1_2'
name: 'derelu1_2'
type: RELU }
# seg-score
layers
{
name: 'seg-score-voc' type: CONVOLUTION bottom: 'deconv1_2' top: 'seg-score'
blobs_lr: 1 blobs_lr: 2 weight_decay: 1 weight_decay: 0
convolution_param {
num_output: 21 kernel_size: 1
weight_filler {
type: "gaussian"
std: 0.01 }
bias_filler {
type: "constant"
value: 0 }
}
}
I am searching for a long time on net. But no use. Please help or try to give some ideas how to solve this.
You need to define kernel_size for your layer! kernel_size cannot be zero.
Caffe allows you to define kernel_size in two ways:
Using kernel_size once to use the same value for all spatial dimensions, or once per spatial dimension.
Alternatively, for 2D Blobs, you can specify kernel_h and kernel_w for height and width of the kernel respectively.
See "Deconvolution" layer help for more information.

Validate existance of RGB channels

I'm looking over a number of images with missing aspects, namely missing either red, green or blue channels (which have been removed accidentally by an automated process before I was give the images). I need to fine the valid images.
Is there a quick way of checking to see if an image has all three (R, G & B) channels? Alpha channels (if included) are ignored.
I've been using PIL up until this for image processing in Python point (I realise it might not be the way forward). I've not tried anything yet as I'm not sure the best way forward: My first guess, and this may be long winded would be to loop over every pixel and working out if all the Red, Green or Blue data is zero (presumed missing) However I 've a feeling there's a faster method.
You can check pretty easily with ImageMagick if an image has a missing channel. It is installed on most Linux distros and is available for OSX and Windows - it also has Python bindings but for now, I am just using the command-line:
tl;dr
Multiply together the mean of the red, the mean of the green and the mean of the blue channel - if any one of them is zero, the answer will be zero so your test is quick and easy:
convert NormalImage.png -format '%[fx:mean.r*mean.g*mean.b]' info:
0.0284282
or
convert NoRed.jpg -format '%[fx:mean.r*mean.g*mean.b]' info:
0
Longer Version
Basically, you can get the image statistics like this:
identify -verbose main.png
Image: main.png
Format: PNG (Portable Network Graphics)
Mime type: image/png
Class: DirectClass
Geometry: 1790x4098+0+0
Units: Undefined
Type: TrueColor
Endianess: Undefined
Colorspace: sRGB
Depth: 8-bit
Channel depth:
red: 8-bit
green: 8-bit
blue: 8-bit
Channel statistics:
Pixels: 7335420
Red:
min: 0 (0)
max: 184 (0.721569)
mean: 139.605 (0.547471) <--- Useful
standard deviation: 76.5813 (0.300319)
kurtosis: -0.46531
skewness: -1.21572
entropy: 0.210465
Green:
min: 0 (0)
max: 115 (0.45098)
mean: 87.2562 (0.342181) <--- Useful
standard deviation: 47.864 (0.187702)
kurtosis: -0.465408
skewness: -1.21572
entropy: 0.223793
Blue:
min: 0 (0)
max: 51 (0.2)
mean: 38.6967 (0.151752) <--- Useful
standard deviation: 21.2286 (0.0832494)
kurtosis: -0.46556
skewness: -1.21571
entropy: 0.253787
Image statistics:
Overall:
min: 0 (0)
max: 184 (0.721569)
mean: 88.5193 (0.347134)
standard deviation: 53.5609 (0.210043)
kurtosis: 1.21045
skewness: 0.306884
entropy: 0.229348
Rendering intent: Perceptual
Gamma: 0.454545
Chromaticity:
red primary: (0.64,0.33)
green primary: (0.3,0.6)
blue primary: (0.15,0.06)
white point: (0.3127,0.329)
Background color: white
Border color: srgb(223,223,223)
Matte color: grey74
Transparent color: black
Interlace: None
Intensity: Undefined
Compose: Over
Page geometry: 1790x4098+0+0
Dispose: Undefined
Iterations: 0
Compression: Zip
Orientation: Undefined
Properties:
date:create: 2016-05-04T12:09:37+01:00
date:modify: 2016-05-04T12:00:06+01:00
png:bKGD: chunk was found (see Background color, above)
png:IHDR.bit-depth-orig: 8
png:IHDR.bit_depth: 8
png:IHDR.color-type-orig: 2
png:IHDR.color_type: 2 (Truecolor)
png:IHDR.interlace_method: 0 (Not interlaced)
png:IHDR.width,height: 1790, 4098
png:sRGB: intent=0 (Perceptual Intent)
signature: 1b12ce9d2a18826aa215b7e8b87a050717572ed638a6be6332c741eddb36c0be
Artifacts:
filename: main.png
verbose: true
Tainted: False
Filesize: 942KB
Number pixels: 7.335M
Pixels per second: 73.35MB
User time: 0.090u
Elapsed time: 0:01.099
Version: ImageMagick 6.9.3-7 Q16 x86_64 2016-04-05 http://www.imagemagick.org
Or, if you like parsing JSON:
convert main.png json:
{
"image": {
"name": "main.png",
"format": "PNG",
"formatDescription": "Portable Network Graphics",
"mimeType": "image/png",
"class": "DirectClass",
"geometry": {
"width": 1790,
"height": 4098,
"x": 0,
"y": 0
},
"units": "Undefined",
"type": "TrueColor",
"endianess": "Undefined",
"colorspace": "sRGB",
"depth": 8,
"baseDepth": 8,
"channelDepth": {
"red": 8,
"green": 8,
"blue": 8
},
"pixels": 7335420,
"imageStatistics": {
"all": {
"min": "0",
"max": "184",
"mean": "88.5193",
"standardDeviation": "53.5609",
"kurtosis": "1.21045",
"skewness": "0.306884"
}
},
"channelStatistics": {
"red": {
"min": "0",
"max": "184",
"mean": "139.605",
"standardDeviation": "76.5813",
"kurtosis": "-0.46531",
"skewness": "-1.21572"
},
"green": {
"min": "0",
"max": "115",
"mean": "87.2562",
"standardDeviation": "47.864",
"kurtosis": "-0.465408",
"skewness": "-1.21572"
},
"blue": {
"min": "0",
"max": "51",
"mean": "38.6967",
"standardDeviation": "21.2286",
"kurtosis": "-0.46556",
"skewness": "-1.21571"
}
},
"renderingIntent": "Perceptual",
"gamma": 0.454545,
"chromaticity": {
"redPrimary": {
"x": 0.64,
"y": 0.33
},
"greenPrimary": {
"x": 0.3,
"y": 0.6
},
"bluePrimary": {
"x": 0.15,
"y": 0.06
},
"whitePrimary": {
"x": 0.3127,
"y": 0.329
}
},
"backgroundColor": "#FFFFFF",
"borderColor": "#DFDFDF",
"matteColor": "#BDBDBD",
"transparentColor": "#000000",
"interlace": "None",
"intensity": "Undefined",
"compose": "Over",
"pageGeometry": {
"width": 1790,
"height": 4098,
"x": 0,
"y": 0
},
"dispose": "Undefined",
"iterations": 0,
"compression": "Zip",
"orientation": "Undefined",
"properties": {
"date:create": "2016-05-04T12:09:37+01:00",
"date:modify": "2016-05-04T12:00:06+01:00",
"png:bKGD": "chunk was found (see Background color, above)",
"png:IHDR.bit-depth-orig": "8",
"png:IHDR.bit_depth": "8",
"png:IHDR.color-type-orig": "2",
"png:IHDR.color_type": "2 (Truecolor)",
"png:IHDR.interlace_method": "0 (Not interlaced)",
"png:IHDR.width,height": "1790, 4098",
"png:sRGB": "intent=0 (Perceptual Intent)",
"signature": "1b12ce9d2a18826aa215b7e8b87a050717572ed638a6be6332c741eddb36c0be"
},
"artifacts": {
"filename": "main.png"
},
"tainted": false,
"filesize": "942KB",
"numberPixels": "7.335M",
"pixelsPerSecond": "73.35MB",
"userTime": "0.090u",
"elapsedTime": "0:01.099",
"version": "ImageMagick 6.9.3-7 Q16 x86_64 2016-04-05 http://www.imagemagick.org"
}
}
Or, you can be more surgical and just get things that interest you:
convert main.png -format '%[fx:255*mean.r]' info:
139.605
Pretty much any image processing library provides means for reading pixel values. The simplest and most efficient way is indeed iterating over all pixels checking if any value is 0 for all pixels.
Of course many libraries also provide convenient tools for extracting color planes and calculating average pixel values. But internally, they do nothing but iterating over pixels. How else should any algorithm know if all values are zero if not by checking every value? So your feeling is wrong, unless the pixel reading function is poorly implemented and the algorithm is using someething more efficient, which is quite unlikely.
So you're doing nothing wrong either way.

webpack error in missing path # multi main

I'm seeing an error in webpack when I try to run my build.
webpack --config conf/webpack.build.config.js --progress --colors --display-error-details --display-modules --display-reasons
Hash: e633ac8cf3ba9196f876
Version: webpack 1.12.9
Time: 312ms
Asset Size Chunks Chunk Names
tinymce-comments-plus-bundle.js 5.88 kB 0 [emitted] main
[0] multi main 28 bytes {0} [built] [1 error]
[1] ./js/tinymce-comments-plus.js 0 bytes [built] [failed]
single entry ./js/tinymce-comments-plus.js [0] multi main
ERROR in missing path
# multi main
Options.build is true when the npm task is running. I've tried adjusting the paths but can't seem to find which path is wrong. Where is # multi main?
Here is my webpack config.
module.exports = function( options ) {
var path = require( 'path' ),
cssLoaders = 'style!css',
scssLoaders = cssLoaders + '!sass',
babelLoader = 'react-hot!babel',
webpack = require( 'webpack' ),
ExtractTextPlugin = require( 'extract-text-webpack-plugin' );
function extractLoaders( extract, loaders ) {
return ExtractTextPlugin.extract( extract, loaders.substr( loaders.indexOf( '!' ) ) );
}
if ( options.build ) {
cssLoaders = extractLoaders( 'style', cssLoaders );
scssLoaders = extractLoaders( 'style', scssLoaders );
babelLoader = extractLoaders( 'react-hot', babelLoader );
}
return {
entry: [ './js/tinymce-comments-plus.js' ],
output: {
path: __dirname + '/../js',
publicPath: options.build ? '/dist/' : 'http://localhost:8080/',
filename: 'tinymce-comments-plus-bundle.js',
// hot: true,
// headers: { 'Access-Control-Allow-Origin': '*' }
},
module: {
loaders: [
{
test: /\.css$/,
loader: cssLoaders
},
{
test: /\.scss$/,
loader: scssLoaders
},
{
test: /\.js$/,
exclude: /node_modules/,
loader: babelLoader
},
{
test: /\.jsx$/,
exclude: /node_modules/,
loader: babelLoader
}
]
},
resolve: {
root: [
path.join( __dirname, '..', 'components' ),
path.join( __dirname, '..', 'js' ),
path.join( __dirname, '..', 'sass' ),
],
extensions: [ '', '.js', '.jsx', '.sass', '.scss', '.css' ],
},
plugins: options.build ? [
// build plugins
new ExtractTextPlugin( './css/[name].css' ),
new webpack.optimize.UglifyJsPlugin({
compress: {
warnings: false
}
}),
new webpack.HotModuleReplacementPlugin()
] : [
// dev plugins
new ExtractTextPlugin( './css/[name].css' ),
//new webpack.HotModuleReplacementPlugin()
]
}; }
I had a similar issue, I would recommend installing webpack globally using npm install -g webpack then linking to the global installation npm link webpack
Also, ensure that you have your extension linked to resolve.extensions
resolve: {
extensions: ['', '.ts', '.tsx', '.js'] // <-- Had to add the .js one
}