フィルターのクリア

how to generate deep dream data from own Images ?

2 ビュー (過去 30 日間)
Selva Karna
Selva Karna 2017 年 9 月 9 日
回答済み: voxey 2018 年 4 月 4 日
how to generate deep dream data from own Images ?

採用された回答

Image Analyst
Image Analyst 2017 年 9 月 9 日
Find an article on it and code it up, because there is no built in function for that.
  1 件のコメント
Selva Karna
Selva Karna 2017 年 9 月 11 日
any other way to generate deep dream image in our own image?

サインインしてコメントする。

その他の回答 (9 件)

Delprat Sebastien
Delprat Sebastien 2018 年 1 月 4 日
編集済み: Star Strider 2018 年 1 月 4 日
clear all;
close all;
clc;
% ===============================
% You will need to download the net using the Matlab app finder tool
% ===============================
No=1;
switch No
case 1
net=alexnet;
netname='AlexNet';
layer = 23; % Ouput layer before classification
case 2
net=vgg16;
netname='VGG16';
layer = 39; % Ouput layer before classification
end
InputSize=net.Layers(1).InputSize;
fprintf('==============================\n');
fprintf('Network layers\n');
net.Layers
fprintf('==============================\n');
fprintf('Network classes\n');
for i=1:length(net.Layers(end).ClassNames)
fprintf('%i - %s\n',i,net.Layers(end).ClassNames{i});
end
% ==============================================
% Your image to be used as a starting dream
% ==============================================
FileName='Poisson';
initImg=imread([FileName '.jpg']);
initImg=imresize(initImg,InputSize(1:2));
[label,scores] = classify(net,initImg);
% Display network output, just for info (display the 5 more probable
% classes)
[~,idx] = sort(scores,'descend');
idx = idx(5:-1:1);
classNames = net.Layers(end).ClassNames;
classNamesTop = classNames(idx);
scoreTop = scores(idx);
fprintf('Most probable classes:\n');
for i=1:length(idx)
fprintf('%i - %s - %f\n',i,classNamesTop{i},scoreTop(i));
end
% Display initial image
figure;
imshow(initImg)
channels = [208]; % Golden retriever
channels = 53; % Thunder snake
channels = 481; % Cash machine
channels = 158; % Papillon
channels = 162; % Basset
channels = 328; % Starfish
channels = 818; % sports car
fprintf('Targeted class: %s\n',net.Layers(end).ClassNames{channels});
levels = 1; % 1 or 2 is good
iterations = 20; % higher better, but also longer
I = deepDreamImage(net,layer,channels, ...
'Verbose',true, ...
'NumIterations',iterations, ...
'PyramidLevels',levels,...
'InitialImage',initImg);% 'PyramidScale',1.2,...
% Save result and built file name using algorithm config
Classname=net.Layers(end).ClassNames{channels};
name=sprintf('dreem_%s_%s_chl_%i_iter_%i_lvl_%i_%s',netname,FileName,channels,iterations,levels,Classname);
imwrite(I,[name '.jpg']);
% Display result
figure
imshow(I)
Original image:
Dreamed image (fish interpreted as a snake)
  2 件のコメント
Selva Karna
Selva Karna 2018 年 3 月 29 日
Thanks to Delprat Sebastien, Star Strider
Thanks for spending your Time. and ideas. i will replay you.
Selva Karna
Selva Karna 2018 年 3 月 29 日
i did not get result above like this,
My result is , how can i get Good visible result from like above result.. we will change any layer or iteration ????

サインインしてコメントする。


Selva Karna
Selva Karna 2018 年 3 月 29 日
編集済み: Selva Karna 2018 年 3 月 29 日
Why i get the error like this ? how to use directly use image without image resize ?
For an image input layer, the input data for predict must be a single image, a 4D array of images, or an imageDatastore with the correct size.
  6 件のコメント
Selva Karna
Selva Karna 2018 年 3 月 30 日
Image Analyst
Image Analyst 2018 年 3 月 31 日
Alexnet is built assuming that size. If you want different size you'd have to use a different network. However, you will probably find it does just fine with resizing your images to that. It will most likely still work with your images.

サインインしてコメントする。


