semvec/pypi-packages huggingface dataset:
yaml-expressions 0.2.1
Jinja2 templates for yaml. Make dynamic rules and configs.
License: MIT
Keywords: yaml jinja2 exptessions template

# YAML Jinja2 expressions

Renders Jinja2 expressions inside YAML file.

## Install

```
pip install yaml-expressions
```

## Examples

### Load template from file

cfg/cfg.yml:

```yaml
cfg:
  test: "{{test}}"
```

```python
from yex import Yex

yex = Yex('./cfg/')

print(yex.render('cfg.yml', test='passed'))
```

Output: `{'cfg': {'test': 'passed'}}`

### Load template from string

```python
from yex import Yex

result = Yex('test: {{test}}')(test='passed')
# or
result = {'test':'passed'} > Yex('test: {{test}}')
# or
result = Yex('test: {{test}}').render(test='passed')

print(result)
```

Output: `{'test': 'passed'}`

## Another examples

### Describe SEO checklist, generate report

```python
tests_tpl = """
tests:
    title: {{ 20 < (title | length) < 70 }}
    description: {{ 20 < (description | length) < 160 }}"""

report_tpl = """
report: >
    Test results:
      Title: {{ 'ok' if tests.title else 'fail' }}
        ({{ title[:10] }}...)
      Description: {{ 'ok' if tests.description else 'fail' }}
        ({{ description[:10] }}...)
"""

data = {
    'title': 't' * 130,
    'description': 'd' * 120,
}

results = Yex.render_text(tests_tpl, data)
report = Yex.render_text(report_tpl, **results, **data)

print(report.get('report'))
```

Output:

```text
Test results:
  Title: fail
    (tttttttttt...)
  Description: ok
    (dddddddddd...)
```

### Render HTML pages from prepared config

```python
template = """
meta:
{% for k, v in meta.items() %}
  {{ k }}: >-
    {{ v }}
{% endfor %}
data:
{% for k, v in data.items() %}
  {{ k }}: >-
    {{ v }}
{% endfor %}
"""
data = [
    {
        'meta': {
            'title': 'Hello, world 1!',
        },
        'data': {
            'content': """<h1>Wellcome to our site!</h1>
        <p>Glad to see you!</p>
        """
        }
    },
    {
        'meta': {
            'title': 'Hello, world 2!',
        },
        'data': {
            'content': """<h1>Wellcome to our site!</h1>
        <p>Glad to see you!</p>
        """
        }
    },
]
content_page_template = """<title>{{meta.title}}</title>
<div>{{data.content}}</div>"""
content_page = Yex(content_page_template)
for cfg in Yex(template).generate(data):
    print(content_page.render_content(cfg))
```

Output:

```text
<title>Hello, world 1!</title>
    <div><h1>Wellcome to our site!</h1>
    <p>Glad to see you!</p>
    </div>
<title>Hello, world 2!</title>
    <div><h1>Wellcome to our site!</h1>
    <p>Glad to see you!</p>
    </div>
```
dlclib 1.1.0
a wrapper of DeepLabCut for its ease of use.
License: MIT
Requires Python: >=3.6

# python-dlclib

A wrapper of DeepLabCut for its ease of use.

`dlclib` is supposed to work with almost all single-camera setups of all DLC versions.

## Installation

It is better building your DeepLabCut environment first, before running:

```bash
$ pip install dlclib
```

## Classes

### `dlclib.estimate.TFSession`

A thin wrapper over the DeepLabCut inference network based on TensorFlow.

- `session = TFSession.from_config(cfg)` will return a `TFSession` object
  using the specified `config.yaml` file of the DeepLabCut project.
- `session.get_pose(image)` will return a `numpy.ndarray` corresponding to the estimation.
  for a batch-processing network, use a list of images, or a 4-D uint8 array
  whose axis 0 correspond to indexes of images.
- `session.open_writer(path)` opens a CSVWriter at the specified path (see below).

### `dlclib.posture.PostureMapper`

A utility class that maps the output of `TFSession` to a dictionary.
Note that the current implementation:

- does not care anything about conversion speed.
- currently only supports non-batch models.

- `mapper = PostureMapper.from_config(cfg)` will return a `PostureMapper` object
  using the specified `config.yaml` file of the DeepLabCut project.
- `posedict = mapper.map(pose)` receives the output of `TFSession.get_pose()`,
  and returns a dictionary. `posedict[part]` is a named tuple that has `x`, `y` and `prob` attributes.

### `dlclib.writer.CSVWriter`

A simple class for writing the estimation into a CSV file.
This class _does_ support batch-processing networks.

- `writer = session.open_writer(path)` from a `TFSession` object initializes the writer
  associated with the inference session.
- For every video frame, you can call `writer.push(frame)`. It automatically calls
  `TFSession.get_pose()` internally, and writes its outputs into the file.
- Calling `writer.flush()` will flush the pended video frames (in case of batch modes;
  it does not wait for more frames and runs `get_pose()` to writes the estimation).
- Calling `writer.close()` will flush its internal buffer, close the file and invalidates itself.
  You can keep using the originating `TFSession` object.

This class supports the context-manager model, so you can write:

```python
with session.open_writer(path) as out:
    for frame in video_frames:
        out.push(frame)
```

## License

2020-2021 Keisuke Sehara, the MIT License
timedcapture 0.3.2
a cython-based module to achieve on-time capture through V4L2.
License: MIT
Requires Python: >=3.6

# timedcapture

a cython-based module to achieve on-time video capture through V4L2.

For a general usage, refer to [USAGE](https://github.com/gwappa/python-timedcapture/blob/master/USAGE.md).

## Prerequisites

**IMPORTANT NOTE**: the current implementation only allows 16-bit grayscale acquisition.
**IMPORTANT NOTE**: there is no functionality that controls the frame rate. Frame-capture timings must be controlled elsewhere, either using software or hardware timers.

- The library is tested on Ubuntu 18.04 LTS, but it is supposed to work on any Linux environment that runs V4L2.
- Please note that the library is optimized for cameras from [ImagingSource](https://www.theimagingsource.com/).
  By using devices from other manufacturers, you will not have control over functionalities such as:
  - 1 microsecond-order exposure control (V4L2 only allows the order of 10 microseconds)
  - auto-gain/manual-gain switch (the gain control will be totally manual- or auto-controlled)
  - trigger modes (by default, only the free-running mode will be allowed)
  - "strobe" output
  These settings must be configured elsewhere.

## Installation

For the time being, we only provide the source distribution on PyPI.
You will need a working Cython and Numpy combination **pre-installed**.

```bash
$ pip install numpy>=1.19 cython>=0.29 # or: "conda install numpy cython", in case you use Anaconda
$ pip install timedcapture
```

## License

2020 Keisuke Sehara, the MIT License.