Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,21 +1,17 @@
|
|
| 1 |
import cv2
|
| 2 |
-
import timm
|
| 3 |
import numpy as np
|
| 4 |
-
import tensorflow as tf
|
| 5 |
-
from tensorflow.keras.layers import Input, Conv2D, BatchNormalization, ReLU, DepthwiseConv2D, GlobalAveragePooling2D, Dense
|
| 6 |
-
from tensorflow.keras.models import load_model
|
| 7 |
-
import streamlit as st
|
| 8 |
-
from collections import deque
|
| 9 |
-
import pandas as pd
|
| 10 |
-
import base64
|
| 11 |
-
from Crypto.Cipher import AES
|
| 12 |
import torch
|
| 13 |
import torch.nn as nn
|
|
|
|
|
|
|
|
|
|
| 14 |
from ultralytics import YOLO
|
| 15 |
import csv
|
| 16 |
from Crypto.Cipher import AES
|
| 17 |
from Crypto.Random import get_random_bytes
|
| 18 |
-
|
|
|
|
|
|
|
| 19 |
|
| 20 |
# Set page title and favicon
|
| 21 |
st.set_page_config(page_title="Violence Detection and Analysis App", page_icon=":boom:")
|
|
@@ -78,6 +74,11 @@ gender_model.fc = nn.Sequential(
|
|
| 78 |
age_model.load_state_dict(torch.load('agetest_mobilevit_V_1.1.pt', map_location=torch.device('cpu')))
|
| 79 |
gender_model.load_state_dict(torch.load('gendertest_mobilevit_V_1.1.pt', map_location=torch.device('cpu')))
|
| 80 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 81 |
# Function to preprocess image for detection
|
| 82 |
def preprocess_image(image, target_size=(256, 256)):
|
| 83 |
img = cv2.resize(image, target_size, interpolation=cv2.INTER_CUBIC)
|
|
@@ -167,11 +168,6 @@ def decrypt_file(input_file, output_file, key):
|
|
| 167 |
with open(output_file, 'wb') as outfile:
|
| 168 |
outfile.write(plaintext)
|
| 169 |
|
| 170 |
-
|
| 171 |
-
# Load the violence detection model
|
| 172 |
-
violence_model = load_model('modelnew (1).h5')
|
| 173 |
-
|
| 174 |
-
|
| 175 |
# Streamlit UI
|
| 176 |
def main():
|
| 177 |
st.markdown('<h1 class="title">Violence Detection and Analysis App</h1>', unsafe_allow_html=True)
|
|
|
|
| 1 |
import cv2
|
|
|
|
| 2 |
import numpy as np
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
import torch
|
| 4 |
import torch.nn as nn
|
| 5 |
+
import streamlit as st
|
| 6 |
+
from collections import deque
|
| 7 |
+
from keras.models import load_model
|
| 8 |
from ultralytics import YOLO
|
| 9 |
import csv
|
| 10 |
from Crypto.Cipher import AES
|
| 11 |
from Crypto.Random import get_random_bytes
|
| 12 |
+
import timm
|
| 13 |
+
import base64
|
| 14 |
+
import pandas as pd
|
| 15 |
|
| 16 |
# Set page title and favicon
|
| 17 |
st.set_page_config(page_title="Violence Detection and Analysis App", page_icon=":boom:")
|
|
|
|
| 74 |
age_model.load_state_dict(torch.load('agetest_mobilevit_V_1.1.pt', map_location=torch.device('cpu')))
|
| 75 |
gender_model.load_state_dict(torch.load('gendertest_mobilevit_V_1.1.pt', map_location=torch.device('cpu')))
|
| 76 |
|
| 77 |
+
# Load the violence detection model
|
| 78 |
+
violence_model = load_model('modelnew (1).h5')
|
| 79 |
+
MODEL = "yolov8_people.pt"
|
| 80 |
+
yolo_model = YOLO(MODEL)
|
| 81 |
+
|
| 82 |
# Function to preprocess image for detection
|
| 83 |
def preprocess_image(image, target_size=(256, 256)):
|
| 84 |
img = cv2.resize(image, target_size, interpolation=cv2.INTER_CUBIC)
|
|
|
|
| 168 |
with open(output_file, 'wb') as outfile:
|
| 169 |
outfile.write(plaintext)
|
| 170 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 171 |
# Streamlit UI
|
| 172 |
def main():
|
| 173 |
st.markdown('<h1 class="title">Violence Detection and Analysis App</h1>', unsafe_allow_html=True)
|