Delprat Sebastien
Delprat Sebastien 2018 年 4 月 1 日
Please look at the following code https://fr.mathworks.com/matlabcentral/fileexchange/66710-deep-dreaming-animation-for-matlab
There is : 1) a required modification to add clipping to the original matlab code 2) a script that generate an animation from image (with resizing) using recursive deepdream
NB : please read carefully the patch.m file... Enjoy

Selva Karna
Selva Karna 2018 年 4 月 2 日
編集済み: Image Analyst 2018 年 4 月 2 日
Delprat Sebastien, it's not working. I got this error below:
Error in deepDreamImage2 (line 186)
X = nnet.internal.cnn.visualize.deepDreamImageLaplacianNorm2(...
Error in check_April2 (line 38)
Idream = deepDreamImage2(net,layer,channels, ...
  2 件のコメント
Delprat Sebastien
Delprat Sebastien 2018 年 4 月 2 日
編集済み: Delprat Sebastien 2018 年 4 月 2 日
If you do not copy the error in detail, I cannot help. Did you copy the deepDreamImageLaplacianNorm as deepDreamImageLaplacianNorm2 in the specified matlab toolbox folder?
Selva Karna
Selva Karna 2018 年 4 月 3 日
編集済み: Selva Karna 2018 年 4 月 3 日
yes i copied deepDreamImageLaplacianNorm as deepDreamImageLaplacianNorm2 in the specified matlab toolbox folder , but i got this error .

サインインしてコメントする。


Selva Karna
Selva Karna 2018 年 4 月 3 日
Error: Frame n°i : 1 / 20 Error using nnet.internal.cnn.visualize.resizeImage (line 11) output size must be [height width]
Error in deepDreamImage2 (line 183) avgI = nnet.internal.cnn.visualize.resizeImage(iVisualNet.Layers{1}.AverageImage, sz(1:3));
Error in check_April2 (line 38) Idream = deepDreamImage2(net,layer,channels, ...
Here i have attached modified code please kindly check the code,

Delprat Sebastien
Delprat Sebastien 2018 年 4 月 3 日
In the deepDreamImageLaplacianNorm2.m you must not comment the gradient ascend % X = X + gradient * stepSize; X=max(XMin2,min(X,XMax2));
=> should be (mind the % removal) X = X + gradient * stepSize; X=max(XMin2,min(X,XMax2));
  2 件のコメント
Selva Karna
Selva Karna 2018 年 4 月 3 日
Again i got this error sir, Frame n°i : 1 / 20 Error using deepDreamImage2 Too many input arguments.
Error in check_April2 (line 90) Idream = deepDreamImage2(net,layer,channels, ...
I have attached my modified files please check this file
Selva Karna
Selva Karna 2018 年 4 月 3 日
I Got this following Erro Frame n°i : 1 / 20 Undefined variable "nnet" or class "nnet.internal.cnn.visualize.deepDreamImageLaplacianNorm2".
Error in deepDreamImage2 (line 186) X = nnet.internal.cnn.visualize.deepDreamImageLaplacianNorm2(...
Error in check_April2 (line 90) Idream = deepDreamImage2(net,layer,channels, ...

サインインしてコメントする。


Selva Karna
Selva Karna 2018 年 4 月 3 日
Can u send code deepDreamImage2 ,.deepDreamImageLaplacianNorm2 ?

Delprat Sebastien
Delprat Sebastien 2018 年 4 月 3 日
Unfortunately, due to Mathworks copyright, I cannot disclose the source code of their functions. If you follow the steps detailed in the patch. M files, this should be OK.
In your previous code, you did add a comment on the original line x = x + g*stepsize. Remove this comment and it should work.
  2 件のコメント
Selva Karna
Selva Karna 2018 年 4 月 3 日
i have did , but i have error.sir Delprat Sebastien,
Selva Karna
Selva Karna 2018 年 4 月 3 日
Delprat Sebastien i got this error following ?
Frame n°i : 1 / 20 Undefined variable "nnet" or class "nnet.internal.cnn.visualize.deepDreamImageLaplacianNorm2".
Error in deepDreamImage2 (line 186) X = nnet.internal.cnn.visualize.deepDreamImageLaplacianNorm2(...
Error in check_April2 (line 90) Idream = deepDreamImage2(net,layer,channels, ...
>> >>

サインインしてコメントする。


voxey
voxey 2018 年 4 月 4 日
check the image size

カテゴリ

Help Center および File ExchangeImage Data Workflows についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by