Spaces:
Sleeping
Sleeping
Update model.py
Browse filesUsed pipeline to load model
model.py
CHANGED
@@ -1,5 +1,6 @@
|
|
1 |
import albumentations as A
|
2 |
from transformers import AutoModelForObjectDetection, AutoImageProcessor
|
|
|
3 |
|
4 |
|
5 |
# Mapping for labels and IDs
|
@@ -52,11 +53,15 @@ def get_val_transform():
|
|
52 |
)
|
53 |
|
54 |
# Load the model
|
55 |
-
def load_model():
|
56 |
-
|
57 |
-
|
58 |
-
model
|
59 |
-
|
60 |
-
|
|
|
|
|
|
|
|
|
61 |
)
|
62 |
-
return
|
|
|
1 |
import albumentations as A
|
2 |
from transformers import AutoModelForObjectDetection, AutoImageProcessor
|
3 |
+
from transformers import pipeline
|
4 |
|
5 |
|
6 |
# Mapping for labels and IDs
|
|
|
53 |
)
|
54 |
|
55 |
# Load the model
|
56 |
+
def load_model(device: int = -1):
|
57 |
+
"""
|
58 |
+
Load the DETR model pipeline.
|
59 |
+
:param device: Specify device to load the model (-1 for CPU, 0 for GPU).
|
60 |
+
:return: Hugging Face object-detection pipeline.
|
61 |
+
"""
|
62 |
+
model_pipeline = pipeline(
|
63 |
+
"object-detection",
|
64 |
+
model="sergiopaniego/detr-resnet-50-dc5-fashionpedia-finetuned",
|
65 |
+
device=device
|
66 |
)
|
67 |
+
return model_pipeline
|