tlemagueresse
commited on
Commit
·
ab4c4a0
1
Parent(s):
a8e5e72
Update readme
Browse files- README.md +8 -2
- __init__.py +0 -0
README.md
CHANGED
|
@@ -44,14 +44,20 @@ If you only want to download the required files to use the model (without clonin
|
|
| 44 |
Here's an example:
|
| 45 |
|
| 46 |
```python
|
|
|
|
|
|
|
|
|
|
| 47 |
from huggingface_hub import hf_hub_download
|
| 48 |
import importlib.util
|
| 49 |
|
| 50 |
# Specify the repository
|
| 51 |
repo_id = "tlmk22/QuefrencyGuardian"
|
| 52 |
|
| 53 |
-
# Download the Python file containing the model class
|
| 54 |
model_path = hf_hub_download(repo_id=repo_id, filename="model.py")
|
|
|
|
|
|
|
|
|
|
| 55 |
|
| 56 |
# Dynamically load the class from the downloaded file
|
| 57 |
spec = importlib.util.spec_from_file_location("model", model_path)
|
|
@@ -65,7 +71,7 @@ FastModelHuggingFace = model_module.FastModelHuggingFace
|
|
| 65 |
fast_model = FastModelHuggingFace.from_pretrained(repo_id)
|
| 66 |
|
| 67 |
# Perform predictions
|
| 68 |
-
result = fast_model.predict("path/to/audio.wav")
|
| 69 |
map_labels = {0: "chainsaw", 1: "environment"}
|
| 70 |
print(f"Prediction Result: {map_labels[result[0]]}")
|
| 71 |
```
|
|
|
|
| 44 |
Here's an example:
|
| 45 |
|
| 46 |
```python
|
| 47 |
+
import os
|
| 48 |
+
import sys
|
| 49 |
+
|
| 50 |
from huggingface_hub import hf_hub_download
|
| 51 |
import importlib.util
|
| 52 |
|
| 53 |
# Specify the repository
|
| 54 |
repo_id = "tlmk22/QuefrencyGuardian"
|
| 55 |
|
| 56 |
+
# Download the Python file containing the model class and add it to your path
|
| 57 |
model_path = hf_hub_download(repo_id=repo_id, filename="model.py")
|
| 58 |
+
model_dir = os.path.dirname(model_path)
|
| 59 |
+
if model_dir not in sys.path:
|
| 60 |
+
sys.path.append(model_dir)
|
| 61 |
|
| 62 |
# Dynamically load the class from the downloaded file
|
| 63 |
spec = importlib.util.spec_from_file_location("model", model_path)
|
|
|
|
| 71 |
fast_model = FastModelHuggingFace.from_pretrained(repo_id)
|
| 72 |
|
| 73 |
# Perform predictions
|
| 74 |
+
result = fast_model.predict("path/to/audio.wav", device="cpu")
|
| 75 |
map_labels = {0: "chainsaw", 1: "environment"}
|
| 76 |
print(f"Prediction Result: {map_labels[result[0]]}")
|
| 77 |
```
|
__init__.py
DELETED
|
File without changes
|