LogoLogo
  • TABLE OF CONTENTS
  • General Concepts
    • Overview
    • Introduction to Rendered.ai
    • The Rendered.ai Platform
    • Who Uses Rendered.ai?
    • Rendered.ai Licensing and Offerings
  • Application User Guides
    • Overview
    • Quick Start Guide
      • Terminology
      • Content Codes
      • Getting Started with the SDK
    • Tutorials
      • Organization and Workspace Resources
      • Creating and Using Graphs
        • Graph Validation
        • Graph Best Practices
      • Creating and Using Datasets
        • Dataset Annotations
        • Dataset Analytics
        • Domain Adaptation
        • Dataset Comparison
        • Training and Inference
        • Mixing Datasets
        • Dataset Best Practices
      • Creating and Using Volumes
        • Inpaint Service
      • Collaboration
  • Development Guides
    • Overview
    • Ana Software Architecture
      • Basic components
      • Graphs
      • Channels
      • Packages
      • Package Volumes
      • Nodes
      • Schema
      • Ana Modules, Classes, and Functions
      • The anatools Package
      • Graph Validation
        • Typical Validation Use Cases
      • Preview
      • In-tool Help
    • Setting Up the Development Environment
      • Local Development With NVIDIA GPUs
      • Remote Development With AWS EC2
    • Deploying a Channel
    • An Example Channel - Toybox
      • Run and Deploy the Toybox Channel
      • Add a Modifier Node
      • Add a Generator Node
  • Open Source Channels
    • Toybox
    • DIRSIG Channel
  • Release Notes
    • Rendered.ai Platform
      • Platform Version 1.6.0
      • Platform Version 1.5.0
      • Platform Version 1.4.1
      • Platform Version 1.4.0
      • Platform Version 1.3.2
      • Platform Version 1.3.1
      • Platform Version 1.3.0
      • Platform Version 1.2.6
      • Platform Version 1.2.5
      • Platform Version 1.2.4
      • Platform Version 1.2.3
      • Platform Version 1.2.2
      • Platform Version 1.2.1
      • Platform Version 1.2.0
      • Platform Version 1.1.5
      • Platform Version 1.1.4
      • Platform Version 1.1.3
      • Platform Version 1.1.2
      • Platform Version 1.1.1
      • Platform Version 1.1.0
      • Platform Version 1.0.3
      • Platform Version 1.0.2
      • Platform Version 1.0.1
      • Platform Version 1.0.0
      • Platform Version 0.3.4.4
      • Platform Version 0.3.4.3
      • Platform Version 0.3.4.2
      • Platform Version 0.3.4.1
      • Platform Version 0.3.4
      • Platform Version 0.3.3.1
      • Platform Version 0.3.3
      • Platform Version 0.3.2.2
      • Platform Version 0.3.2.1
      • Platform Version 0.3.2
      • Platform Version 0.3.1.6
      • Platform Version 0.3.1.5
      • Platform Version 0.3.1.4
      • Platform Version 0.3.1.3
      • Platform Version 0.3.1.2
      • Platform Version 0.3.1
      • Platform Version 0.3.0.9
      • Platform Version 0.3.0.8
      • Platform Version 0.3.0.7
      • Platform Version 0.3.0.6
      • Platform Version 0.3.0.5
      • Platform Version 0.3.0
      • Platform Version 0.2.15
      • Platform Version 0.2.14
      • Platform Version 0.2.13
      • Platform Version 0.2.12
      • Platform Version 0.2.11
      • Platform Version 0.2.10
      • Platform Version 0.2.9
      • Platform Version 0.2.8
      • Platform Version 0.2.7
      • Platform Version 0.2.6
      • Platform Version 0.2.5
      • Platform Version 0.2.4
      • Platform Version 0.2.3
      • Platform Version 0.2.2
      • Platform Version 0.2.1
      • Platform Version 0.2.0
Powered by GitBook
On this page
Export as PDF
  1. Development Guides
  2. Ana Software Architecture

Preview

This section describes how to prepare a channel to support previews. In the GUI a preview is generated when you click the preview button in the graph canvas. You can also test preview locally by including the "--preview" flag on the ana command that runs the channel.

To determine if a given run of a channel is in preview mode, you should check the context variable 'preview'. This will be set to True if the channel should generate a preview image. Typically this is done by taking the rendered image and generating a copy called "preview.png". The preview image should be stored in the root of the output directory.

Channels should be optimized so that preview times are minimal. This includes such things as reducing the number of render samples and decreasing the resolution of the image.

Here is an example of a blender channel that generates a preview. This code is in the render node that generates the image. It lowers the sample count to 10, cuts the resolution of the preview image in half, and also doesn't write annotation or metadata if preview is set. Note the node has one input which is a pointer to the AnaScene object.

from anatools.lib.node import Node
import anatools.lib.context as ctx
from PIL import Image, ImageFile

class Render(Node):
     def exec(self):
        ana_scene = self.inputs["Scene"][0]
        # cut the resolution in half
        if ctx.preview:
            bpy.context.scene.cycles.samples = 10
            bpy.context.scene.render.resolution_x = int(bpy.context.scene.render.resolution_x / 2)
            bpy.context.scene.render.resolution_y = int(bpy.context.scene.render.resolution_y / 2)
        # render the image
        bpy.ops.render.render(write_still=True, scene=ana_scene.blender_scene.name)
        # generate preview image
        if ctx.preview:
            filename = f'{ctx.interp_num:010}-{ana_scene.blender_scene.frame_current}-{ana_scene.sensor_name}.png'
            image_file = os.path.join(ctx.output, "images", filename)
            image = Image.open(image_file)
            image.save( os.path.join(ctx.output,"preview.png") )
        else:
            ana_scene.write_ana_annotations()
            ana_scene.write_ana_metadata()
        return {}

PreviousTypical Validation Use CasesNextIn-tool Help

Last updated 8 months ago