Aditya
commited on
Commit
·
1d2f4d4
1
Parent(s):
5b8727d
add models
Browse files
app.py
CHANGED
|
@@ -8,67 +8,12 @@ from huggingface_hub import hf_hub_download
|
|
| 8 |
backend = get_backend('ultralytics')
|
| 9 |
|
| 10 |
# Make sure the models paths are defined wrt their tasks, it helps map task in backend
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
},
|
| 18 |
-
"Detection": {
|
| 19 |
-
"repo_id": "Synaptics/sr100_person_detection_480x640",
|
| 20 |
-
"filename": "person_detection_flash(480x640).tflite",
|
| 21 |
-
"local_dir": "model/detect"
|
| 22 |
-
},
|
| 23 |
-
"Pose": {
|
| 24 |
-
"repo_id": "Synaptics/sr100_person_pose_detection_480x640",
|
| 25 |
-
"filename": "person_pose_detection_flash(480x640).tflite",
|
| 26 |
-
"local_dir": "model/pose"
|
| 27 |
-
},
|
| 28 |
-
"Segmentation": {
|
| 29 |
-
"repo_id": "Synaptics/sr100_person_segmentation_480x640",
|
| 30 |
-
"filename": "person_segmentation_flash(480x640).tflite",
|
| 31 |
-
"local_dir": "model/segment"
|
| 32 |
-
}
|
| 33 |
-
}
|
| 34 |
-
|
| 35 |
-
downloaded_models = {}
|
| 36 |
-
|
| 37 |
-
os.makedirs("model", exist_ok=True)
|
| 38 |
-
|
| 39 |
-
for model_type, model_info in model_repos.items():
|
| 40 |
-
os.makedirs(model_info["local_dir"], exist_ok=True)
|
| 41 |
-
|
| 42 |
-
for model_type, model_info in model_repos.items():
|
| 43 |
-
target_path = os.path.join(model_info["local_dir"], model_info["filename"])
|
| 44 |
-
|
| 45 |
-
if os.path.exists(target_path):
|
| 46 |
-
print(f"Model already exists at {target_path}")
|
| 47 |
-
downloaded_models[model_type] = target_path
|
| 48 |
-
continue
|
| 49 |
-
|
| 50 |
-
try:
|
| 51 |
-
print(f"Downloading {model_type} model from Hugging Face...")
|
| 52 |
-
model_path = hf_hub_download(
|
| 53 |
-
repo_id=model_info["repo_id"],
|
| 54 |
-
filename=model_info["filename"],
|
| 55 |
-
local_dir=model_info["local_dir"],
|
| 56 |
-
local_dir_use_symlinks=False
|
| 57 |
-
)
|
| 58 |
-
|
| 59 |
-
downloaded_models[model_type] = model_path
|
| 60 |
-
print(f"Successfully downloaded {model_type} model to {model_path}")
|
| 61 |
-
except Exception as e:
|
| 62 |
-
print(f"Error downloading {model_type} model: {e}")
|
| 63 |
-
# Fallback to local path if download fails
|
| 64 |
-
downloaded_models[model_type] = target_path
|
| 65 |
-
print(f"Falling back to local path: {target_path}")
|
| 66 |
-
|
| 67 |
-
return downloaded_models
|
| 68 |
-
|
| 69 |
-
# Get model paths from Hugging Face
|
| 70 |
-
model_paths = use_models_hf()
|
| 71 |
-
|
| 72 |
|
| 73 |
selected_model_name = "Classification"
|
| 74 |
backend.patch(model_paths[selected_model_name])
|
|
|
|
| 8 |
backend = get_backend('ultralytics')
|
| 9 |
|
| 10 |
# Make sure the models paths are defined wrt their tasks, it helps map task in backend
|
| 11 |
+
model_paths = {
|
| 12 |
+
"Classification": "model/classify/person_classification_flash(448x640).tflite",
|
| 13 |
+
"Detection": "model/detect/person_detection_flash(480x640).tflite",
|
| 14 |
+
"Pose": "model/pose/person_pose_detection_flash(480x640).tflite",
|
| 15 |
+
"Segmentation": "model/segment/person_segmentation_flash(480x640).tflite"
|
| 16 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
|
| 18 |
selected_model_name = "Classification"
|
| 19 |
backend.patch(model_paths[selected_model_name])
|
model/classify/person_classification_flash(448x640).tflite
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:cef272090b9d1f098b5b1e886c02f73aef8ba3a17746000af803e941d24a46a5
|
| 3 |
+
size 1526416
|
model/detect/person_detection_flash(480x640).tflite
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:d498a99939b4f6654dd5c6286a5fcf281fc11dfb84f62b412e2782796fd4fa4d
|
| 3 |
+
size 1262040
|
model/pose/person_pose_detection_flash(480x640).tflite
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:65290b73151b7b7ffbb0a182abc863a3fc656e77ff67c57be25013fc1b929e50
|
| 3 |
+
size 1530504
|
model/segment/person_segmentation_flash(480x640).tflite
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:434116fec61c9214447aa391141dd8c0c329f27e19bd525ad51cc00544c748e7
|
| 3 |
+
size 1524648
|