Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -2,26 +2,16 @@ import gradio as gr
|
|
| 2 |
import tensorflow as tf
|
| 3 |
import numpy as np
|
| 4 |
import librosa
|
| 5 |
-
import
|
| 6 |
-
import os
|
| 7 |
|
| 8 |
-
#
|
| 9 |
try:
|
| 10 |
-
#
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
# Download the model if it doesn't exist
|
| 18 |
-
if not os.path.exists(model_path):
|
| 19 |
-
print("Downloading model...")
|
| 20 |
-
response = requests.get(model_url)
|
| 21 |
-
with open(model_path, 'wb') as f:
|
| 22 |
-
f.write(response.content)
|
| 23 |
-
print("Model downloaded successfully!")
|
| 24 |
-
|
| 25 |
# Load the model
|
| 26 |
model = tf.keras.models.load_model(model_path)
|
| 27 |
print("Model loaded successfully!")
|
|
|
|
| 2 |
import tensorflow as tf
|
| 3 |
import numpy as np
|
| 4 |
import librosa
|
| 5 |
+
from huggingface_hub import hf_hub_download
|
|
|
|
| 6 |
|
| 7 |
+
# Load model with error handling
|
| 8 |
try:
|
| 9 |
+
# Download model file from Hugging Face with specific path
|
| 10 |
+
model_path = hf_hub_download(
|
| 11 |
+
repo_id="IsolaHGVIS/Cat-Meow-Classification",
|
| 12 |
+
filename="best_model_fold_2.h5",
|
| 13 |
+
repo_type="model"
|
| 14 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
# Load the model
|
| 16 |
model = tf.keras.models.load_model(model_path)
|
| 17 |
print("Model loaded successfully!")
|