0% found this document useful (0 votes)
12 views16 pages

AI-Driven Snakebite First-Aid System

Design Process
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views16 pages

AI-Driven Snakebite First-Aid System

Design Process
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Deep learning - Design Process

Project overview: The First-aid (CPR) Assistant for Snakebite is a healthcare support system that helps
non-professionals respond quickly to snakebite accidents. An edge camera kit captures images of the wound
and, if possible, the snake. On-device AI analyzes the wound to classificate whether it is poisoned or not,
while the device forwards the wound image, snake photo, and bite timestamp to a central server. Bystanders
add victim details (age, weight, symptoms) through a website. The server evaluates wound condition, snake
type (optional), and symptoms to assign a danger level. If critical, it alerts nearby hospitals to prepare
treatment. Meanwhile, the website provides instant first-aid instructions, symptom tracking (manually), and
GPT-powered guidance (based on the central result), escalating to direct contact with medical staff when
urgent.

Main Goal For Deep learning process:


- (MG1) Enable quick and real-time on-site triage — Quickly outdoor wound classification the
likelihood of venomous snakebite and capture essential incident data (snake).
- (MG3) Ensure accurate central analysis — Use advanced AI to identify wound condition (snake
species if possible), assess wound severity, and evaluate risks.
- (MG4) Standardize wound evaluation — Apply objective and consistent criteria for assessing bite
conditions.

Task Assignment:
+ Thành Khoa (Leader): Project overview, and Step 1 - Problem Definition & Success Criteria
+ Châu Huy : Step 2 - Data Collection, Splits & Preprocessing, step 4 - Training Setup
+ Quang Thắng: Step 3 - Training Setup, Step 7 Deployment (Similar Edge AI course task)
+ Bảo Khánh: Step 5 - Evaluation & Validation, Step 6 - Model Optimization

Step 1 - Problem Definition & Success Criteria


1.1 Model task: Outdoor wound classification
1.2 Output: Decide “poisoned / not poisoned” classes; For Central/Server model, also estimate risk
level
1.3 Success Criterial:
- Edge model (lightweight, real-time triage) - MG1
+ Target latency: ≤ 2–5 s per image (single-thread CPU, input size 224–320
px).
+ Evaluate metrics for classification function:
● Accuracy: ≥ 70% (goal 75–85%)
● F1-score (macro or positive-class F1): ≥ 0.75 (goal 0.75–0.84)
● ROC-AUC: ≥ 0.80 (goal 0.80–0.88)
● Recall / Sensitivity (for “poisoned / not poisoned” class): ≥ 0.85
(minimum 0.80 if necessary) prioritize recall over precision.
● Precision (for “poisoned / not poisoned”): acceptable ≥ 0.60
(tradeoff allowed to keep recall high)
+ Measurement / Test procedure [Link]
022-06096-y
● Test set composition: hold-out set of ≥ 500 wound images (if
possible) containing both venomous and non-venomous/other
wounds. Ensure diversity (skin tones, lighting, wound
dressings).
● Labeling: ground-truth labels from clinician review (at least 2 independent raters; resolve
disagreements by third rater). Record inter-rater agreement (Cohen’s kappa).
● Failure policy: if model confidence < 0.6 on critical outputs (bite/venomous), mark case
for central review.
- Central/Server classification model (larger, higher accuracy) - (MG2 + MG3)
+ Target latency: ≤ 5–10 s per image (GPU/CPU server environment).
+ Evaluate metrics for classification function:
● Accuracy: ≥ 85% (goal 88–95%)
● F1-score: ≥ 0.86 (goal 0.86–0.94)
● ROC-AUC: ≥ 0.92 (goal 0.92–0.98)
● Recall / Sensitivity (for “poisoned / not poisoned”): ≥ 0.93
(minimum 0.90)
● Precision (for “poisoned / not poisoned”): ≥ 0.75
● Calculate the risk lever (low, medium, high) based on the confident score (and Snake
types if available)
+ Measurement / Test procedure
● Test set composition: curated, clinically-verified hold-out set
≥1,500–3,000 cases (images + symptom metadata + confirmed
clinical outcome where possible). Include cross-site samples to
test generalization.
● Labeling / ground truth: hospital/clinical records (e.g., antivenom administered, clinical
diagnosis) + expert image review. Use multiple clinicians to label; compute inter-rater
reliability.
● Robustness checks: evaluate per-subgroup performance (skin tone, lighting, device types,
geographies), adversarial / out-of-distribution examples, and stratify results by time-
since-bite.
1.4 Establish constraints & baseline
- Hardware: Raspberry Pi 4 (ARM Cortex-A72), 1 to 4GB RAM, about 8GB of memory, and support
2.4GHz Wi-Fi Connectivity.
- Edge classification model (lightweight, real-time triage):
+ Target latency: ≤ 2–5 s per image (single-thread CPU, input size 224–320
px).
+ Memory footprint: ≤ 300 MB total (including Python runtime, model,
pre/post-processing).
+ Model size (on-disk): ≤ 25–50 MB quantized (preferably 10–20 MB with
int8 quantization).
+ Priority: Low latency for immediate triage, acceptable trade-off with accuracy.
- Central/Server classification model (larger, higher accuracy):
+ Target latency: ≤ 5–10 s per image (GPU/CPU server environment).
+ Model size (on server): Flexible — up to 200–300 MB if necessary (less constrained).
+ Primary objective: Maximize accuracy and robustness (re-evaluation, snake recognition, wound
severity analysis).
- Model baselines & candidates:
+ Edge classification: MobileNetV2 / MobileNetV3 Small (224 px), EfficientNet-Lite.
+ Central/Cloud refinement: Larger backbones such as EfficientNet-B3/B4, UNet++, or DeepLabV3+
with ResNet-50.
- Deployment formats:
+ Train in google Colab (use PyTorch or TensorFlow)
+ Export to TFLite (int8 quantization) for Raspberry Pi 4 CPU inference.

