LogoLogo
sigopt.comLog In / Sign Up
  • Welcome to SigOpt!
    • SigOpt API Modules
    • Main Concepts
      • Define and Set Up Parameter Space
      • Define and Set Up Metric Space
      • Alternative Experiment Types
  • Advanced Experimentation
    • Multimetric Optimization
    • Metric Thresholds
    • Metric Constraints
    • Metric Failure
    • All Constraints Experiment
    • Multisolution
    • Parallelism
    • Parameter Constraints
    • Prior Beliefs
    • Multitask Experiments
  • Core Module API References
    • Installation and Setup
    • Quick Start
    • API Topics
      • API Tokens and Authentication
      • API Errors
      • Manage Open Suggestions
      • Metadata
      • Pagination
    • API Endpoints
      • Client Detail
      • Experiment Best Assignments
      • Experiment Create
      • Experiment Delete
      • Experiment Detail
      • Experiment Metric Importances
      • Experiment Stopping Criteria
      • Experiment Update
      • Observation Create
      • Observation Batch Create
      • Observation Delete
      • Observation Detail
      • Observation List Delete
      • Observation List
      • Observation Update
      • Queued Suggestion Create
      • Queued Suggestion Delete
      • Queued Suggestion Detail
      • Queued Suggestion List
      • Suggestion Create
      • Suggestion Delete
      • Suggestion Detail
      • Suggestion List Delete
      • Suggestion List
      • Experiment Token Create
      • Organization Detail
      • Suggestion Update
    • API Objects
      • Assignments Object
      • Best Assignments Object
      • Bounds Object
      • Categorical Value Object
      • Client Object
      • Conditional Object
      • Conditions Object
      • Constraint Term Object
      • Experiment Object
      • Metadata Object
      • Metric Object
      • Metric Evaluation Object
      • Metric Importances Object
      • Observation Object
      • Organization Object
      • Pagination Object
      • Parameter Object
      • Parameter Constraint Object
      • Plan Object
      • Plan Period Object
      • Plan Rules Object
      • Prior Object
      • Progress Object
      • Queued Suggestion Object
      • Stopping Criteria Object
      • Suggestion Object
      • Token Object
  • AI MODULE API REFERENCES
    • Installation and Setup
    • Quick Start Tutorials
      • Run Tutorial
      • Project Tutorial
      • AI Experiment and Optimization Tutorial
    • Tracking Your Training Runs
      • Set Up for Example Code
      • Record SigOpt Runs in Jupyter
      • Record SigOpt Runs with Python IDE and SigOpt CLI
      • Record SigOpt Runs with Python IDE
      • View and Analyze the Recorded SigOpt Run
      • Enable Optimization for your SigOpt Runs
    • AI Experiments
      • AI Experiment Set Up
    • Bring Your Own Optimizer
    • XGBoost Integration
      • Installation
      • Tracking XGBoost Training
      • Tuning XGBoost Models
    • HyperOpt
      • Installation
      • User Case
      • API
    • SigOpt Orchestrate
      • Install SigOpt Orchestrate
      • Orchestrate a Tracked Training Run
      • Orchestrate an AI Experiment
      • AWS Cluster Create and Manage
      • SigOpt: Bring Your Own Cluster
      • Dockerfile: Define Your Environment
      • Debugging
      • CLI Reference
    • API Reference
      • Manually create a SigOpt Run
      • Tracking a Run
      • AI Experiment Client Calls
      • Project Client Calls
      • Objects
        • Training Run Object
        • AI Experiment Object
        • Parameter Object
        • Metric Object
      • SigOpt CLI Commands
      • Orchestrate CLI Commands
  • Support
    • Support
    • FAQ
    • Best Practices
      • Setting an experiment budget
      • Reproducibility in SigOpt
      • Uploading data as a Training Run artifact
      • Navigating multiple metrics
Powered by GitBook
On this page
  • 1. Filepath
  • 2. PIL.Image.Image
  • 3. numpy.ndarray
  • 4. matplotlib.figure.Figure
  1. Support
  2. Best Practices

Uploading data as a Training Run artifact

1. Filepath

If a string is provided then this argument will be treated like a filesystem path and the image will be opened and uploaded. The image type will be inferred from the file extension. To follow the code snippet please fetch sigopt_logo.png.

import sigopt
filepath = "./sigopt_logo.png"
run_context = sigopt.create_run(name= "test logging images")
run_context.log_image(image=filepath, name= "retro SigOpt logo”)

2. PIL.Image.Image

If a PIL Image is provided then it will be converted to PNG and uploaded.

This snippet will change the white pixels in the image to purple, save the data to the PIL Image frame, and upload it to the run context.

import PIL
im_frame = PIL.Image.open(filepath)
im_frame_color = im_frame.convert("RGB")
im_data = im_frame_color.getdata()
new_im_data = []
for item in im_data:
  if item[0] > 0:
    new_image.append((110,50,170))
  else:
    new_image.append(item)
im_frame_color.putdata(new_image)
run_context.log_image(image=im_frame_color, name= "purple letters logo”)

3. numpy.ndarray

If a numpy array is provided, the values will be clamped to the range [0, 255] and then cast to unsigned 8-bit integers. The resulting array will be converted to PNG and then uploaded.

In this snippet we reuse the PIL Image frame to log a grayscale, 2D numpy array.

import numpy
run_context.log_image(image=256*(numpy.array(im_frame)>0), name="B&W logo")

4. matplotlib.figure.Figure

If a matplotlib Figure is provided then it will be converted to SVG and uploaded.

Here we log a matplotlib Figure by counting the number of white pixels in each column of the 2D numpy array and plotting the value on the y axis vs the column position.

import matplotlib.pyplot as plt
import matplotlib.axes as axes
pixel_counts = numpy.sum((numpy.array(im_frame)>0), axis=0)
fig = plt.figure()
new_plot = fig.add_subplot(111)
new_plot.plot(pixel_counts, "b--”)
run_context.log_image(image=fig, name="Pixel counts for columns")
PreviousReproducibility in SigOptNextNavigating multiple metrics

Last updated 1 year ago