Other Tools#

While Infinity Core provides a generic interface for communicating with the Infinity API, the Workflows repository includes additional convenience modules to help with synthetic data generation. For example, these modules include:

  • Generator-specific tools for crafting job parameters

  • Tools to analyze and visualize the distribution of job parameters in synthetic data batches (before and after submission to the API).

  • Tools to download and unpack synthetic data from the Infinity REST API.

  • Tools to visualize and analyze downloaded data.

Refer to the example notebooks to see these tools in action.

Tools to Help With Submission#

Sample inputs for a specific generator#

We provide the sample_input function as a convenient way to specify values for parameters you explicitly care about while letting the rest of the parameters be chosen randomly. The random sampling is tailored for each parameter. Note that in the example below, the sample_input function is specific the to visionfit class of generators, and thus is not part of the generic Infinity Core package.

from visionfit.utils.sampling import sample_input
job_params = [
    sample_input(sesh=sesh, num_reps=1, exercise="UPPERCUT-LEFT") for _ in range(10)

Here we have specified values for num_reps and exercise explicitly. However, now, sample_input will randomly sample all of the unspecified parameters for each of the 10 jobs using appropriate distributions.

Visualize job parameters for a batch#

Carefully controlling the statistical distribution of job parameters in a batch is a typical need. Before submitting a batch, you can visualize a list of job parameters to ensure you have the properties you need.

from visionfit.utils.vis import visualize_job_params
job_params = [sesh.sample_input() for _ in range(100)]

Re-run a batch with simple modifications#

A common task is to re-run a previous batch, or a subset of its jobs, with targeted parameter changes. For example, we can re-run a batch of previews that we like as full high resolution videos:

seed_job_params = batch.get_job_params_seeded_for_rerun()
for jp in seed_job_params:
    jp["image_height"] = 512
    jp["image_width"] = 512
high_res_batch = sesh.submit(
    batch_name="high res rerun"

Generate parameter sweeps based on a previous seed#

Another common task is to sweep one or more previous jobs (image or video) across a range of parameters, using the state of the previous job as a seed. You can construct this manually or use some helper functions from visionfit.utils.sampling. For example:

# Re-run the first five seeds from a previous batch of previews, each
# expanded across a range of camera heights.
seed_job_params = batch.get_job_params_seeded_for_rerun()[0:5]
seed_job_ids = [p["state"] for p in seed_job_params]
sweep_params =[{"camera_height": v} for v in np.linspace(1.0, 2.5, 10)]

from visionfit.utils.sampling import expand_overrides_across_each_preview_state
# This will have 5 * 10 = 50 jobs in the expanded batch.
new_batch_params = expand_overrides_across_each_preview_state(
sweep_batch = sesh.submit(
    batch_name="camera height sweep"

Tools for Analysis of Results#

Visualize batch parameters in tabular format#

# Review submitted batch job parameters with dataframe.
df_jp = pd.DataFrame.from_records(batch.job_params)

# Download and visualize results from a batch
download_path = "tmp/results"

from visionfit.utils.vis import summarize_batch_results_as_dataframe
df_results = summarize_batch_results_as_dataframe(download_path)

Visualize batch parameters in graphical format#

Similar to visualize_job_params, we can visualize the parameter distribution data alongside new metadata available from completed results with visualize_batch_results.

from visionfit.utils.vis import visualize_batch_results

Visualize the synthetic data (videos and previews)#

Infinity Workflows also provides utilities to visualize resulting images and videos directly. Visualizations can include keypoint overlays and segmentation information for rich visual analysis of your synthetic data.

# For a batch of previews.
from visionfit.utils.images import get_subdirectories, view_previews
preview_job_paths = get_subdirectories(download_path)
view_previews(random.choices(preview_job_paths, k=20))

# For a batch of videos.
from visionfit.utils.vis import visualize_all_labels
video_path = visualize_all_labels(target_job_path)