Step 2 - Data Collection, Splits & Preprocessing


2.1 Data Collection

Dataset Objective Number of Advantages Disadvantages


Images

1. Kaggle: Snake species ~7,000 Diverse species, No wound images


Preprocessed Snake recognition images already preprocessed
Images

2. Roboflow: Detect wounds + ~1,200 Includes bounding Small scale


Snakebite Detection snake species images boxes for wounds and
System snakes

3. Roboflow: Snake Wound detection ~800 Focused on wound Only wounds, no


Bite Detection images detection snakes

2.2 Data Splits

Training Set (70%)

● Purpose: Train the model to learn both basic and complex patterns.
● Characteristics:
○ ~5,600 images in total.
○ Diverse content: includes wound images and snake photos from all three datasets.
○ Strong data augmentation applied to improve robustness.
○ Model weights are updated based on the loss calculated from this set.

Validation Set (15%)


● Purpose: Hyperparameter tuning and overfitting prevention.
● Characteristics:
○ ~1,200 images.
○ No augmentation applied (kept intact for objective evaluation).
○ Used for early stopping during training.
○ Metrics tracked: accuracy, precision, recall, and F1-score.

Test Set (15%)

● Purpose: Final evaluation of the model’s generalization ability.


● Characteristics:
○ ~1,200 images.
○ Used only once after training is fully completed.
○ Represents real-world data that the model is expected to encounter.
○ Confusion matrix computed for detailed error analysis.

Reasons:

● 70% Training: A sufficiently large portion is required for the model to effectively learn complex
and varied features, such as snake species, wound characteristics, and environmental
backgrounds.
● 15% Validation: Provides enough data to tune hyperparameters and apply early stopping, while
still keeping most of the data for training. This balance helps ensure the model generalizes well.
● 15% Test: Maintains a fair and representative portion of unseen data to evaluate the final
performance of the model under real-world conditions.

2.3 Data Preprocessing


- Representative Data: Combine 3 datasets to cover both wounds and snake species

- Normalization

Purpose: Standardize pixel values to a normal distribution (mean, std) for more stable model training.

Setup: Since pre-trained models are used on ImageNet:

● PyTorch: [Link]()

○ Normalizes pixel values based on ImageNet mean/std.


○ Ensures input data matches the same distribution as the pre-trained model, leading to
faster and more stable convergence.

● TensorFlow: [Link]() — normalization by mean/std

○ Scales pixel values to [0,1], then normalizes using ImageNet statistics.


○ Makes data processing easier and avoids inconsistencies in value ranges.

