PerceptiLabs
v0.13
v0.11v0.12v0.13
v0.13
v0.11v0.12v0.13
  • Welcome
  • ⚡Getting Started
    • Quickstart Guide
      • Requirements
      • Installation
      • Video Tutorials
    • Load and Pre-process Data
    • Build Models
    • Train Models
    • Evaluate Models
    • Export and Deploy Models
    • Manage, Version, and Track Models
  • 🙏How to Contribute
    • Datasets
    • Models
    • Components
  • 👨‍🍳Tutorials
    • Basic Image Recognition
    • Basic Image Segmentation
  • 🛠️Advanced
    • Common Testing Issues
    • Common Training Issues
    • Components
      • Input and Target
      • Processing
      • Deep Learning
      • Operations
      • Custom
    • CSV File Format
    • Debugging and Diagnostic Features
    • How PerceptiLabs Works With TensorFlow
    • Included Packages
    • Types of Tests
    • UI Overview
      • Data Wizard
      • Overview Screen
      • Model Training Settings
      • Modeling Tool
      • Training View
      • Evaluate View
      • Deploy View
    • Using the Exported/Deployed Model
  • 💡Use Cases
    • General
      • A Guide to Using U-Nets for Image Segmentation
      • A Voice Recognition model using Image Recognition
    • Environmental
      • Automated Weather Analysis Using Image Recognition
      • Wildfire Detection
    • Healthcare & Medical
      • Brain Tumor Detection
      • Breast Cancer Detection
      • Classifying Chest X-Rays to Detect Pneumonia
      • Classifying Ways to Wear a Face Mask
      • Detecting Defective Pills
      • Highlighting Blood Cells in Dark-field Microscopy Using Image Segmentation
      • Ocular Disease Recognition
      • Retinal OCT
      • Skin Cancer Classification
    • Industrial IoT & Manufacturing
      • Air Conditioner Piston Check
      • Classifying Fruit
      • Classifying Wood Veneers Into Dry and Wet
      • Defect Detection in Metal Surfaces
      • Fabric Stain Classification
  • 📖Support
    • FAQs
    • Changelog
  • Code of Conduct
  • Marketing Site
Powered by GitBook
On this page

Was this helpful?

  1. Advanced
  2. Components

Custom

The Custom Component provides a generic Component in which you can write custom Python (e.g., TensorFlow) code to transform data. This is done by using the Code Editor.

The Component's input socket must be connected to another Component that provides input data, and the output socket must be connected to another Component to output the transformed data to.

Default Code

The Custom component starts out with the following code:

class LayerCustom_LayerCustom_1Keras(tf.keras.layers.Layer, PerceptiLabsVisualizer):
    def call(self, inputs, training=True):
        
        raise TypeError("Missing input connection 'input'")
                            
                
        input_ = inputs['input']
        output = preview = input_
        
            
        self._outputs = {            
            'output': output,
            'preview': output,
        }
                            

        return self._outputs

    def get_config(self):
        """Any variables belonging to this layer that should be rendered in the frontend.
        
        Returns:
            A dictionary with tensor names for keys and picklable for values.
        """
        return {}

    @property
    def visualized_trainables(self):
        """ Returns two tf.Variables (weights, biases) to be visualized in the frontend """
        return tf.constant(0), tf.constant(0)


class LayerCustom_LayerCustom_1(Tf2xLayer):
    def __init__(self):
        super().__init__(
            keras_class=LayerCustom_LayerCustom_1Keras
        )

Note: When you connect the input socket of your Custom Component to the output socket of another Component, PerceptiLabs will automatically remove the line:

raise TypeError("Missing input connection 'input'").

You will add your code to the call() method of the LayerCustom_LayerCustom_1Keras class which is invoked by PerceptiLabs to transform data when the model runs (including when PerceptiLabs runs the model as you edit it in the Modeling Tool to display previews). In general, you will add your transformation(s) between the input and output assignments:

input_ = inputs['input']

"""add your transformation(s)/custom code here..."""

output = preview = input_

Tip: You can include import statements above the class declarations to import other Python modules.

For additional information see: How PerceptiLabs Works with TensorFlow.

PreviousOperationsNextCSV File Format

Last updated 3 years ago

🛠️