Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -20,9 +20,14 @@ from detectron2.engine import DefaultPredictor
|
|
| 20 |
from detectron2.config import get_cfg
|
| 21 |
from detectron2.utils.visualizer import Visualizer
|
| 22 |
from detectron2.data import MetadataCatalog
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
|
| 27 |
cfg = get_cfg()
|
| 28 |
cfg.merge_from_file("./configs/detectron2/faster_rcnn_R_50_FPN_3x.yaml")
|
|
@@ -30,7 +35,7 @@ cfg.MODEL.ROI_HEADS.NUM_CLASSES = 2
|
|
| 30 |
cfg.MODEL.WEIGHTS = model_path
|
| 31 |
|
| 32 |
my_metadata = MetadataCatalog.get("dbmdz_coco_all")
|
| 33 |
-
my_metadata.thing_classes = ["
|
| 34 |
|
| 35 |
if not torch.cuda.is_available():
|
| 36 |
cfg.MODEL.DEVICE = "cpu"
|
|
|
|
| 20 |
from detectron2.config import get_cfg
|
| 21 |
from detectron2.utils.visualizer import Visualizer
|
| 22 |
from detectron2.data import MetadataCatalog
|
| 23 |
+
from detectron2.data.datasets import register_coco_instances
|
| 24 |
+
try:
|
| 25 |
+
register_coco_instances("Fiber", {}, "./labels-fiver.json", "/content/Fiber")
|
| 26 |
+
Fiber_metadata = MetadataCatalog.get("Fiber")
|
| 27 |
+
dataset_dicts = DatasetCatalog.get("Fiber")
|
| 28 |
+
except:
|
| 29 |
+
print("there is an issue")
|
| 30 |
+
model_path = "https://huggingface.com/mosidi/detectron2-model-demo/resolve/main/model_final.pth"
|
| 31 |
|
| 32 |
cfg = get_cfg()
|
| 33 |
cfg.merge_from_file("./configs/detectron2/faster_rcnn_R_50_FPN_3x.yaml")
|
|
|
|
| 35 |
cfg.MODEL.WEIGHTS = model_path
|
| 36 |
|
| 37 |
my_metadata = MetadataCatalog.get("dbmdz_coco_all")
|
| 38 |
+
my_metadata.thing_classes = ["Fiber", "Fiber"]
|
| 39 |
|
| 40 |
if not torch.cuda.is_available():
|
| 41 |
cfg.MODEL.DEVICE = "cpu"
|