AI Fault Diagnosis for Overhead Cranes: Grad-CAM & SHAP

The "black box" problem in AI-based fault diagnosis for overhead cranes is being cracked by two explainability techniques: Grad-CAM generates heatmaps that show operators which sensor regions the model is "looking at," while SHAP quantifies the contribution of each input feature to the diagnostic conclusion. After Kelude deployed a dual-method integrated system on five QD32/5t overhead cranes in the continuous casting bay of a steel plant, operator adoption of AI diagnoses rose from an initial 62% to 94%, and unplanned downtime dropped by 61%. The technical core: Grad-CAM provides spatial localization ("the 1.2–2.4 kHz vibration band of the drum bearing housing is what I focused on"), while SHAP provides attribution ranking ("V1_RMS contribution +0.32, V2_kurtosis contribution +0.21")—the two complement each other to form a complete diagnostic evidence chain.

Deep learning models (CNN/GNN) have achieved F1 scores above 0.97 in overhead crane fault diagnosis, yet the vast majority of industrial users refuse to accept a black-box decision where "the model says fault, so it's a fault." From a compliance standpoint, GB/T 41867-2022 Artificial Intelligence — Explainability — Terminology and Classification explicitly requires high-risk AI systems to provide decision explanations. From a practical standpoint, operators need to know why the AI flagged a bearing fault—whether it was the vibration frequency pattern or a change in the current waveform—before they will trust and act on maintenance instructions.

This article is based on the AI diagnostic system Kelude deployed across 12 overhead cranes, and provides a complete walkthrough of the principles, Python implementation, and crane-specific integration of two mainstream explainability methods: Grad-CAM (Gradient-weighted Class Activation Mapping) and SHAP (SHapley Additive exPlanations). The two methods serve different purposes: Grad-CAM answers "where did the model look" (spatial localization), while SHAP answers "which features matter most" (feature attribution). Together, they cover the two core requirements of GB/T 41867-2022 for explainability: functional-level understandability and feature-level traceability.

Grad-CAM and SHAP dual-method explainable AI diagnostic architecture—from CNN feature maps to heatmap localization to SHAP feature attribution ranking

Grad-CAM Explained: From CNN Gradient Backpropagation to Heatmap Visualization

Mathematical Principle: Grad-CAM (Selvaraju et al., 2017) uses gradient information from the final convolutional layer of a CNN to compute importance weights for each feature channel, then produces a class-activation heatmap via weighted summation. For an overhead crane fault diagnosis task, assume the last convolutional layer outputs a feature map A⁽ˡ⁾∈ℝ^C×H×W (C=512 channels, H=8, W=8 spatial resolution). For a target class c (e.g., bearing fault F1), the class score yᶜ is first averaged over all spatial positions of the k-th feature map to obtain the gradient: αₖᶜ = (1/Z)·∑ᵢ∑ⱼ ∂yᶜ/∂Aⁱʲₖ. The feature maps are then linearly combined using αₖᶜ as weights: L_Grad-CAM = ReLU(∑ₖ αₖᶜ·Aₖ). The final ReLU ensures that only positively correlated regions are retained ("this is where the model looks to make its fault determination"), while negatively correlated regions are suppressed.

What This Means for Crane Vibration Diagnosis: Suppose the input is a 12-sensor × 256-point FFT spectrogram (concatenated into a 12×128 2D input). After three convolutional + pooling layers, the final feature map is 8×8 in size (each spatial position corresponds to a frequency band). The red regions in the Grad-CAM heatmap correspond to the frequency bands and sensor positions the diagnostic model considers most important. In field testing, for bearing fault F1, the Grad-CAM heatmap peak consistently concentrated in the 1.2–2.4 kHz band of vibration sensor V3 on the drum bearing housing—precisely the frequency range corresponding to the 2,180 Hz fundamental characteristic frequency of a rolling bearing outer ring fault, consistent with Hertzian elastic contact theory.

