torstendittmann commited on
Commit
f114d60
·
verified ·
1 Parent(s): aecb8a5

Use curl and urllib in download examples

Browse files
Files changed (1) hide show
  1. README.md +15 -4
README.md CHANGED
@@ -52,7 +52,10 @@ training, not for the ONNX Runtime path.
52
  Download the ranking model and crop a photo:
53
 
54
  ```sh
55
- hf download appwrite/focalnet focalnet-human.onnx --local-dir artifacts
 
 
 
56
  uv run focalnet predict-human artifacts/focalnet-human.onnx photo.jpg \
57
  --aspect-ratio 16:9
58
  ```
@@ -60,17 +63,25 @@ uv run focalnet predict-human artifacts/focalnet-human.onnx photo.jpg \
60
  From Python:
61
 
62
  ```python
63
- from huggingface_hub import hf_hub_download
 
 
64
  from focalnet.human_runtime import HumanCropPredictor
65
 
66
- path = hf_hub_download("appwrite/focalnet", "focalnet-human.onnx")
 
 
 
67
  crop = HumanCropPredictor(path).predict("photo.jpg", aspect_ratio=16 / 9)
68
  ```
69
 
70
  Importance-only inference:
71
 
72
  ```sh
73
- hf download appwrite/focalnet focalnet.onnx --local-dir artifacts
 
 
 
74
  uv run focalnet predict artifacts/focalnet.onnx photo.jpg --aspect-ratio 16:9
75
  ```
76
 
 
52
  Download the ranking model and crop a photo:
53
 
54
  ```sh
55
+ mkdir -p artifacts
56
+ curl -fsSL \
57
+ "https://huggingface.co/appwrite/focalnet/resolve/main/focalnet-human.onnx" \
58
+ -o artifacts/focalnet-human.onnx
59
  uv run focalnet predict-human artifacts/focalnet-human.onnx photo.jpg \
60
  --aspect-ratio 16:9
61
  ```
 
63
  From Python:
64
 
65
  ```python
66
+ from pathlib import Path
67
+ from urllib.request import urlretrieve
68
+
69
  from focalnet.human_runtime import HumanCropPredictor
70
 
71
+ url = "https://huggingface.co/appwrite/focalnet/resolve/main/focalnet-human.onnx"
72
+ path = Path("artifacts/focalnet-human.onnx")
73
+ path.parent.mkdir(parents=True, exist_ok=True)
74
+ urlretrieve(url, path)
75
  crop = HumanCropPredictor(path).predict("photo.jpg", aspect_ratio=16 / 9)
76
  ```
77
 
78
  Importance-only inference:
79
 
80
  ```sh
81
+ mkdir -p artifacts
82
+ curl -fsSL \
83
+ "https://huggingface.co/appwrite/focalnet/resolve/main/focalnet.onnx" \
84
+ -o artifacts/focalnet.onnx
85
  uv run focalnet predict artifacts/focalnet.onnx photo.jpg --aspect-ratio 16:9
86
  ```
87