<jupyter_start><jupyter_text>deeptrack.generatorsThis example introduces the module deeptrack.generators  What is a generatorGenerators are tools for continuously creating new images from a feature series. They are fully Keras compatible, meaning they can serve as the input to a keras model during training. The first argument is the feature to resolve, while the second is a function that extracts labels from an image, given an image as input.<jupyter_code>from deeptrack.generators import Generator

generator = Generator()
from deeptrack.optics import Fluorescence
from deeptrack.scatterers import PointParticle

import numpy as np
import matplotlib.pyplot as plt

optics = Fluorescence(
    NA=0.7,
    wavelength=680e-9,
    resolution=1e-6,
    magnification=10,
    output_region=(0, 0, 128, 128)
)

scatterer = PointParticle(
    intensity=100,        
    position_unit="pixel",
    position=lambda: np.random.rand(2) * 128
)


imaged_scatterer = optics(scatterer)


def get_particle_position(result):
    for property in result.properties:
        if "position" in property:
            return property["position"]

particle_generator = generator.generate(
    imaged_scatterer, 
    get_particle_position, 
    #shape=(128, 128), 
    batch_size=4
)


# generates next batch
particles, positions = next(particle_generator)

for particle, position in zip(particles, positions):
    plt.imshow(np.squeeze(particle), cmap='gray')
    plt.scatter(position[1], position[0], 200, marker='o', facecolors="none", edgecolors="r")
    plt.show()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.08428390367553866, 'fraction_numerical': 0.023447401774397972, 'mean_word_length': 4.579505300353357, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '543634', 'license': 'MIT', 'n_tokens_mistral': 502, 'n_tokens_neox': 468, 'n_words': 144, 'path': 'examples/generators_example.ipynb', 'repo_name': 'Margon01/DeepTrack-2.0', 'size': '1578'}