Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -7,6 +7,8 @@ import tempfile
|
|
| 7 |
import os
|
| 8 |
import asyncio
|
| 9 |
from concurrent.futures import ThreadPoolExecutor
|
|
|
|
|
|
|
| 10 |
|
| 11 |
# Set page configuration
|
| 12 |
st.set_page_config(page_title="Solar Panel Fault Detection", layout="wide")
|
|
@@ -18,6 +20,10 @@ st.write("Upload a thermal video (MP4) of a solar panel to detect thermal, dust,
|
|
| 18 |
# Load model and processor
|
| 19 |
@st.cache_resource
|
| 20 |
def load_model():
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
processor = DetrImageProcessor.from_pretrained("facebook/detr-resnet-50")
|
| 22 |
model = DetrForObjectDetection.from_pretrained("facebook/detr-resnet-50")
|
| 23 |
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
|
@@ -98,8 +104,7 @@ async def process_video(video_path, frame_skip=5, batch_size=4):
|
|
| 98 |
|
| 99 |
while cap.isOpened():
|
| 100 |
ret, frame = cap.read()
|
| 101 |
-
if not
|
| 102 |
-
break
|
| 103 |
|
| 104 |
if frame_count % frame_skip != 0:
|
| 105 |
out.write(frame)
|
|
|
|
| 7 |
import os
|
| 8 |
import asyncio
|
| 9 |
from concurrent.futures import ThreadPoolExecutor
|
| 10 |
+
import warnings
|
| 11 |
+
from transformers.utils import logging
|
| 12 |
|
| 13 |
# Set page configuration
|
| 14 |
st.set_page_config(page_title="Solar Panel Fault Detection", layout="wide")
|
|
|
|
| 20 |
# Load model and processor
|
| 21 |
@st.cache_resource
|
| 22 |
def load_model():
|
| 23 |
+
# Suppress warning about unused weights
|
| 24 |
+
warnings.filterwarnings("ignore", message="Some weights of the model checkpoint.*were not used")
|
| 25 |
+
logging.set_verbosity_error()
|
| 26 |
+
|
| 27 |
processor = DetrImageProcessor.from_pretrained("facebook/detr-resnet-50")
|
| 28 |
model = DetrForObjectDetection.from_pretrained("facebook/detr-resnet-50")
|
| 29 |
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
|
|
|
| 104 |
|
| 105 |
while cap.isOpened():
|
| 106 |
ret, frame = cap.read()
|
| 107 |
+
if not, break
|
|
|
|
| 108 |
|
| 109 |
if frame_count % frame_skip != 0:
|
| 110 |
out.write(frame)
|