Update app.py
Browse files
app.py
CHANGED
|
@@ -1,4 +1,12 @@
|
|
|
|
|
| 1 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
import gradio as gr
|
| 3 |
import cv2
|
| 4 |
import numpy as np
|
|
@@ -6,7 +14,7 @@ from detectron2.config import get_cfg
|
|
| 6 |
from detectron2.engine import DefaultPredictor
|
| 7 |
from detectron2.utils.visualizer import Visualizer, ColorMode
|
| 8 |
from detectron2.data import MetadataCatalog
|
| 9 |
-
|
| 10 |
|
| 11 |
# Load model
|
| 12 |
cfg = get_cfg()
|
|
|
|
| 1 |
+
import os, sys, subprocess
|
| 2 |
|
| 3 |
+
# install detectron2 during space build
|
| 4 |
+
if not os.path.exists("detectron2"):
|
| 5 |
+
subprocess.run(
|
| 6 |
+
["pip", "install",
|
| 7 |
+
"git+https://github.com/facebookresearch/detectron2.git"],
|
| 8 |
+
check=True
|
| 9 |
+
)
|
| 10 |
import gradio as gr
|
| 11 |
import cv2
|
| 12 |
import numpy as np
|
|
|
|
| 14 |
from detectron2.engine import DefaultPredictor
|
| 15 |
from detectron2.utils.visualizer import Visualizer, ColorMode
|
| 16 |
from detectron2.data import MetadataCatalog
|
| 17 |
+
|
| 18 |
|
| 19 |
# Load model
|
| 20 |
cfg = get_cfg()
|