# upalx-mz/grommets-vision-artificial architecture

> Architecture diagram of the GitHub repository upalx-mz/grommets-vision-artificial, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-08-01). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/upalx-mz/grommets-vision-artificial
- Repository: https://github.com/upalx-mz/grommets-vision-artificial

## Overview

#### Purpose
`grommets-Vision-Artificial` is an industrial machine-vision repository for detecting/classifying grommets and related parts, with PLC/factory simulation assets. The minimal README provides no operating instructions; architecture is inferred from source, model, camera, and automation artifacts.

#### Primary Entry Point
- `src/main.py` is the likely application orchestrator.
- `src/__init__.py` defines the Python package boundary.
- `pyproject.toml` defines the Python project/runtime dependency boundary.

#### Vision and Inference Layer
- `lib/analisys.py` likely contains image-analysis and model-inference logic.
- Pretrained TensorFlow/Keras-style model assets are separated by product/domain:
  - `models/grommets/grommet_model.h5`
  - `models/regco/regco_model.h5`
- Class mappings are stored beside models:
  - `models/grommets/labels.txt`
  - `models/regco/labels.txt`
- `models/modelos.txt` likely provides a model registry or selection list.

#### Camera Acquisition Boundary
- `lib/camaras.py` is the camera/device integration layer.
- It should isolate live image capture from inference, allowing `src/main.py` to pass frames into `lib/analisys.py` without embedding device-specific behavior in model code.

#### Industrial Control and Simulation Integration
- Factory I/O simulation is represented by `assets/Factory/OP180 -OP200 .factoryio`.
- PLC logic/project configuration is represented by `assets/Codesys/PLC Estadia.project`.
- The likely control flow is: camera frame → visual classification/decision → PLC-facing signal or protocol update → Factory I/O simulation/actuation.
- `sample/modbus.py` indicates Modbus is the probable PLC communication protocol and an important external integration boundary.

#### Execution and Validation Examples
- `sample/grommet.py`, `sample/regco.py`, and `sample/regco2.py` appear to exercise model-specific inference paths.
- `sample/sample1.py` and `sample/sample2.py` likely provide general camera/vision experiments.
- These scripts are secondary entry points for manual validation rather than the main runtime.

#### Outputs and Operational Artifacts
- `out/log.txt` is the repository’s persisted runtime/log output location.
- `img/` is the likely image capture, inspection, or visualization artifact directory.
- The architecture depends on local camera hardware, trained `.h5` model files, and optionally a Modbus-connected PLC or Factory I/O/CODESYS simulation environment.

