MyCaffe  1.11.7.7
Deep learning software for Windows C# programmers.
MyCaffe.extras.DeepDraw< T > Class Template Reference

The DeepDraw class implements both deep drawing and deep dream as originally introduced by Google. More...

Inheritance diagram for MyCaffe.extras.DeepDraw< T >:

Public Member Functions

 DeepDraw (CancelEvent evtCancel, Net< T > net, DataTransformer< T > transformer, string strSrcBlobName="data")
 The constructor. More...
 
void Dispose ()
 Releases all resources used by DeepDraw. More...
 
void Add (string strLayer, int nIterations, double dfStartSigma, double dfEndSigma, double dfStartStep, double dfEndStep, bool bSaveFile=false, double dfPctDetailsToApply=0.25)
 Adds a new Octave to run the deep drawing over. More...
 
void Add (Octaves octaves)
 Add a new Octaves to the collection of Octaves to run. More...
 
IEnumerator< OctavesGetEnumerator ()
 Returns the Octave enumerator. More...
 
Bitmap CreateRandomImage (Color clrBack, int nW=-1, int nH=-1, double dfScale=16.0)
 Creates an image with random noise. More...
 
bool Render (Bitmap bmpInput, int nFocusLabel=-1, double dfDetailPercentageToOutput=0.25, string strOutputDir=null, bool bVisualizeEachStep=false, float[] rgDirectInputs=null)
 Renders the deep draw image(s) depending on the Octave's installed. More...
 

Static Public Member Functions

static Bitmap CreateRandomImageEx (Color clrBack, int nW, int nH, double dfScale=16.0)
 Creates an image with random noise. More...
 
static Bitmap AdjustContrast (Image bmp, float fBrightness=1.0f, float fContrast=1.0f, float fGamma=1.0f)
 The AdjustContrast function adjusts the brightness, contrast and gamma of the image and returns the newly adjusted image. More...
 
static string CreateConfigurationString (int nWd, int nHt, double dfOutputDetailPct, OctavesCollection colOctaves, string strSrcBlobName, double dfRandomImageScale)
 The CreateConfigurationString function packs all deep draw settings into a configuration string. More...
 
static OctavesCollection ParseConfigurationString (string strConfig, out int nWd, out int nHt, out double dfOutputDetailPct, out string strSrcBlobName, out double dfRandomImageScale)
 The ParseConfigurationString method parses a deep draw configuration string into the actual settings. More...
 

Properties

int Count [get]
 Returns the numberof Octaves installed. More...
 

Detailed Description

The DeepDraw class implements both deep drawing and deep dream as originally introduced by Google.

See also
Deep Dreams (with Caffe) by the Google Deep Dream Team, 2015.
Diving Deeper into Deep Dreams by Kirk Kaiser, 2015.
auduno/deepdraw on GitHub.
kylemcdonald/deepdream on GitHub
Template Parameters
TSpecifies the base type float or double. Using float is recommended to conserve GPU memory.

Definition at line 29 of file DeepDraw.cs.

Constructor & Destructor Documentation

◆ DeepDraw()

MyCaffe.extras.DeepDraw< T >.DeepDraw ( CancelEvent  evtCancel,
Net< T >  net,
DataTransformer< T >  transformer,
string  strSrcBlobName = "data" 
)

The constructor.

Parameters
evtCancelSpecifies the cancel event used to cancel the drawing operation.
netSpecifies the Net to use for the drawing operation.
transformerSpecifies the DataTransformer to use when preprocessing input images.
strSrcBlobNameSpecifies the the name of the Blob containing the data source.

Definition at line 50 of file DeepDraw.cs.

Member Function Documentation

◆ Add() [1/2]

void MyCaffe.extras.DeepDraw< T >.Add ( Octaves  octaves)

Add a new Octaves to the collection of Octaves to run.

Parameters
octavesSpecifies the Octaves to add.

Definition at line 124 of file DeepDraw.cs.

◆ Add() [2/2]

void MyCaffe.extras.DeepDraw< T >.Add ( string  strLayer,
int  nIterations,
double  dfStartSigma,
double  dfEndSigma,
double  dfStartStep,
double  dfEndStep,
bool  bSaveFile = false,
double  dfPctDetailsToApply = 0.25 
)

Adds a new Octave to run the deep drawing over.

Parameters
strLayerSpecifies the name of the target 'end' layer in the network.
nIterationsSpecifies the number of iterations to run over the Octave.
dfStartSigmaSpecifies the starting sigma used when performing the gaussian bluring, on each iteration this value moves toward the end sigma.
dfEndSigmaSpecifies the ending sigma to use whenp performing the gaussian bluring.
dfStartStepSpecifis the starting step, this value moves towards the end step on each iteration.
dfEndStepSpecifies the ending step.
bSaveFileSpecifies whether or not to save the final image for the octave to disk.
dfPctDetailsToApplySpecifies the percentage of the details from the previous octave run to apply to the source for this Octave - this value must be 1.0 when only using one Octave.

Definition at line 115 of file DeepDraw.cs.

◆ AdjustContrast()

static Bitmap MyCaffe.extras.DeepDraw< T >.AdjustContrast ( Image  bmp,
float  fBrightness = 1.0f,
float  fContrast = 1.0f,
float  fGamma = 1.0f 
)
static

The AdjustContrast function adjusts the brightness, contrast and gamma of the image and returns the newly adjusted image.

