Commit
·
a9a3a95
1
Parent(s):
67f6a39
Refactor imports for better organization and enable high-performance mode
Browse files- detect-objects.py +12 -9
detect-objects.py
CHANGED
|
@@ -58,16 +58,17 @@ import argparse
|
|
| 58 |
import logging
|
| 59 |
import os
|
| 60 |
import sys
|
| 61 |
-
from typing import
|
| 62 |
|
| 63 |
import torch
|
| 64 |
-
from
|
| 65 |
-
from datasets import load_dataset, Dataset, Features, Sequence, Value, ClassLabel
|
| 66 |
from datasets import Image as ImageFeature
|
| 67 |
from huggingface_hub import HfApi, login
|
|
|
|
| 68 |
from tqdm.auto import tqdm
|
| 69 |
-
from transformers import
|
| 70 |
|
|
|
|
| 71 |
# Configure logging
|
| 72 |
logging.basicConfig(
|
| 73 |
level=logging.INFO,
|
|
@@ -285,11 +286,13 @@ def process_batch(
|
|
| 285 |
image_categories.append(0) # Single class, always index 0
|
| 286 |
image_scores.append(float(score))
|
| 287 |
|
| 288 |
-
batch_objects.append(
|
| 289 |
-
|
| 290 |
-
|
| 291 |
-
|
| 292 |
-
|
|
|
|
|
|
|
| 293 |
|
| 294 |
return {"objects": batch_objects}
|
| 295 |
|
|
|
|
| 58 |
import logging
|
| 59 |
import os
|
| 60 |
import sys
|
| 61 |
+
from typing import Any, Dict, List
|
| 62 |
|
| 63 |
import torch
|
| 64 |
+
from datasets import ClassLabel, Dataset, Features, Sequence, Value, load_dataset
|
|
|
|
| 65 |
from datasets import Image as ImageFeature
|
| 66 |
from huggingface_hub import HfApi, login
|
| 67 |
+
from PIL import Image
|
| 68 |
from tqdm.auto import tqdm
|
| 69 |
+
from transformers import Sam3Model, Sam3Processor
|
| 70 |
|
| 71 |
+
os.environ["HF_XET_HIGH_PERFORMANCE"] = "1"
|
| 72 |
# Configure logging
|
| 73 |
logging.basicConfig(
|
| 74 |
level=logging.INFO,
|
|
|
|
| 286 |
image_categories.append(0) # Single class, always index 0
|
| 287 |
image_scores.append(float(score))
|
| 288 |
|
| 289 |
+
batch_objects.append(
|
| 290 |
+
{
|
| 291 |
+
"bbox": image_bboxes,
|
| 292 |
+
"category": image_categories,
|
| 293 |
+
"score": image_scores,
|
| 294 |
+
}
|
| 295 |
+
)
|
| 296 |
|
| 297 |
return {"objects": batch_objects}
|
| 298 |
|