Wolfram Research

U-Net Trained on Glioblastoma-Astrocytoma U373 Cells on a Polyacrylamide Substrate Data

Segment a microscopy image to detect cells

Released in 2015 by the University of Freiburg, Germany, this model exploits an architecture consisting of a contracting path to capture context and a symmetric expanding path that enables the precise segmentation of glioblastoma-astrocytoma U373 cells on a polyacrylamide substrate.

Number of layers: 61 | Parameter count: 31,100,354 | Trained size: 125 MB

Training Set Information

Performance

Examples

Resource retrieval

Get the pre-trained net:

In[1]:=
NetModel["U-Net Trained on Glioblastoma-Astrocytoma U373 Cells on a \
Polyacrylamide Substrate Data"]
Out[1]=

Evaluation function

Define an evaluation function to handle net reshaping and tiling of the input and output:

In[2]:=
netevaluate[img_, device_: "CPU"] :=
 Block[
  {net = NetModel[
     "U-Net Trained on Glioblastoma-Astrocytoma U373 Cells on a \
Polyacrylamide Substrate Data"],
   dims = ImageDimensions[img], pads, mask},
  pads = Map[{Floor[#], Ceiling[#]} &, Mod[4 - dims, 16]/2];
  mask = NetReplacePart[
     net,
     {"Input" -> 
       NetEncoder[{"Image", Ceiling[dims - 4, 16] + 188, 
         ColorSpace -> "Grayscale"}],
      "Output" -> NetDecoder[{"Class", Range[2], "InputDepth" -> 3}]}][
    ImagePad[ColorConvert[img, "Grayscale"], pads + 92, 
     Padding -> "Reversed"],
    TargetDevice -> device
    ];
  Take[mask, {1, -1} Reverse[pads[[2]] + 1], {1, -1} (pads[[1]] + 1)]
  ]

Basic usage

Obtain the segmentation mask for a given image:

In[3]:=
CloudGet["https://www.wolframcloud.com/objects/1414347a-bca0-4f2f-a433-e5e2549c88a5"] (* Evaluate this cell to copy the example input from a cloud object *)
In[4]:=
mask = netevaluate[img];

Visualize the mask:

In[5]:=
Colorize[mask]
Out[5]=

Overlay the mask on the input image:

In[6]:=
HighlightImage[img, Image[mask - 1, "Bit"]]
Out[6]=

Net information

Inspect the number of parameters of all arrays in the net:

In[7]:=
NetInformation[
 NetModel["U-Net Trained on Glioblastoma-Astrocytoma U373 Cells on a \
Polyacrylamide Substrate Data"], "ArraysElementCounts"]
Out[7]=

Obtain the total number of parameters:

In[8]:=
NetInformation[
 NetModel["U-Net Trained on Glioblastoma-Astrocytoma U373 Cells on a \
Polyacrylamide Substrate Data"], "ArraysTotalElementCount"]
Out[8]=

Obtain the layer type counts:

In[9]:=
NetInformation[
 NetModel["U-Net Trained on Glioblastoma-Astrocytoma U373 Cells on a \
Polyacrylamide Substrate Data"], "LayerTypeCounts"]
Out[9]=

Display the summary graphic:

In[10]:=
NetInformation[
 NetModel["U-Net Trained on Glioblastoma-Astrocytoma U373 Cells on a \
Polyacrylamide Substrate Data"], "SummaryGraphic"]
Out[10]=

Export to MXNet

Export the net into a format that can be opened in MXNet:

In[11]:=
jsonPath = 
 Export[FileNameJoin[{$TemporaryDirectory, "net.json"}], 
  NetModel["U-Net Trained on Glioblastoma-Astrocytoma U373 Cells on a \
Polyacrylamide Substrate Data"], "MXNet"]
Out[11]=

Export also creates a net.params file containing parameters:

In[12]:=
paramPath = FileNameJoin[{DirectoryName[jsonPath], "net.params"}]
Out[12]=

Get the size of the parameter file:

In[13]:=
FileByteCount[paramPath]
Out[13]=

The size is similar to the byte count of the resource object:

In[14]:=
ResourceObject[
  "U-Net Trained on Glioblastoma-Astrocytoma U373 Cells on a \
Polyacrylamide Substrate Data"]["ByteCount"]
Out[14]=
In[15]:=
Import[jsonPath, {"MXNet", "NodeGraphPlot"}]
Out[15]=

Requirements

Wolfram Language 11.3 (March 2018) or above

Resource History

Reference

  • O. Ronneberger, P. Fischer, T. Brox "U-Net: Convolutional Networks for Biomedical Image Segmentation," arXiv:1505.04597 (2015)
  • (available from https://lmb.informatik.uni-freiburg.de/people/ronneber/u-net/index.html)
  • Rights: All code is provided for research purposes only and without any warranty. Any commercial use requires the authors' consent. When using the code in your research work, you should cite the respective paper.