PyTorch Implementation:

 import torch import torch.nn.functional as F import matplotlib.pyplot as plt import numpy as np class GradCAM: """Grad-CAMHeatmap Generator——Overhead Crane AdaptationCNNdiagnostic model""" def __init__(self, model, target_layer): self.model = model self.target_layer = target_layer self.gradients = None self.activations = None # Register Forward and Backward Hooks target_layer.register_forward_hook(self._forward_hook) target_layer.register_full_backward_hook(self._backward_hook) def _forward_hook(self, module, input, output): self.activations = output.detach() # [B, C, H, W] def _backward_hook(self, module, grad_input, grad_output): self.gradients = grad_output[0].detach() # [B, C, H, W] def generate(self, x, class_idx=None): """Generate Heatmap""" # forward propagation logits = self.model(x.unsqueeze(0)) if class_idx is None: class_idx = logits.argmax(dim=1).item() # backpropagation(Target Class Score) self.model.zero_grad() logits[0, class_idx].backward() # Compute Gradient Weights αₖᶜ = global_average_pooling(∂y/∂Aₖ) weights = self.gradients.mean(dim=(2, 3), keepdim=True) # [1, C, 1, 1] # Weighted Summation: Σ αₖ·Aₖ cam = (weights * self.activations).sum(dim=1, keepdim=True) # [1, 1, H, W] cam = F.relu(cam) # Positive Correlation Only # Upsample to Input Size cam = F.interpolate(cam, size=(128, 128), mode='bilinear', align_corners=False) cam = cam.squeeze().cpu().numpy() # Normalize to[0,1] cam = (cam - cam.min()) / (cam.max() - cam.min() + 1e-8) return cam, class_idx # Usage Example # model = torch.load('crane_cnn_fault.pt') # Pretrained Overhead CraneCNNdiagnostic model # target_conv = model.features[-1] # Last Convolutional Layer # grad_cam = GradCAM(model, target_conv) # heatmap, pred_class = grad_cam.generate(sample_spectrogram, class_idx=1) # plt.imshow(heatmap, cmap='jet', alpha=0.5) # Overlay on Spectrogram # plt.title(f'Grad-CAM: Predicted Class={pred_class} (bearing faultF1)') 

Code Notes: The GradCAM class uses PyTorch's register_forward_hook and register_full_backward_hook to automatically capture the activations and gradients of the target convolutional layer. The core computation is performed in the generate method: ① forward propagation to obtain logits; ② backpropagation for the target class to obtain gradients; ③ global average pooling of gradients to derive channel weights αₖᶜ; ④ weighted summation + ReLU + upsampling. The final heatmap is overlaid on the input spectrogram, with red regions indicating the frequency bands the model used for its diagnosis.


SHAP Fundamentals: How Shapley Values Quantify Feature Contributions

Mathematical Principle: SHAP (Lundberg & Lee, 2017) is grounded in the Shapley value from cooperative game theory. Each feature is treated as a "player" in a cooperative game, and the model prediction is the "total payout." The Shapley value φᵢ for the i-th feature is defined as the weighted average of the marginal contribution of feature i across all feature subsets S⊆F{i}: φᵢ = Σ_{S⊆F{i}} (|S|!(|F|-|S|-1)!/|F|!) · [fₓ(S∪{i}) – fₓ(S)]. Here, fₓ(S) is the model output restricted to the feature subset S (missing features are replaced with baseline values), and the combinatorial weight reflects the probability of subset S occurring. SHAP's key advantage lies in satisfying three ideal axioms: local accuracy (the sum of explanations equals the total prediction), missingness (features not present have zero contribution), and consistency (if a model changes so a feature becomes more important, its SHAP value does not decrease).

Application to Overhead Crane Diagnostics: For a 120-dimensional input (12 sensors × 10 features), computing marginal contributions across all 2¹²⁰ feature subsets is computationally infeasible. In practice, TreeSHAP (tree-model-specific, O(TLD²) complexity) or KernelSHAP (model-agnostic, approximation via sampling) is used. Kelude's crane diagnostic system employs KernelSHAP with a feature-grouping strategy: the 10-dimensional features per sensor are first merged into 12 groups (each group's SHAP value = sum of its 10 dimensions), then individual SHAP values are computed within each group for fine-grained analysis. This reduces the feature space from 120 dimensions to 12 groups, cutting sampling complexity by 12×. With 128 background samples × 256 sampling iterations, per-sample SHAP computation takes approximately 1.8 seconds (CPU, Intel i7-12700), which meets the requirements for offline diagnostic report generation.

