Update README.md
Browse files
README.md
CHANGED
|
@@ -25,41 +25,20 @@ Two sources were used for training:
|
|
| 25 |
|
| 26 |
## Usage
|
| 27 |
|
| 28 |
-
The model can be used as any `ultralytics` model.
|
| 29 |
-
|
| 30 |
-
The model needs to be downloaded. This is sufficient to perform once.
|
| 31 |
-
|
| 32 |
-
```
|
| 33 |
-
import os
|
| 34 |
-
import requests
|
| 35 |
-
from ultralytics import YOLO
|
| 36 |
-
|
| 37 |
-
def download_detector(
|
| 38 |
-
url="https://huggingface.co/BVRA/TurtleDetector/resolve/main/turtle_detector.pt",
|
| 39 |
-
path_model="models/turtle_detector.pt",
|
| 40 |
-
force=False,
|
| 41 |
-
):
|
| 42 |
-
if not os.path.exists(path_model) or force:
|
| 43 |
-
os.makedirs(os.path.dirname(path_model), exist_ok=True)
|
| 44 |
-
r = requests.get(url, timeout=60)
|
| 45 |
-
r.raise_for_status()
|
| 46 |
-
with open(path_model, "wb") as f:
|
| 47 |
-
f.write(r.content)
|
| 48 |
-
|
| 49 |
-
path_model = "models/turtle_detector.pt"
|
| 50 |
-
download_detector(path_model=path_model)
|
| 51 |
-
```
|
| 52 |
-
|
| 53 |
-
Once this is done, load the model.
|
| 54 |
|
| 55 |
```
|
|
|
|
| 56 |
from ultralytics import YOLO
|
| 57 |
|
| 58 |
-
path_model =
|
|
|
|
|
|
|
|
|
|
| 59 |
model = YOLO(path_model)
|
| 60 |
```
|
| 61 |
|
| 62 |
-
|
| 63 |
|
| 64 |
```
|
| 65 |
import requests
|
|
|
|
| 25 |
|
| 26 |
## Usage
|
| 27 |
|
| 28 |
+
The model can be used as any `ultralytics` model. First, download and load the model.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 29 |
|
| 30 |
```
|
| 31 |
+
from huggingface_hub import hf_hub_download
|
| 32 |
from ultralytics import YOLO
|
| 33 |
|
| 34 |
+
path_model = hf_hub_download(
|
| 35 |
+
repo_id="BVRA/TurtleDetector",
|
| 36 |
+
filename="turtle_detector.pt",
|
| 37 |
+
)
|
| 38 |
model = YOLO(path_model)
|
| 39 |
```
|
| 40 |
|
| 41 |
+
Then download an image (or use yours) and run the prediction.
|
| 42 |
|
| 43 |
```
|
| 44 |
import requests
|