You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+20-6Lines changed: 20 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,17 +1,17 @@
1
1
# Apex Grid
2
2
3
-
## Live app
3
+
## 🚀 Live app
4
4
5
5
- Production (deployed): <https://apex-grid-transformer-tracker.vercel.app/>
6
6
- Want to run everything locally? Use the instructions in `Instructions.md`.
7
7
8
-
## Auth
8
+
## 🔒 Auth
9
9
10
10
- Log in with `user1`..`user5` using the same value as the password (e.g., `user3`/`user3`).
11
11
- Backend handles user creation/verification on first successful login at `/api/login`.
12
12
- The UI shows “Logged in as username” and records `uploadedBy` for created/updated entities and images.
13
13
14
-
## Features
14
+
## 💫 Features
15
15
16
16
- Transformers and Inspections CRUD (App Router API routes with Prisma)
17
17
- Image uploads stored as base64 in the DB; baseline images can be added/removed
@@ -25,7 +25,7 @@
25
25
- Cascade delete: deleting a Transformer removes its Inspections
26
26
- Now available in dark mode!
27
27
28
-
## Project structure (high level)
28
+
## 🤖 Project structure (high level)
29
29
30
30
-`frontend/` — Next.js frontend
31
31
-`app/` — App Router pages
@@ -41,7 +41,7 @@
41
41
-`repository/` — Spring Data JPA repositories
42
42
-`service/` — business logic services
43
43
44
-
## Project Description
44
+
## 📖 Project Description
45
45
46
46
- The project has 2 main pages: transformers and inspections.
47
47
- The transformers page allows users to create, read, update, and delete (CRUD) transformer records.
@@ -55,7 +55,21 @@
55
55
- An AI model can be used to analyze and generate insights from the thermal images of transformers.
56
56