Python Implementation:

 import shap import numpy as np import torch class SHAPExplainer: """SHAPFeature Attribution Interpreter——Overhead Crane Fault Diagnosis Specific""" def __init__(self, model, background_size=128, n_samples=256): self.model = model self.background_size = background_size self.n_samples = n_samples self.feature_names = [ # 12Sensors × 10Dimensional Features f'{sensor}_{feat}' for sensor in ['V1','V2','V3','V4','T1','T2','T3','C1','C2','C3','Q1','Q2'] for feat in ['RMS','Peak Value','Kurtosis','Skewness','Waveform Factor','Impulse Factor', 'Clearance Factor','Frequency Centroid','Energy Ratio_0_500','Energy Ratio_500_2k'] ] def _predict_proba(self, X): """PyTorchModel Wrapped asshapCallable Format""" self.model.eval() with torch.no_grad(): X_tensor = torch.from_numpy(X).float() outputs = torch.softmax(self.model(X_tensor), dim=1).numpy() return outputs def explain(self, sample, background_data, class_names=None): """Generate for Single SampleSHAPExplanation""" # Randomly Select Background Samples bg_idx = np.random.choice(len(background_data), self.background_size, replace=False) background = background_data[bg_idx] # KernelSHAPFeature Attribution Interpreter explainer = shap.KernelExplainer(self._predict_proba, background) # ComputeSHAPPeak Value(Specified Fault Class Index) shap_values = explainer.shap_values( sample.reshape(1, -1), nsamples=self.n_samples ) return shap_values # list of [n_classes, n_features] arrays # Usage Example # model = torch.load('crane_cnn_fault.pt') # explainer = SHAPExplainer(model, background_size=128, n_samples=256) # background_data = np.load('crane_background_samples.npy') # [5000, 120] # sample = background_data[0] # Sample to Explain # shap_vals = explainer.explain(sample, background_data) # Aggregate by Sensor GroupSHAPPeak Value # sensor_groups = {s: sum(shap_vals[c][:, i*10:(i+1)*10]) for i, s in # enumerate(['V1','V2','V3','V4','T1','T2','T3','C1','C2','C3','Q1','Q2'])} # shap.summary_plot(shap_vals[1], sample.reshape(1,-1), # feature_names=explainer.feature_names) 

Code Notes: The SHAPExplainer class wraps the shap.KernelExplainer call logic. The key parameter background_size controls the background dataset size (affecting baseline estimation accuracy), while n_samples controls the number of sampling iterations (affecting computation time and stability). The background dataset should contain at least 5,000 samples collected under normal operating conditions. In grouped aggregation, sensor V1 (acceleration RMS and peak) consistently shows the highest average SHAP value for bearing fault diagnosis, while T2 (brake friction surface temperature) contributes the least under normal conditions—confirming that the model has correctly learned the underlying physical relationships.

Kelude Heavy Industry: Overhead Crane & Gantry Crane Manufacturer

Kelude Heavy Industry is a professional manufacturer of overhead cranes, gantry cranes, and electric hoists. We provide a full range of material handling solutions, including single-girder and double-girder cranes, explosion-proof cranes, and low-headroom hoists, tailored to industrial applications across the United States and Europe.

Frequently Asked Questions (FAQ)

Q: What is the lead time for a standard overhead crane?
A: For standard models, the lead time is typically 30 to 45 days after order confirmation. Customized cranes may require 60 to 90 days depending on complexity.

Q: Do you provide installation services?
A: Yes, we offer professional installation services either by our own team or through our certified local partners in the US and Europe. Supervision and training are also available.

Q: Can your cranes be adapted for existing runways?
A: Absolutely. We can design cranes to fit existing runway beams and dimensions. Please provide your runway drawings for a feasibility assessment.

Q: What is the warranty period for your products?
A: We offer a standard warranty of 12 months from the date of commissioning, covering defects in materials and workmanship. Extended warranty options are available upon request.

Q: Do you supply spare parts for cranes?
A: Yes, we maintain a comprehensive inventory of spare parts for all our crane models, including hoists, motors, brakes, and control panels. Parts can be shipped worldwide.

Q: Are your cranes compliant with international safety standards?
A: All our cranes are designed and manufactured in accordance with ISO 4301, ISO 12480, and IEC 60204-32 standards. We also provide CE certification for the European market.

Comparison Parameter Grad-CAM SHAP Complementary Relationship
Output Format heatmap(Visual Positioning) Bar Chart(Numerical Attribution) Visual+Numerical Valuedual channel
Question Addressed Model Attention Map? Feature Importance Ranking? Spatial+Full Feature Setcoverage
Applicable Models CNN(Requirementconvolutional layergradient) Optional Applicable Models(Black-box) CNN+Optional Applicable Models
Granularity Spatial Region-level(Pixel/Frequency Band) Feature-level(Single Feature/Sensor) Layer-wise Region Feature Refinement
Computational Cost Extremely Low(1Timesbackpropagation) High(256×128Forward Passes) Prior Grad CAMPositioning Posterior SHAPNumerical Attribution
Theoretical Foundation gradient Weighted(Heuristic) Shapley Numerical Value(Axiomatic) Heuristic+Axiomatic Guarantee
explainability Type Function-level(L1/GFunction-level) Feature-level(L3/GFeature-level) Compliance GB/T 41867-2022

A: ISO/IEC 41867-2022 defines four levels of explainability, L1 through L4. Grad-CAM satisfies L1 (functional level, explaining which regions the model focuses on), while SHAP satisfies L3 (feature level, explaining feature contributions). Together, they cover L1 and L3, leaving only L2 (structural level, neuron activation explanations) and L4 (conceptual level, concept semantics) uncovered.


Engineering Integration: Deploying a Dual-Method Grad-CAM + SHAP System Architecture

Integration Strategy: The dual-method system is built around a two-stage pipeline: "Grad-CAM for localization, then SHAP for attribution." In the first stage, while the CNN diagnosis model outputs the fault category, Grad-CAM automatically generates a heatmap overlaid on the input spectrogram, highlighting the frequency bands the model focuses on in red on the diagnostic interface. In the second stage, if users need finer-grained feature-level explanations, they can trigger SHAP analysis (online or asynchronously) with a single click, producing a bar chart ranking feature contributions. This two-stage separation prevents SHAP's frequent computations (~1.8 seconds per run) from impacting the real-time diagnostic pipeline, which requires sub-50ms latency.

System Architecture: Sensor data flows through an Edge Computing box (Jetson Orin NX) → CNN inference (6.2ms) → Grad-CAM heatmap generation (+0.3ms, negligible overhead) → real-time display on the HMI. When a user clicks "Deep Explanation," an MQTT request is sent to the plant-level server, where KernelSHAP computation (1.8s) runs and the SHAP attribution plot is returned to the HMI. Grad-CAM remains always-on, while SHAP is triggered on demand. This architecture leverages Grad-CAM's minimal computational cost (a single backpropagation pass with negligible latency) for seamless integration into the real-time inference pipeline, while SHAP's heavier computational load is handled asynchronously.

Key Performance Indicators:

Performance Indicator Grad-CAM(Online) SHAP(On-demand) Dual-method Integration
Single-pass Computation Time 0.3ms 1,800ms 1.8s(SHAPOn-demand Trigger Only)
Computation Location Edge Device(Jetson) Plant-levelserver Edge+Cloud-edge Collaboration
On-demand Trigger Only Frequency Per Inference(~5Times/Seconds) Per User Click(~3Times/Days) Grad CAM 99.9%+SHAP 0.1%
Network Dependency Network-independent(Local) Requirement MQTTCommunication Offline Lowlatency+Online High Accuracy
Output Integration Method spectrogram Overlayheatmap Feature Contribution Bar Chart Comprehensive Diagnosis Report Card

Across 12 overhead cranes monitored over 16 months, operator adoption of AI diagnostics improved from an initial 62% (when only class labels and confidence scores were shown) to 81% after adding Grad-CAM heatmaps, and further to 94% once SHAP attribution was included—demonstrating that spatial localization and feature attribution have a cumulative effect on building user trust.


Overhead Crane Fault Diagnosis: Field Case Studies

Case 1: Outer Ring Fatigue Spalling on a Drum Bearing (Steel mill, QD32/5t overhead crane, August 2025)

The CNN model output fault class F1 (bearing fault) with a confidence score of 0.963. The Grad-CAM heatmap highlighted high-contribution regions (red) concentrated in rows 3–5 of the input spectrogram (corresponding to vibration sensors V2 and V3) and columns 32–64 (corresponding to the 1.2–2.4 kHz frequency band). SHAP attribution ranked the top contributing features: V2_kurtosis = +0.21 (highest), V1_RMS = +0.19, V3_energy_ratio_500_2k = +0.15, and T1_mean = +0.08. The combined interpretation: "The abnormally elevated kurtosis (+0.21) on drum bearing housing sensor V2, along with the increased RMS (+0.19) on V1 and the higher energy in the 1.2–2.4 kHz band (+0.15) on V3, points to fatigue spalling on the rolling bearing outer ring. A shutdown for bearing replacement is recommended within 48 hours." Physical inspection confirmed the diagnosis: contact fatigue spalling covering approximately 15 mm² on the outer ring raceway—fully consistent with the model's conclusion.

Case 2: Gear Wear (Steel mill, LD16/3.2t overhead crane, January 2026)

The CNN model output fault class F2 (gear wear) with a confidence score of 0.941. The Grad-CAM heatmap showed red regions concentrated across the full frequency range of sensor V2 (gearbox input bearing), with peaks in the 0.5–1.0 kHz band (mesh frequency and its sidebands). SHAP attribution ranked the top features: V2_energy_ratio_0_500 = +0.24, V2_peak = +0.18, C2_fundamental = +0.11, and Q1_mean = +0.07. The feature combination pattern differs markedly from Case 1—Case 1's dominant feature was V2_kurtosis at +0.21 (a typical bearing fault indicator, as kurtosis is sensitive to impact signals), while Case 2's dominant feature was V2_energy_ratio_0_500 at +0.24 (a typical gear wear indicator, reflecting increased mesh frequency sideband energy). This clear differentiation in feature attribution patterns across fault types further validates the discriminative power of SHAP-based feature-level explanations.

Reliability Data: Over 16 months of operation across 12 overhead cranes, the combined Grad-CAM + SHAP approach generated 784 diagnostic reports. Manual verification (via bearing housing opening, disassembly, or borescope inspection) confirmed 752 correct diagnoses, yielding an accuracy rate of 95.9%. SHAP attributions aligned with expert judgment in 92.3% of cases (155 out of 168 independent expert reviews agreed with the SHAP feature importance rankings).


Explainability for Compliance and Trust in Industrial Settings

Compliance Requirements: The Chinese national standard GB/T 41867-2022 (Artificial Intelligence—Explainability—Terminology and Classification) defines four levels of explainability (L1 functional to L4 conceptual), while GB/T 42132-2022 (Deep Learning Algorithm Evaluation Specification) mandates explainability assessments for high-risk AI systems. Overhead crane fault diagnosis directly impacts equipment and personnel safety, classifying it as a high-risk AI system that must meet at least L1 + L3 explainability requirements. Grad-CAM satisfies L1 (heatmaps describing the model's functional attention), while SHAP satisfies L3 (quantitative feature contribution attribution). The combined approach has passed Kelude Heavy Industry's internal compliance review.

Building Trust: Operator trust in AI diagnostics is not established overnight—it accumulates gradually with each diagnostic report. Moving from "telling you the fault class" to "showing you where the model looked" and finally to "explaining why it looked there" progressively increases information transparency, and trust follows naturally. Tracking data from 12 overhead cranes over 16 months shows that Grad-CAM heatmaps increased false-alarm tolerance from 1 to 3 per week (operators accepted more "nuisance alarms" because they could see the model's reasoning), while SHAP attribution reduced the rate of "rejecting AI conclusions and forcing an unnecessary inspection" from 38% to 9%.

Economic Value: Each avoided unnecessary inspection (opening the bearing housing) saves approximately ¥12,000 (including labor, downtime, and spare parts). Over the 16-month period, operator trust in AI diagnostics prevented 47 unnecessary inspections, saving roughly ¥560,000 in total. Additionally, SHAP attribution enabled early fault detection (e.g., Case 1 provided a 72-hour advance warning of a bearing fault), averting one potential spindle seizure incident—estimated direct losses of ¥180,000 plus production downtime costs of ¥450,000/day × 3 days = ¥1.53 million.

For more combined approaches to model explainability and edge deployment, see Kelude Heavy Industry's resources on GNN-based multi-sensor fault diagnosis and PyTorch-ONNX-TensorRT edge deployment practices.


Frequently Asked Questions (FAQ)

Q: Can Grad-CAM and SHAP be applied simultaneously to GNN models?

A: Grad-CAM requires convolutional layer feature maps, and standard GNNs (GCN/GAT) operate on computational graphs (message passing at the graph level) that do not produce regular grid-like feature maps—so Grad-CAM cannot be directly applied to GNNs. However, GNNs can use GNNExplainer (an explainability method designed for graph structures) to obtain node and edge attention weights, which serves as an equivalent to Grad-CAM's spatial localization function. SHAP is model-agnostic and can be applied to any model, including GNNs—simply wrap the inference function in a SHAP-callable format. Kelude Heavy Industry uses a "GNNExplainer (for key sensor node localization) + SHAP (for feature attribution)" combination in GNN-based diagnostics.

Q: Can SHAP computation time be optimized further? 1.8 seconds is too long for real-time scenarios.

A: Three optimization approaches are available: ① Use FastSHAP (train a separate explainer network to directly generate SHAP approximations, reducing inference time to <1 ms), though this requires additional training and incurs some approximation accuracy loss; ② Use TreeSHAP (if using XGBoost or LightGBM, the O(TLD²) complexity is thousands of times faster than KernelSHAP); ③ Use feature grouping combined with background sampling reduction (group the 120 dimensions into 12 sensor groups, reduce background_size from 128 to 64, and n_samples from 256 to 128—cutting computation time from 1.8s to 0.3s with SHAP value deviation under 3%). Kelude Heavy Industry recommends option ③ as the optimal engineering practice.

Q: How do I interpret Grad-CAM heatmaps on spectrograms? Does a red region always indicate a fault?

A: Red regions in the heatmap indicate "the frequency bands the model considers most important for its current fault classification"—they do not necessarily mean a fault signal is present in that region. For example, when diagnosing a healthy condition, the Grad-CAM heatmap typically shows no prominent red regions (or a uniform distribution without peaks), because the model's "normal signal" judgment is based on energy levels across all bands remaining within baseline ranges. However, if a clearly defined red highlight suddenly appears (e.g., concentrated in the 1.2–2.4 kHz band at sensor positions V2/V3), even if the confidence score has not yet exceeded the alarm threshold, maintenance personnel should take note—the fault may be in its early stages. Kelude Heavy Industry has implemented a "heatmap anomaly activity" indicator in the HMI interface that triggers an early warning when the heatmap's focus region shifts beyond a threshold for three consecutive windows.

Q: Does deploying an explainability system require additional hardware investment?

A: Grad-CAM requires no additional hardware—it consumes only a single GPU backpropagation pass (<0.5ms) and can be seamlessly embedded into existing CNN inference pipelines. SHAP, when run on-demand at the edge (Jetson Orin NX), takes approximately 4–6 seconds per computation (due to compute constraints); we recommend deploying it on a plant-level server (Intel Xeon or equivalent, 1.8 seconds) or in the cloud. Kelude includes the Grad-CAM module in its standard AI diagnosis suite at no charge, while the SHAP module is available as a value-added option (¥12,000 per suite, including visualization interface development and operator training).

Grad-CAM and SHAP address the "black box" challenge in overhead crane AI fault diagnosis from two complementary angles—spatial localization and feature attribution. Instead of presenting operators with a binary "fault/normal" verdict, these methods reveal the complete chain of evidence behind the model's reasoning. Across 12 overhead cranes over 16 months, 784 diagnostic reports, 95.9% accuracy, and a 94% operator adoption rate demonstrate that explainability is not merely a compliance requirement—it is the key to AI systems being genuinely accepted and delivering value in industrial settings. Kelude Heavy Industry continues to advance the combined Grad-CAM + SHAP approach toward L2 structure-level explanations (currently under research: neuron activation path tracing) and L4 concept-level explanations (concept activation vectors, CAV).

Related News

contact

contact us

phone:
+86 13903802779

mail:3915269@qq.com

Working hours: Monday to Friday

Wechat
Wechat
SHARE
TOP