- Augmentation
Purpose: Increase dataset diversity and reduce overfitting.

When to apply: Mandatory if the dataset has fewer than 5,000 images.

Transformations used:

● Rotation (±15°): simulates viewpoint changes.

○ [Link]() → randomly rotates images within a degree range,


helping the model generalize across perspectives.

● Horizontal/Vertical Flip: mirrors images.

○ [Link]() (PyTorch) / [Link].random_flip_left_right


(TensorFlow) → improves robustness when objects appear flipped.

● Color Jitter: alters brightness, contrast, and saturation.

○ [Link]() → helps the model adapt to various lighting conditions.

● Random Crop/Resize: simulates zoom or camera shifts.

○ [Link]() (PyTorch) / [Link].random_crop() → improves


tolerance to different zoom levels and object positions.

Step 3 - Model Selection (choose an initial architecture) (1) (3)


Model Advantages Disadvantages Trade-off
YOLOv8
real-time object detection
& segmentation for bite
- High speed, real-time
region localization and - Difficult to detect small
processing (~81 FPS).
snake detection in scene objects in images.
- Unified framework for Real-time speed trades off
images(labelling). - Requires large
object detection and with detailed sorting
Real-Time Detection and computational resources
segmentation. accuracy. Suitable for
Classification of for training.
- Good balance between positioning tasks (bites,
Venomous and Non - Detailed classification
accuracy and speed, snakes) rather than
Venomous Snakes using accuracy may be lower
suitable for diverse detailed snake species
YOLOv8 (Mane et al., than that of a model that
hardware. classification.
2025) specializes in
- Effective with obscured
https:// classification.
objects.
[Link]/
science/article/abs/pii/
S1051200424005888
EfficientNet-B0 - High computational - Classification is only High classification
(high-performance performance, optimized performed, with no ability accuracy comes at the
CNN model, ~237 architecture. to detect and locate expense of handling only
layers with ~5.3 - Very high accuracy objects in a complex pure classification
million
parameters). The (~94%) on specialized scene. problems. A pipeline
model was datasets (SnakeCLEF). - Pretreatment is required system is needed in
pretrained on
ImageNet and
fine-tuned on the
SnakeCLEF 2021
dataset (772
species, 409,679
images globally).
The results
achieved an
accuracy of ~94%
(F1≈95.9%).Iguerna conjunction with an
ne, M., Ouzziki, M., to cut the solid/bite
Es-Saady, Y., Hajji, - Suitable for pre-cropped object detection model
container before being
M. E., Lansari, A., & image classification. (such as YOLOv8) to
included in the model.
Bouazza, A. (2025). work effectively.
Deep Learning-
Based Snake
Species
identification for
enhanced
snakebite
Management. AI,
6(2), 21.
[Link]
6020021.
Ensemble - Extremely high - Very high computational Maximum precision
ResNeSt/ResNeXt/ResN synthesis accuracy complexity, slow trades off with speed and
et (91.6%) thanks to the inference time, difficult to complexity. Suitable for
Snake species combination of the power deploy in real-time the in-depth classification
identification (fine- of multiple models. application. phase after the solid-
grained classification) for - Minimization of bias - Large resource containing image area has
SnakeCLEF 2021. Type: and variance, strong requirements for memory been identified.
CNN (enhanced ResNet). generalization. and processing power.
Architecture: - Efficiency with fine-
Combination of multiple grained classification
convolutional ResNet between species with
networks including similar morphology.
ResNeSt-200, ResNeXt-
101, ResNet-101, etc.
(ResNeSt-200 is 200
layers; ResNet-101 is 101
layers). Model trained
from checkpoint
ImageNet and multi-
architecture ensemble,
while eliminating species
predictions that do not
match the observed
country. Achieved 91.6%
accuracy on the test set.
Hu, F., Wang, P., Li, Y.,
Duan, C., Zhu, Z., Wang,
F., Zhang, F., Li, Y., &
Wei, X.-S. (2023). Watch
out Venomous Snake
Species: A Solution to
SnakeCLEF2023.
Unpublished Conference
Paper. School of
Computer Science and
Engineering, Nanjing
University of Science and
Technology, Nanjing,
China.

