Algorithm: Attention-Guided Adaptive Feature
Pyramid Network (AG-AFPN) for Scene Text
Detection
Input: 1. Input: Color Image I where Height =
Width = 256;
Output: Binary segmentation mask B of detected text
regions
[Link] Hyper Parameters: batch size b, epochs N,
Learning rate η and Threshold T
2. Preprocess the input image I by normalizing
intensities and resizing to 256 × 256
3. Multi-Scale Feature Extraction: Pass the input image
I through the VGG19 encoder and extract hierarchical
feature maps {C1,C2,C3,C4,C5}
4. AG-AFPN Construction:
Redefine the encoder outputs as pyramid levels
{P1, P2, P3, P4, P5}.
For each feature level Pi:
Apply a Squeeze-and-Excitation (SE) block to
enhance channel-wise features.
Fuse the pyramid levels using attention-guided
adaptive fusion to generate a unified multi-
scale representation F.
5. Edge Detection: Apply an edge operator to
the input image I and produce an initial edge
map E.
6. Type-2 Fuzzy Edge Refinement: Refine the edge map
using type-2 fuzzy logic in order to suppress back-
ground noise and enhance text specific boundaries,
producing the refined edge map E′.
7. Fusion and Prediction: Integrate the refined feature
map F with fuzzy edge map E′, and pass them through
Convolutional decoding layers to generate a
probability map P.
8. Adaptive Differentiable Binarization: Apply an
adaptive threshold function to the probability map P to
obtain a sharpened segmentation mask.
9. Final Output: Binarized result B represents the
detected text regions in the input image.
D. Attention-Guided Adaptive Feature Pyramid Network
To effectively capture both semantic context and structural cues across different
resolutions, particularly for text in complex natural scenes, an Attention-Guided
Adaptive Feature Pyramid Network (AG-AFPN) is employed. The goal of AG-AFPN
is to construct scale-consistent feature maps that preserve fine details while
strengthening high-level semantics, thereby improving the robustness of text
localization.
In the first stage, the backbone network produces multi-level feature maps
{C1,C2,C3,C4,C5}. Each feature map is passed through a 1×1 convolution layer to
normalize the channel dimensions across all scales, ensuring compatibility for fusion.
The normalized features are then progressively up-sampled and adaptively fused,
resulting in a hierarchical set of multi-scale representations {P1,P2,P3,P4,P5}
To further strengthen these pyramid representations, an attention-guided mechanism
combined with Squeeze-and-Excitation (SE) blocks is applied. The SE block learns
channel-specific weights, while the attention module highlights spatially important
regions associated with text. This produces enhanced feature maps Pi′P_i^{\prime}Pi′,
expressed as:
Pi′=Pi⋅A(Pi)⋅S(Pi)(2)P_i^{\prime} = P_i \cdot A(P_i) \cdot S(P_i) \tag{2}Pi′=Pi⋅A(Pi
)⋅S(Pi)(2)
where S(Pi)S(P_i)S(Pi) represents the channel-wise recalibration by the SE block and
A(Pi)A(P_i)A(Pi) denotes the learned spatial attention weights.
Finally, all refined feature maps are adaptively up-sampled to a uniform resolution and
concatenated, forming a comprehensive multi-scale representation:
F=P1′⊕P2′⊕P3′⊕P4′⊕P5′(3)F = P_1^{\prime} \oplus P_2^{\prime} \oplus P_3^{\
prime} \oplus P_4^{\prime} \oplus P_5^{\prime} \tag{3}F=P1′⊕P2′⊕P3′⊕P4′⊕P5′
(3)
where ⊕\oplus⊕ indicates the concatenation operation. The fused representation FFF
is both scale-invariant and attention-guided, enabling more discriminative
embedding for challenging text detection and recognition scenarios.