Spaces:
Running
Running
File size: 2,279 Bytes
e828445 02b1305 b9d4152 9b9b04a b9d4152 02b1305 7391c3b 02b1305 7391c3b 59a25c1 1ba0338 150ee0b 9b841d0 1ba0338 59a25c1 c0e2025 59a25c1 c0e2025 9df6aa5 c0e2025 9df6aa5 55c0e27 9df6aa5 55c0e27 76ee486 55c0e27 f8c30a9 9df6aa5 1ba0338 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
import os
from tensorflow.keras.models import load_model
#def load_trained_model(path):
#return load_model(path)
# β
Set writable cache directory
os.environ["HF_HUB_CACHE"] = "/tmp/huggingface"
def run_prediction(model, processed_frame): # Renamed function
prediction = model.predict(processed_frame)
return prediction[0][0]
'''
import os
import urllib.request
from tensorflow.keras.models import load_model
def load_trained_model(path="violence_model.h5"):
url = "https://huggingface.co/spaces/muskan19/Violence_Detector/blob/main/violence_model.keras"
if not os.path.exists(path):
print("Downloading model...")
urllib.request.urlretrieve(url, path)
print("Download complete.")
return load_model(path, compile=False)
'''
'''
import os
import urllib.request
from tensorflow.keras.models import load_model
def load_trained_model(path="violence_model.keras"):
url = "https://huggingface.co/spaces/muskan19/Violence_Detector/resolve/main/violence_model.keras"
if not os.path.exists(path):
print("Downloading model...")
urllib.request.urlretrieve(url, path)
print("Download complete.")
return load_model(path, compile=False)
'''
'''
from huggingface_hub import hf_hub_download
from tensorflow.keras.models import load_model
def load_trained_model():
model_path = hf_hub_download(
repo_id="muskan19/Violence_Detector",
filename="violence_model.keras"
)
return load_model(model_path, compile=False)
'''
'''
import os
import urllib.request
from tensorflow.keras.models import load_model
def load_trained_model(path="violence_model.keras"):
url = "https://huggingface.co/spaces/muskan19/Violence_Detector/resolve/main/violence_model.keras"
if not os.path.exists(path):
print("π₯ Downloading model...")
urllib.request.urlretrieve(url, path)
return load_model(path, compile=False)
'''
from huggingface_hub import hf_hub_download
from tensorflow.keras.models import load_model
def load_trained_model():
model_path = hf_hub_download(
repo_id="muskan19/violence_model", # Your model repo, NOT Space
filename="violence_model.h5" # Exact file name
)
return load_model(model_path, compile=False)
|