ConvNeXt-V2 + CLIP
metadata – Global snake
species recognition
incorporating geolocation
information. Type: CNN
(ConvNeXt) combined
with visual-linguistic
model. Architecture:
ConvNeXt-V2 backbone
(augmented version of
ConvNeXt, including 4
modern CNN stages)
- Integration of metadata - Depends on the
combined with metadata
(e.g. geography) greatly availability and accuracy Increase factual accuracy
processing sub-network
improves accuracy by of metadata. If the by sacrificing reliance on
(CLIP encoder for
removing species that do geographic information is additional data. The
location information).
not occur in that area. wrong, the results can be optimal solution requires
Uses Real-World
- Very practical for negatively affected. an accurate geographic
Weighted CE loss and
practical applications - The architecture is more information collection
post-processing to assign
where location complex due to multi- system.
high weights to venomous
information is available. modal processing.
species. Achieves overall
F1 score of ~91.3%.
Chamidullin, R., Šulc, M.,
Matas, J., & Picek, L.
(2023). A Deep Learning
Method for Visual
Recognition of Snake
Species. Unpublished
conference paper. Faculty
of Electronics, Czech
Technical University in
Prague.

Vision Transformer - Unprecedented - Training data Global scale and scope


(ViT) taxonomic coverage: challenges: The image come at the expense of
Bolon, I., Picek, L., The model was able to data (386,006 images) complexity and focus.
Durso, A. M., classify 772 snake has a large imbalance in The model aims to
species (198 venomous the number of samples identify a very large
Alcoba, G., Chappuis, and 574 non-venomous) between species and a number of species
F., & De Castañeda, from 188 countries, geographical bias (77% worldwide, but this
R. R. (2022). An with an average of the images come results in uneven data
artificial intelligence accuracy of 96.0% by from the US and and can reduce
species and 99.0% by Canada, while Asia and accuracy for specific
model to identify
genus. Africa – where the regions compared to a
snakes from across burden of snakebites is model well trained for
the world: - High performance on high – only account for that region.
Opportunities and similar species: The a small proportion).
challenges for global model demonstrated the
health and ability to accurately - The impact of “noisy”
herpetology. PLoS discriminate between data: About 13% of the
Neglected Tropical pairs of data from Flickr may
Diseases, 16(8), morphologically similar contain incorrect labels
e0010647. venomous and non- or non-snake images
[Link] venomous snake (e.g., snakes in
species in Southeast captivity, habitat
1/[Link].001064
Asia and sub-Saharan images), which can
7 Africa, which is affect the purity of the
important for clinical model.
applications.
- Being a pure
- Foundation for a classification model:
global system: The Like EfficientNet-B0,
study lays the this model only
foundation for snake performs image
identification support classification, meaning
systems that can be it requires pre-cropped
deployed at global, input images containing
regional or national only the snake. It is not
scales. capable of
automatically detecting
and localizing (object
detection) snakes in a
complex scene image.

After analyzing the above 5 AI models, my team chose the following 2 models for our project:

- YOLOv8 (for Detection and Location task)


- Snake-DETR (for Detailed Classification task)
Reasons for choosing YOLOv8
Practical advantages for urgent applications: YOLOv8 is designed for very high real-time processing
speed, which is vital in an emergency medical situation such as a snake bite. The user can take a
panoramic image and the model immediately localizes the snake and/or bite, saving valuable time.
Suitable for mobile hardware: YOLOv8 has lightweight variants that strike a good balance between speed
and accuracy, allowing for potential deployment on mobile or edge devices - suitable for rural areas
where snake bites are common.

Additional reasons (based on general analysis): Although comparisons show that YOLOv8 may have
somewhat lower accuracy than two-stage architectures such as Mask R-CNN in some problems, in the
context of urgent applications, speed is the top priority. Quickly determining “there is a snake in the
image” and its location is a little more important than waiting a little longer for a little higher accuracy.

Reasons for choosing Snake-DETR


Outstanding performance in complex environments: A recent study (2025) of Snake-DETR, an improved
model based on RT-DETR, shows that it outperforms existing models (including YOLOv9) in detecting
snakes in complex natural environments. Specifically, Snake-DETR achieves a precision of 97.66% and a
mAP@0.5 of 95.23%, while maintaining a processing speed of 43.5 frames/second for real-time response.