57
57
58
-
## For Improvements
58
+
## 🔁 CI / CD
59
+
60
+
This project uses automated deployments for both frontend and backend:
61
+
62
+
- Frontend (Next.js) — deployed on Vercel
63
+
- The `frontend/` directory is connected to Vercel via the GitHub integration. Pushes to `main` (or PR merges depending on your Vercel settings) trigger Vercel builds and automatic deployments of the site.
64
+
65
+
- Backend (Spring Boot) — deployed on Render via DockerHub
66
+
- A GitHub Actions workflow builds the backend and pushes a Docker image to Docker Hub. See `.github/workflows/docker-image-deployed.yml` for the workflow (it sets up Java, runs `mvn -DskipTests package`, builds the image, and pushes it to Docker Hub).
67
+
- The workflow expects the following GitHub Secrets to be configured in this repository:
68
+
-`DOCKERHUB_USERNAME` — Docker Hub account name
69
+
-`DOCKERHUB_TOKEN` — Docker Hub access token or password
70
+
- Docker Hub is configured with a repository that Render watches. When the image is pushed, Docker Hub calls the Render deploy hook which triggers Render to deploy the new container image.
71
+
72
+
## 🤗 For Improvements
59
73
60
74
- Feel free to open issues or submit PRs for any bugs, improvements, or new features.
61
75
- For your own use, you are free to customize the project as needed.
Copy file name to clipboardExpand all lines: Working.md
+20-2Lines changed: 20 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -115,8 +115,26 @@
115
115
- Triggered by `PUT /api/inspections/{id}/boxes/bulk` (unless the caller sets `tuneModel=false`).
116
116
- Archives the previous AI snapshot via `archivePreviousAnalysis`, then records a `ParameterFeedback` row capturing AI/user box counts, diffs, serialized snapshots, and notes.
117
117
- Writes the candidate image to disk, computes added/removed box sets (tolerant to ±0.5 px), and builds a payload with previous/final boxes, faults, annotators, comments, box tolerance, and the current parameter snapshot.
118
-
- Invokes `backend/AI/tune_parameters.py`, which measures HSV statistics for each added/removed box and suggests parameter deltas (e.g., relax warm thresholds for missed hotspots, tighten thresholds for false positives). Small deltas (<1e-6) are filtered out.
119
-
- Applies suggested deltas through `AiParameterService.adjustValue`, which clamps to configured min/max and persists to `ai_model_parameters` (Postgres). Updated values are immediately cached and will be used by subsequent analyses.
118
+
- Invokes `backend/AI/tune_parameters.py`. The tuner runs a deterministic, heuristic adjustment routine based on per-box HSV statistics and the current parameter snapshot. Key points:
119
+
- Input: the candidate PNG plus a JSON payload containing `parameters` (current values), `addedBoxes` and `removedBoxes` (arrays of `[x,y,w,h]`). The script computes a global `mean_value` from the candidate image's V channel and then measures each box.
120
+
- Per-box measurements (from `measure_box`) returned for each box include: `pixel_count`, `area_ratio` (box area / image area), `mean_saturation`, `mean_value`, `mean_delta_value` (V − global mean), `warm_fraction` (fraction of pixels whose hue is inside the warm window), `mean_hue` (circular mean in [0,1]) and `max_value`.
- For `added` boxes (human labeled hotspots that the AI missed) the tuner assumes thresholds are too strict. It decreases thresholds to make detection more permissive:
126
+
- If `warm_sat_threshold - mean_saturation > SATURATION_MARGIN` then `warm_sat_threshold` is decreased by delta = -min(0.05, max(0.005, sat_diff * 0.5)).
127
+
- Equivalent logic applies to `warm_val_threshold` and `contrast_threshold` using `mean_value` and `mean_delta_value`.
128
+
- If `min_area_pixels` is larger than the observed `pixel_count`, it is reduced with a bounded step (delta = -min(50.0, max(5.0, pixel_diff * 0.25))).
129
+
- If the observed area ratios are smaller than `min_area_ratio`, the script reduces `min_area_ratio` by a small step.
130
+
- If the box's `warm_fraction >= 0.5`, tune the hue window by nudging `warm_hue_low` up or `warm_hue_high` down toward the measured `mean_hue` (bounded by `HUE_STEP`).
131
+
- For `removed` boxes (AI boxes the user removed) the tuner assumes thresholds are too permissive. It increases thresholds to tighten detection:
132
+
- If `mean_saturation - warm_sat_threshold < -SATURATION_MARGIN` then `warm_sat_threshold` is increased by a bounded delta (making it harder to count a pixel as warm).
133
+
- Similar symmetric adjustments are applied for `warm_val_threshold`, `contrast_threshold`, `min_area_pixels` and `min_area_ratio` (using slightly different step factors and bounds).
134
+
- Hue adjustments mirror the added-case logic but move the hue bounds away from the problematic `mean_hue`.
135
+
- Update bookkeeping: updates are accumulated per-parameter (the `apply` helper) and tiny deltas (< 1e-6) are filtered out before returning.
136
+
- Output: the script prints a JSON object containing `parameter_updates` (map of parameter → delta), `notes` (a short summary string), and counts (`addedCount`, `removedCount`).
137
+
- The backend receives these suggested deltas, then `AiParameterService.adjustValue` clamps each new value to configured min/max, persists the update to `ai_model_parameters` (Postgres), and refreshes the in-memory cache so subsequent analyses immediately use the new parameters.
-`DELETE /api/inspections/{id}/boxes?x=&y=&w=&h=` removes a box by geometry (with small tolerance) and updates `faulttypes` accordingly.
116
116
-`POST /api/inspections/{id}/clear-analysis` clears `imageurl`, `boundingboxes`, `faulttypes`, and `lastanalysisweather`.
117
117
118
+
## AI Tuning Feedback Loop (`ParameterTuningService`)
119
+
120
+
- Triggered by `PUT /api/inspections/{id}/boxes/bulk` (unless the caller sets `tuneModel=false`).
121
+
- Archives the previous AI snapshot via `archivePreviousAnalysis`, then records a `ParameterFeedback` row capturing AI/user box counts, diffs, serialized snapshots, and notes.
122
+
- Writes the candidate image to disk, computes added/removed box sets (tolerant to ±0.5 px), and builds a payload with previous/final boxes, faults, annotators, comments, box tolerance, and the current parameter snapshot.
123
+
- Invokes `backend/AI/tune_parameters.py`. The tuner runs a deterministic, heuristic adjustment routine based on per-box HSV statistics and the current parameter snapshot. Key points:
124
+
- Input: the candidate PNG plus a JSON payload containing `parameters` (current values), `addedBoxes` and `removedBoxes` (arrays of `[x,y,w,h]`). The script computes a global `mean_value` from the candidate image's V channel and then measures each box.
125
+
- Per-box measurements (from `measure_box`) returned for each box include: `pixel_count`, `area_ratio` (box area / image area), `mean_saturation`, `mean_value`, `mean_delta_value` (V − global mean), `warm_fraction` (fraction of pixels whose hue is inside the warm window), `mean_hue` (circular mean in [0,1]) and `max_value`.
- For `added` boxes (human labeled hotspots that the AI missed) the tuner assumes thresholds are too strict. It decreases thresholds to make detection more permissive:
131
+
- If `warm_sat_threshold - mean_saturation > SATURATION_MARGIN` then `warm_sat_threshold` is decreased by delta = -min(0.05, max(0.005, sat_diff * 0.5)).
132
+
- Equivalent logic applies to `warm_val_threshold` and `contrast_threshold` using `mean_value` and `mean_delta_value`.
133
+
- If `min_area_pixels` is larger than the observed `pixel_count`, it is reduced with a bounded step (delta = -min(50.0, max(5.0, pixel_diff * 0.25))).
134
+
- If the observed area ratios are smaller than `min_area_ratio`, the script reduces `min_area_ratio` by a small step.
135
+
- If the box's `warm_fraction >= 0.5`, tune the hue window by nudging `warm_hue_low` up or `warm_hue_high` down toward the measured `mean_hue` (bounded by `HUE_STEP`).
136
+
- For `removed` boxes (AI boxes the user removed) the tuner assumes thresholds are too permissive. It increases thresholds to tighten detection:
137
+
- If `mean_saturation - warm_sat_threshold < -SATURATION_MARGIN` then `warm_sat_threshold` is increased by a bounded delta (making it harder to count a pixel as warm).
138
+
- Similar symmetric adjustments are applied for `warm_val_threshold`, `contrast_threshold`, `min_area_pixels` and `min_area_ratio` (using slightly different step factors and bounds).
139
+
- Hue adjustments mirror the added-case logic but move the hue bounds away from the problematic `mean_hue`.
140
+
- Update bookkeeping: updates are accumulated per-parameter (the `apply` helper) and tiny deltas (< 1e-6) are filtered out before returning.
141
+
- Output: the script prints a JSON object containing `parameter_updates` (map of parameter → delta), `notes` (a short summary string), and counts (`addedCount`, `removedCount`).
142
+
- The backend receives these suggested deltas, then `AiParameterService.adjustValue` clamps each new value to configured min/max, persists the update to `ai_model_parameters` (Postgres), and refreshes the in-memory cache so subsequent analyses immediately use the new parameters.
143
+
118
144
## Known bugs / limitations
119
145
120
146
- Alignment fragility: SIFT may fail on low‑texture or uniform images; homography requires sufficient matches. We fall back to unaligned comparison.
0 commit comments