IsolaHGVIS commited on
Commit
d831c46
·
verified ·
1 Parent(s): 514adb5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -18
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 requests
6
- import os
7
 
8
- # Download and load model
9
  try:
10
- # Direct LFS URL for your model
11
- model_url = "https://huggingface.co/IsolaHGVIS/Cat-Meow-Classification/resolve/main/best_model_fold_2.h5"
12
-
13
- # Create a models directory if it doesn't exist
14
- os.makedirs('models', exist_ok=True)
15
- model_path = 'models/best_model_fold_2.h5'
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!")