Specially designed for snake detection: Unlike general models, Snake-DETR is specifically optimized to
handle challenges such as camouflaged snakes, partially occluded snakes, and subtle differences between
species (fine-grained detection). This makes it a more powerful and specialized choice than ResNet
ensemble or ConvNeXt-V2+CLIP models that focus only on cropped image classification.

Step 4 - Training Setup

YOLOv8 — Detection & Localization task


Main task: detect and localize bite wounds and snakes(if available) in images (bounding boxes;
optional segmentation masks).

4.1 Loss functions

● Bounding-box regression loss (CIoU / DIoU / GIoU) — optimize box location & shape
to match wound/snake regions precisely.
● Classification loss (object class) — usually BCEWithLogitsLoss (numerically stable
BCE + sigmoid) — task: predict object classes inside boxes (e.g., snake / hand /
background).
● Objectness / confidence loss — in YOLO family this is commonly another BCE term
that predicts whether a predicted box contains an object (use the same
BCEWithLogitsLoss).

● Segmentation (optional) — BCE + Dice Loss for mask supervision (task: precise
pixel-level wound mask).

4.2 Optimization strategy


● AdamW —Provides stable weight updates and fast convergence.
● SGD + momentum — Improves gradient stability during training.
● CosineAnnealingLR — Adjusts learning rate cyclically to avoid local minima.

4.3 Training monitoring

● TensorBoard — Tracks mAP, precision-recall curves, training/validation loss, and


detects overfitting.

4.4 Early stopping & checkpoints

● EarlyStopping: Halts training when validation loss does not improve.


● Checkpoint ([Link]): Saves the model with the best performance.
Ultralytics supports checkpoint saving ([Link], [Link]) and resume
Model Training with Ultralytics YOLO - Ultralytics YOLO Docs

Implementation / reference

Ultralytics YOLOv8 (implementation, training CLI/API, checkpointing):


[Link] or [Link]

Snake-DETR — Detailed classification & fine-grained detection task


Main task: fine-grained species classification (Top-1/Top-k), plus risk categorization (venomous
vs non-venomous).

Loss functions

● Hungarian matching (set-based loss) — task: assign predicted queries to ground-truth


objects before computing losses (DETR’s bipartite matching).

● Classification loss: CrossEntropyLoss for species / risk class —task: fine-grained


species label.
● Bounding box loss: L1Loss (regression) + GIoU (or DIoU/CIoU) — task: refine box
coordinates when DETR is used for detection.

Optimization strategy

● AdamW — recommended for transformer backbones; weight decay helps regularize.


● StepLR / CosineAnnealingLR — Reduces learning rate progressively to improve
generalization.

Training monitoring
● TensorBoard / Weights & Biases: Tracks training/validation accuracy, F1-score, and
confusion matrix for class imbalance analysis.

Early stopping & checkpoints

● EarlyStopping: Stops training when no improvement is observed for N epochs.


EarlyStopping — PyTorch | Keras EarlyStopping
● Checkpoint ([Link]): Saves the best-performing Snake-DETR model.

Implementation / reference

[Link] (includes set-matching and loss code).

—Problems when training—

Overfitting

Issue: The model learns training data too precisely, resulting in poor generalization to unseen
data.

Solutions:

● Apply regularization (L1, L2).


● Use Dropout to reduce reliance on specific neurons.
● Apply Data Augmentation to increase dataset diversity.

Libraries:

● PyTorch: [Link]
● TensorFlow/Keras: [Link]

Vanishing/Exploding Gradient

Issue: Very small gradients (vanishing) slow down or block learning; excessively large
gradients (exploding) cause unstable weights and loss divergence.

Solutions:

● Apply gradient clipping to limit gradient magnitudes.


● Use proper weight initialization (Xavier, He initialization).

Libraries:

● PyTorch: [Link]
● TensorFlow/Keras: [Link]

Vanishing Activation / Dead Neurons


Issue: Certain activation functions (e.g., Sigmoid, ReLU) may cause neurons to “die” (output
always zero) or gradients to vanish, reducing learning capability.

Solutions:

● Use alternative activations such as Leaky ReLU, ELU, or GELU.

● Apply Batch Normalization to stabilize activations during training.

Libraries:

