Spaces:
Sleeping
Sleeping
Update src/predict.py
Browse files- src/predict.py +16 -1
src/predict.py
CHANGED
|
@@ -9,7 +9,7 @@ def run_prediction(model, processed_frame): # Renamed function
|
|
| 9 |
return prediction[0][0]
|
| 10 |
|
| 11 |
|
| 12 |
-
|
| 13 |
import os
|
| 14 |
import urllib.request
|
| 15 |
from tensorflow.keras.models import load_model
|
|
@@ -23,6 +23,21 @@ def load_trained_model(path="violence_model.h5"):
|
|
| 23 |
print("Download complete.")
|
| 24 |
|
| 25 |
return load_model(path, compile=False)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
|
| 27 |
|
| 28 |
|
|
|
|
| 9 |
return prediction[0][0]
|
| 10 |
|
| 11 |
|
| 12 |
+
'''
|
| 13 |
import os
|
| 14 |
import urllib.request
|
| 15 |
from tensorflow.keras.models import load_model
|
|
|
|
| 23 |
print("Download complete.")
|
| 24 |
|
| 25 |
return load_model(path, compile=False)
|
| 26 |
+
'''
|
| 27 |
+
|
| 28 |
+
import os
|
| 29 |
+
import urllib.request
|
| 30 |
+
from tensorflow.keras.models import load_model
|
| 31 |
+
|
| 32 |
+
def load_trained_model(path="violence_model.keras"):
|
| 33 |
+
url = "https://huggingface.co/spaces/muskan19/Violence_Detector/resolve/main/violence_model.keras"
|
| 34 |
+
|
| 35 |
+
if not os.path.exists(path):
|
| 36 |
+
print("Downloading model...")
|
| 37 |
+
urllib.request.urlretrieve(url, path)
|
| 38 |
+
print("Download complete.")
|
| 39 |
+
|
| 40 |
+
return load_model(path, compile=False)
|
| 41 |
|
| 42 |
|
| 43 |
|