Spaces:
No application file
No application file
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,18 +1,31 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
import numpy as np
|
| 3 |
from PIL import Image
|
| 4 |
-
import json
|
| 5 |
-
from transformers import AutoModelForImageClassification, AutoImageProcessor
|
| 6 |
import torch
|
| 7 |
-
import
|
| 8 |
-
import os
|
| 9 |
|
| 10 |
# Set page config
|
| 11 |
st.set_page_config(page_title="Enhanced Solar Panel Fault Detector", layout="wide")
|
| 12 |
|
| 13 |
-
#
|
| 14 |
-
|
| 15 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
|
| 17 |
# Load model and processor
|
| 18 |
@st.cache_resource
|
|
@@ -59,7 +72,7 @@ with tab1:
|
|
| 59 |
|
| 60 |
# Display fault details
|
| 61 |
if fault_type != "normal":
|
| 62 |
-
fault_details =
|
| 63 |
with st.expander("Fault Details"):
|
| 64 |
st.write(f"**Description**: {fault_details.get('description', 'No description available.')}")
|
| 65 |
st.write(f"**Maintenance Tips**: {fault_details.get('maintenance', 'No maintenance tips available.')}")
|
|
@@ -91,7 +104,7 @@ with tab2:
|
|
| 91 |
st.write(f"**File**: {result['filename']}")
|
| 92 |
st.write(f"**Prediction**: {result['fault_type'].capitalize()} (Confidence: {result['confidence']:.2%})")
|
| 93 |
if result["fault_type"] != "normal":
|
| 94 |
-
fault_details =
|
| 95 |
st.write(f"**Description**: {fault_details.get('description', 'No description available.')}")
|
| 96 |
st.write(f"**Maintenance Tips**: {fault_details.get('maintenance', 'No maintenance tips available.')}")
|
| 97 |
else:
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
import numpy as np
|
| 3 |
from PIL import Image
|
|
|
|
|
|
|
| 4 |
import torch
|
| 5 |
+
from transformers import AutoModelForImageClassification, AutoImageProcessor
|
|
|
|
| 6 |
|
| 7 |
# Set page config
|
| 8 |
st.set_page_config(page_title="Enhanced Solar Panel Fault Detector", layout="wide")
|
| 9 |
|
| 10 |
+
# Fault descriptions dictionary
|
| 11 |
+
FAULT_DESCRIPTIONS = {
|
| 12 |
+
"shadowy": {
|
| 13 |
+
"description": "Shadowing occurs when parts of the panel are obscured by objects, reducing energy output.",
|
| 14 |
+
"maintenance": "Remove obstructing objects (e.g., branches, debris) and consider repositioning panels to avoid shadows."
|
| 15 |
+
},
|
| 16 |
+
"cracked": {
|
| 17 |
+
"description": "Cracks on the panel surface can lead to water leakage and reduced performance.",
|
| 18 |
+
"maintenance": "Replace the damaged panel to prevent further degradation and ensure safety."
|
| 19 |
+
},
|
| 20 |
+
"dusty": {
|
| 21 |
+
"description": "Dust or dirt accumulation on the panel surface reduces sunlight absorption.",
|
| 22 |
+
"maintenance": "Clean panels regularly with water and a soft cloth to restore efficiency."
|
| 23 |
+
},
|
| 24 |
+
"hot_spot": {
|
| 25 |
+
"description": "Hot spots indicate localized overheating, often due to defects or debris.",
|
| 26 |
+
"maintenance": "Inspect for debris or defects; consult a technician for potential panel replacement."
|
| 27 |
+
}
|
| 28 |
+
}
|
| 29 |
|
| 30 |
# Load model and processor
|
| 31 |
@st.cache_resource
|
|
|
|
| 72 |
|
| 73 |
# Display fault details
|
| 74 |
if fault_type != "normal":
|
| 75 |
+
fault_details = FAULT_DESCRIPTIONS.get(fault_type, {})
|
| 76 |
with st.expander("Fault Details"):
|
| 77 |
st.write(f"**Description**: {fault_details.get('description', 'No description available.')}")
|
| 78 |
st.write(f"**Maintenance Tips**: {fault_details.get('maintenance', 'No maintenance tips available.')}")
|
|
|
|
| 104 |
st.write(f"**File**: {result['filename']}")
|
| 105 |
st.write(f"**Prediction**: {result['fault_type'].capitalize()} (Confidence: {result['confidence']:.2%})")
|
| 106 |
if result["fault_type"] != "normal":
|
| 107 |
+
fault_details = FAULT_DESCRIPTIONS.get(result["fault_type"], {})
|
| 108 |
st.write(f"**Description**: {fault_details.get('description', 'No description available.')}")
|
| 109 |
st.write(f"**Maintenance Tips**: {fault_details.get('maintenance', 'No maintenance tips available.')}")
|
| 110 |
else:
|