● PyTorch: [Link]
● TensorFlow/Keras:
[Link]

Step 5 - Evaluation & Validation


Phải viết kịch bản đánh giá cho Evaluation (hết quá trình train) và Validation (trong quá trình train). Và
dựa theo hướng dẫn trong file doc thầy để làm phần thể hiện như thế nào là pass cho cả Evaluation - và
Validation cho project nhóm

5.1 Evaluation

- Purpose:

+ Measure the efficiency of the final model on a one-time, untouched test set.
+ Find a suitable threshold to optimize project performance.

- Approach:

+ Use appropriate metrics: Accuracy, ROC-AUC, PR-AUC, and Confusion Matrix.


[Link]
+ Select and store a decision threshold that aligns with project goals.
+ [Link]
+ Audit confusion matrix to identify typical errors.
[Link]
+ Prevent data leakage: the test set is never used during model tuning.
Data leakage

- Pass Criteria:

+ ROC-AUC ≥ 0.70 or PR-AUC ≥ 0.30 (depending on class balance),


Accuracy ≥ 0.75.
[Link]
+ At selected threshold: Recall ≥ 0.70 with Precision ≥ 0.40, or F1 ≥ 0.60.
[Link]
+ Report completion includes: ROC curve, PR curve, confusion matrix, classification summary,
and final threshold.
[Link]

5.2 Validation

- Purpose:

+ Assess ongoing process to select model and hyperparameter tuning without touching the test set.
+ Monitor progress to collect targeted data and highlight weaknesses.

- Approach:

+ Use held-out validation splits (or cross-validation) for balanced comparison.


[Link]
+ Track ROC-AUC and PR-AUC as primary metrics; accuracy as secondary
[Link]
+ Plot confusion matrix each iteration to target specific error cases.
[Link]
+ Document candidate thresholds and rationale.
[Link]
+ Ensure preprocessing and parameter selection use only training and validation data (no leakage).
Data leakage

- Pass Criteria

+ Mean ROC-AUC ≥ 0.70, with low variance (≤ 0.05) to ensure stable


performance.
[Link]
+ No data leakage.
Data leakage
+ Evidence that error types decrease over iterations (confusion matrix trend).
[Link]
+ Clear record of thresholds considered, ready for final evaluation.
[Link]

Step 6 - Model Optimization


Dựa vào 2 cái model đã chọn trên mục 3 (trước hết làm cho YOLO), dùng kĩ thuật nào sau đây:
regularization (dropout, weight decay), data augmentation, and hyperparameter search; compress
models via quantization/pruning for deployment. => và vì sao phải dùng nó, cách thực hiện (thư viện,
code mẫu, và link liên quan)
6.1 Model YOLOv8

- Regularization (dropout, weight decay)

+ Why: Reduce overfitting to camouflage/backgrounds; improve generalization to new


sites/lighting.
+ How (libs):
● Ultralytics YOLOv8 + PyTorch training with AdamW weight decay as the primary
lever; keep EMA; light label smoothing if labels are noisy
● BatchNorm (already in YOLOv8): keep BN active with sensible batch sizes; avoid
micro-batches that destabilize BN stats. Optionally freeze BN only in late
fine-tuning/QAT if needed.

BatchNorm
[Link]

- Data Augmentation (mosaic/mixup + geometric/photometric)

+ Why: Grow visual diversity while preserving tiny bite lesions and slender snake shapes.
+ How (libs): Use residual-based designs (e.g., ResNet/ResNeSt/CSP with residual paths) or
Ultralytics YOLOv8 built-in aug; reduce mosaic strength to avoid unrealistic composites; apply
moderate HSV jitter, light blur/noise; ensure crops keep small regions visible.
ResNet
[Link]

- Hyperparameter Search (staged sweeps)

+ Why: Systematically find better LR/weight decay/image size/augment strengths; target PR-AUC
(bite) and Recall (snake).
+ How (libs): Ultralytics Hyperparameter Tuning (built-in) for parallel search & early stopping
[Link]

- Compression for Deployment (quantization / pruning)