Main entry points: [`lib/analisys.py`](https://github.com/upalx-mz/grommets-vision-artificial/blob/main/lib/analisys.py) (Image analysis), [`src/main.py`](https://github.com/upalx-mz/grommets-vision-artificial/blob/main/src/main.py) (Application orchestrator), [`lib/camaras.py`](https://github.com/upalx-mz/grommets-vision-artificial/blob/main/lib/camaras.py) (Camera acquisition), [`src/__init__.py`](https://github.com/upalx-mz/grommets-vision-artificial/blob/main/src/__init__.py) (src package)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["Python Runtime"]
  node_project["Python project<br/>runtime definition<br/>[pyproject.toml]"]
  node_package["src package<br/>package boundary<br/>[__init__.py]"]
  node_main["Application orchestrator<br/>Python entry point<br/>[main.py]"]
  node_samples["Manual vision samples<br/>validation scripts"]
end

subgraph group_vision["Vision Pipeline"]
  node_camera["Camera acquisition<br/>device adapter<br/>[camaras.py]"]
  node_analysis["Image analysis<br/>inference service<br/>[analisys.py]"]
end

subgraph group_models["Trained Models"]
  node_model_registry["Model selection<br/>model registry<br/>[modelos.txt]"]
  node_grommet_model[("Grommet model<br/>Keras model<br/>[grommet_model.h5]")]
  node_grommet_labels["Grommet labels<br/>class mapping<br/>[labels.txt]"]
  node_regco_model[("Regco model<br/>Keras model<br/>[regco_model.h5]")]
  node_regco_labels["Regco labels<br/>class mapping<br/>[labels.txt]"]
end

subgraph group_industrial["Industrial Integration"]
  node_modbus["Modbus PLC bridge<br/>PLC protocol client<br/>[modbus.py]"]
  node_plc["CODESYS PLC logic<br/>PLC project"]
  node_factory["Factory I/O simulation<br/>factory simulator"]
end

node_images["Inspection images<br/>image artifacts"]
node_log["Runtime log<br/>operational output<br/>[log.txt]"]

node_project -.->|"defines runtime"| node_package
node_package -->|"contains"| node_main
node_main -->|"acquires frames"| node_camera
node_camera -->|"frames"| node_analysis
node_main -->|"orchestrates"| node_analysis
node_model_registry -->|"selects model"| node_analysis
node_grommet_model -->|"inference weights"| node_analysis
node_grommet_labels -->|"class names"| node_analysis
node_regco_model -->|"inference weights"| node_analysis
node_regco_labels -->|"class names"| node_analysis
node_analysis -->|"classification decision"| node_modbus
node_modbus -->|"PLC signals"| node_plc
node_plc -->|"controls simulation"| node_factory
node_main -.->|"captures or visualizes"| node_images
node_main -.->|"writes runtime events"| node_log
node_samples -.->|"exercise capture"| node_camera
node_samples -.->|"exercise inference"| node_analysis

click node_project "https://github.com/upalx-mz/grommets-vision-artificial/blob/main/pyproject.toml"
click node_package "https://github.com/upalx-mz/grommets-vision-artificial/blob/main/src/__init__.py"
click node_main "https://github.com/upalx-mz/grommets-vision-artificial/blob/main/src/main.py"
click node_camera "https://github.com/upalx-mz/grommets-vision-artificial/blob/main/lib/camaras.py"
click node_analysis "https://github.com/upalx-mz/grommets-vision-artificial/blob/main/lib/analisys.py"
click node_model_registry "https://github.com/upalx-mz/grommets-vision-artificial/blob/main/models/modelos.txt"
click node_grommet_model "https://github.com/upalx-mz/grommets-vision-artificial/blob/main/models/grommets/grommet_model.h5"
click node_grommet_labels "https://github.com/upalx-mz/grommets-vision-artificial/blob/main/models/grommets/labels.txt"
click node_regco_model "https://github.com/upalx-mz/grommets-vision-artificial/blob/main/models/regco/regco_model.h5"
click node_regco_labels "https://github.com/upalx-mz/grommets-vision-artificial/blob/main/models/regco/labels.txt"
click node_modbus "https://github.com/upalx-mz/grommets-vision-artificial/blob/main/sample/modbus.py"
click node_plc "https://github.com/upalx-mz/grommets-vision-artificial/blob/main/assets/Codesys/PLC%20Estadia.project"
click node_factory "https://github.com/upalx-mz/grommets-vision-artificial/blob/main/assets/Factory/OP180%20-OP200%20.factoryio"
click node_log "https://github.com/upalx-mz/grommets-vision-artificial/blob/main/out/log.txt"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_project,node_package,node_main,node_samples toneBlue
class node_camera,node_analysis toneAmber
class node_model_registry,node_grommet_model,node_grommet_labels,node_regco_model,node_regco_labels toneMint
class node_modbus,node_plc,node_factory toneRose
class node_images,node_log toneNeutral
```

## Components

### Python Runtime

- [Python project](https://github.com/upalx-mz/grommets-vision-artificial/blob/main/pyproject.toml): runtime definition · Defines the Python dependency boundary. · `pyproject.toml`
- [src package](https://github.com/upalx-mz/grommets-vision-artificial/blob/main/src/__init__.py): package boundary · `src/__init__.py`
- [Application orchestrator](https://github.com/upalx-mz/grommets-vision-artificial/blob/main/src/main.py): Python entry point · `src/main.py`
- **Manual vision samples**: validation scripts · Model-specific and camera/vision experiments.

### Vision Pipeline

- [Camera acquisition](https://github.com/upalx-mz/grommets-vision-artificial/blob/main/lib/camaras.py): device adapter · Isolates live frame capture from inference. · `lib/camaras.py`
- [Image analysis](https://github.com/upalx-mz/grommets-vision-artificial/blob/main/lib/analisys.py): inference service · Runs image analysis and model inference. · `lib/analisys.py`

### Trained Models

- [Model selection](https://github.com/upalx-mz/grommets-vision-artificial/blob/main/models/modelos.txt): model registry · `models/modelos.txt`
- [Grommet model](https://github.com/upalx-mz/grommets-vision-artificial/blob/main/models/grommets/grommet_model.h5): Keras model · `models/grommets/grommet_model.h5`
- [Grommet labels](https://github.com/upalx-mz/grommets-vision-artificial/blob/main/models/grommets/labels.txt): class mapping · `models/grommets/labels.txt`
- [Regco model](https://github.com/upalx-mz/grommets-vision-artificial/blob/main/models/regco/regco_model.h5): Keras model · `models/regco/regco_model.h5`
- [Regco labels](https://github.com/upalx-mz/grommets-vision-artificial/blob/main/models/regco/labels.txt): class mapping · `models/regco/labels.txt`

### Industrial Integration

- [Modbus PLC bridge](https://github.com/upalx-mz/grommets-vision-artificial/blob/main/sample/modbus.py): PLC protocol client · Probable control-signal integration boundary. · `sample/modbus.py`
- [CODESYS PLC logic](https://github.com/upalx-mz/grommets-vision-artificial/blob/main/assets/Codesys/PLC%20Estadia.project): PLC project · `assets/Codesys/PLC Estadia.project`
- [Factory I/O simulation](https://github.com/upalx-mz/grommets-vision-artificial/blob/main/assets/Factory/OP180%20-OP200%20.factoryio): factory simulator · `assets/Factory/OP180 -OP200 .factoryio`

### Other components

- **Inspection images**: image artifacts
- [Runtime log](https://github.com/upalx-mz/grommets-vision-artificial/blob/main/out/log.txt): operational output · `out/log.txt`

## Connections

- Python project → src package: defines runtime
- src package → Application orchestrator: contains
- Application orchestrator → Camera acquisition: acquires frames
- Camera acquisition → Image analysis: frames
- Application orchestrator → Image analysis: orchestrates
- Model selection → Image analysis: selects model
- Grommet model → Image analysis: inference weights
- Grommet labels → Image analysis: class names
- Regco model → Image analysis: inference weights
- Regco labels → Image analysis: class names
- Image analysis → Modbus PLC bridge: classification decision
- Modbus PLC bridge → CODESYS PLC logic: PLC signals
- CODESYS PLC logic → Factory I/O simulation: controls simulation
- Application orchestrator → Inspection images: captures or visualizes
- Application orchestrator → Runtime log: writes runtime events
- Manual vision samples → Camera acquisition: exercise capture
- Manual vision samples → Image analysis: exercise inference
