Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,26 +1,41 @@
|
|
1 |
from PIL import Image
|
2 |
-
import sys
|
3 |
-
|
4 |
-
import
|
5 |
-
import torch, detectron2
|
6 |
import pandas as pd
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
7 |
from detectron2.utils.logger import setup_logger
|
8 |
setup_logger()
|
9 |
-
import numpy as np
|
10 |
-
# import os, json, cv2, random
|
11 |
from detectron2 import model_zoo
|
12 |
from detectron2.engine import DefaultPredictor
|
13 |
from detectron2.config import get_cfg
|
14 |
-
|
15 |
-
|
16 |
-
import
|
17 |
-
|
18 |
-
|
19 |
-
#
|
20 |
-
|
21 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
22 |
|
23 |
-
print("hello world")
|
24 |
|
25 |
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
|
26 |
num_classes = 15
|
|
|
1 |
from PIL import Image
|
2 |
+
import sys
|
3 |
+
import os
|
4 |
+
import distutils.core
|
|
|
5 |
import pandas as pd
|
6 |
+
import numpy as np
|
7 |
+
import torch
|
8 |
+
import torch.nn as nn
|
9 |
+
from torchvision import transforms, models
|
10 |
+
import gradio as gr
|
11 |
+
|
12 |
+
|
13 |
+
sys.path.insert(0, os.path.abspath('./detectron2-main'))
|
14 |
+
import detectron2
|
15 |
from detectron2.utils.logger import setup_logger
|
16 |
setup_logger()
|
|
|
|
|
17 |
from detectron2 import model_zoo
|
18 |
from detectron2.engine import DefaultPredictor
|
19 |
from detectron2.config import get_cfg
|
20 |
+
import os, json, cv2, random
|
21 |
+
from detectron2.utils.visualizer import Visualizer
|
22 |
+
from detectron2.data import MetadataCatalog, DatasetCatalog
|
23 |
+
|
24 |
+
|
25 |
+
# Example of setting up detectron2 configuration
|
26 |
+
cfg = get_cfg()
|
27 |
+
cfg.MODEL.DEVICE = "cuda" if torch.cuda.is_available() else "cpu"
|
28 |
+
cfg.MODEL.WEIGHTS = model_zoo.get_checkpoint_url("COCO-Detection/faster_rcnn_R_50_FPN_3x.yaml")
|
29 |
+
cfg.MODEL.ROI_HEADS.NUM_CLASSES = 80
|
30 |
+
# Example of creating a default predictor with detectron2
|
31 |
+
predictor = DefaultPredictor(cfg)
|
32 |
+
|
33 |
+
|
34 |
+
|
35 |
+
SEED = 2024
|
36 |
+
torch.manual_seed(SEED)
|
37 |
+
np.random.seed(SEED)
|
38 |
|
|
|
39 |
|
40 |
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
|
41 |
num_classes = 15
|