+ Why: Meet mobile/edge latency & size constraints without sacrificing safety-critical recall on
bite/snake.
+ How (libs):
● Quantization: Export YOLOv8 → TFLite INT8 (PTQ) or TensorRT INT8; use a
representative dataset (varied lighting/backgrounds and close-ups of bites) for calibration; use
QAT if PTQ drops metrics too much.
[Link]
[Link]
[Link]?
● Pruning (optional): PyTorch (structured pruning) (≤ ~30% channels) followed by
re-tuning; keep only if accuracy within limit.
[Link] https://
[Link]/tutorials/intermediate/pruning_tutorial.html
Step 7 - Deployment (Apply Deep model for Edge AI course)
Thuật toán chuyển đổi từ model trên mấy sang device (link thư viện dùng, và code mẫu - tham khảo phần
technologies trong file excel cột edge AI), bộ tham số (list ít nhất 2), và các bước evaluation trên device
(copy phần evaluation trong file excel cột edge AI)

7.1. Model-to-device conversion algorithm

Advantages for the Conversion & Runtime


Format Shortcoming
Project Tools
- Open standard,
independent framework,
easy to test on multiple
runtimes. - An operator support Converter:
ONNX (Open Neural - Supports dynamic error may occur if the [Link]
Network Exchange) shapes, suitable for model uses operators that Runtime: ONNX
changing input image are not fully supported. Runtime (Python/C++)
sizes.
- Can be further optimized
using ONNX Runtime.
- Optimized specifically
for PyTorch, high - TorchScript tracing
Converter: [Link]
performance on generates static graphs,
or [Link]
TorchScript Raspberry Pi. which may not support
Runtime: LibTorch (C+
- Allows model loading complex control threads
+) / PyTorch (Python)
without relying on native (if/else, loops).
Python code.
- Designed specifically
for mobile/edge, with a
powerful set of
quantization tools. Converter:
- Supports hardware TFLiteConverter
TensorFlow Lite - Primarily for the
acceleration through Runtime: TensorFlow
(LiteRT) TensorFlow ecosystem.
delegates (e.g. GPU, Lite Interpreter
NNAPI). - FlatBuffers (Python/C++)
format for fast model
loading and low memory
usage.

7.3. Device evaluation steps


A. Objective metrics & targets
- Envenomation Detection Accuracy (Bounding Box / Segmentation / Classification) (1, 3, 4)
• Target: Dice / IoU ≥ 0.65 and poisoned/non-poisoned classification accuracy ≥ 70
%.
• Measurement: Run model inference on a held-out edge-device test set and compute Dice/IoU for wound region
and overall classification accuracy.
Ref: [Link]
- Real-Time Inference Latency (Time for one captured frame to pass through the detection model on edge
device) (1, 2, 5)
• Target: ≤ 300 ms per detection single-frame
• Measurement: Measure processing time from frame capture → detection output using edge device profiling
tools.
Ref: [Link]
- End-to-End Offline Latency (Time from image capture → detection → basic guidance display
without server connection.) (1, 2)
• Target: capture → guidance (full offline pipeline) ≤ 1.5 s.
• Measurement: Record timestamps across the offline pipeline in disconnected mode.
Ref: [Link]
- Interactive Throughput (Sustained rate of complete capture→detect→display cycles during repeated
use.) (1)
• Target: ≥ 1 complete capture→detect→display cycle every 4 seconds.
• Measurement: Run the edge device through repeated capture–detect–display cycles under realistic conditions and
record the duration of each cycle during continuous use.
Ref: [Link]
- Robustness to Varying Lighting (1, 3, 5)
• Target: Maintain ≥ 60 % poisoned/non-poisoned classification accuracy and
Dice/IoU ≥ 0.50 under low-light, or high-glare
• Measurement: Test on low-light / glare subsets; compare with baseline performance.
Ref: [Link]

B. Subjective evaluation (1–5 scales)


+ Speed / Latency (1, 2): Is the response time fast enough and non-disruptive during an emergency?
Ref: [Link]
+ Clarity of Visual Overlays (2, 4): Are highlighted ROIs / callouts clear and useful for guiding action?
Ref: [Link]
+ Trust in Detection (1, 5): Do users feel the system identifies emergencies reliably?
Ref: [Link]
+ Perceived Robustness: Do the system remained reliable under different lighting or movement conditions?
Ref: [Link]
Light_Image_Dynamic_Enhancement_for_Object_Detection?utm_source=[Link]

You might also like