Parameters
bmpSpecifies the image to adjust.
fBrightnessSpecifies the brightness to apply.
fContrastSpecifies the contrast to apply.
fGammaSpecifies the gamma to apply.
Returns
The updated image is returned.

Definition at line 445 of file DeepDraw.cs.

◆ CreateConfigurationString()

static string MyCaffe.extras.DeepDraw< T >.CreateConfigurationString ( int  nWd,
int  nHt,
double  dfOutputDetailPct,
OctavesCollection  colOctaves,
string  strSrcBlobName,
double  dfRandomImageScale 
)
static

The CreateConfigurationString function packs all deep draw settings into a configuration string.

Parameters
nWdSpecifies the input width.
nHtSpecifies the input height.
dfOutputDetailPctSpecifies the percentage of detail to apply to the final output.
colOctavesSpecifies the collection of Octaves to run.
strSrcBlobNameSpecifies the name of the source blob.
dfRandomImageScaleSpecifies the random image scale to use, a number in the range [0,50] used to create varying degrees of gray in the random input image.
A value of 0 removes the variation and uses a consistent image.
Returns
The configuration string is returned.

Definition at line 461 of file DeepDraw.cs.

◆ CreateRandomImage()

Bitmap MyCaffe.extras.DeepDraw< T >.CreateRandomImage ( Color  clrBack,
int  nW = -1,
int  nH = -1,
double  dfScale = 16.0 
)

Creates an image with random noise.

Parameters
clrBackSpecifies the base back color.
nWOptionally, specifies the width. When not specified, the width of the source Blob is used instead (recommended).
nHOptionally, specifies the height. When not specified, the height of the source Blob is used instead (recommended).
dfScaleOptionally, specifies the spread of pixels randomized around the base color. For example the default of 16 randomly picks a color value +8 and -8 from the base color.
Returns

Definition at line 155 of file DeepDraw.cs.

◆ CreateRandomImageEx()

static Bitmap MyCaffe.extras.DeepDraw< T >.CreateRandomImageEx ( Color  clrBack,
int  nW,
int  nH,
double  dfScale = 16.0 
)
static

Creates an image with random noise.

Parameters
clrBackSpecifies the base back color.
nWSpecifies the width.
nHSpecifies the height.
dfScaleOptionally, specifies the spread of pixels randomized around the base color. For example the default of 16 randomly picks a color value +8 and -8 from the base color.
Returns

Definition at line 174 of file DeepDraw.cs.

◆ Dispose()

void MyCaffe.extras.DeepDraw< T >.Dispose ( )

Releases all resources used by DeepDraw.

Definition at line 75 of file DeepDraw.cs.

◆ GetEnumerator()

IEnumerator< Octaves > MyCaffe.extras.DeepDraw< T >.GetEnumerator ( )

Returns the Octave enumerator.

Returns
The Octave enumerator is returned.

Definition at line 133 of file DeepDraw.cs.

◆ ParseConfigurationString()

static OctavesCollection MyCaffe.extras.DeepDraw< T >.ParseConfigurationString ( string  strConfig,
out int  nWd,
out int  nHt,
out double  dfOutputDetailPct,
out string  strSrcBlobName,
out double  dfRandomImageScale 
)
static

The ParseConfigurationString method parses a deep draw configuration string into the actual settings.

Parameters
strConfigSpecifies the configuration string to parse.
nWdReturns the input width.
nHtReturns the input height.
dfOutputDetailPctReturns the percentage of detail to apply to the final image.
strSrcBlobNameReturns the source blob name.
dfRandomImageScaleReturns the random image scale to use, a number in the range [0,50] used to create varying degrees of gray in the random input image.
A value of 0 removes the variation and uses a consistent image. The default value is 16.
Returns
Returns the collection of Octaves to run.

Definition at line 492 of file DeepDraw.cs.

◆ Render()

bool MyCaffe.extras.DeepDraw< T >.Render ( Bitmap  bmpInput,
int  nFocusLabel = -1,
double  dfDetailPercentageToOutput = 0.25,
string  strOutputDir = null,
bool  bVisualizeEachStep = false,
float[]  rgDirectInputs = null 
)

Renders the deep draw image(s) depending on the Octave's installed.

Parameters
bmpInputSpecifies the input image.
nFocusLabelSpecifies a label to focus on (use this when running on classifying layers).
dfDetailPercentageToOutputOptionally, specifies the amount of detail to apply to the original image when producing the final image (Default = 0.25 for 25%).
strOutputDirOptionally, specifies the output directory wheren images are to be output. When null, no images are output, but are instead set in each Octave.
bVisualizeEachStepOptionally, specifies to create an image at each step of the process which can be useful when making a video of the evolution (default = false).
rgDirectInputsOptionally, specifies the direct inputs used to set each output. When not null the direct inputs are used instead of the nFocusLabel whereby the network outputs are set to the direct input values and the nFocusLabel is used to index the image and should therefore be unique for each set of direct inputs.
By default, this value is set to null.
Returns
Upon completing the render, this method returns true, otherwise if cancelled it returns false.

Definition at line 213 of file DeepDraw.cs.

Property Documentation

◆ Count

int MyCaffe.extras.DeepDraw< T >.Count
get

Returns the numberof Octaves installed.

Definition at line 99 of file DeepDraw.cs.


The documentation for this class was generated from the following file: