Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,10 +1,8 @@
|
|
1 |
import os
|
2 |
os.system('pip install detectron2 -f https://dl.fbaipublicfiles.com/detectron2/wheels/cu102/torch1.9/index.html')
|
3 |
-
|
4 |
-
import gradio as gr
|
5 |
-
import cv2
|
6 |
os.system('pip install torch==1.9.0 torchvision==0.10.0')
|
7 |
|
|
|
8 |
# check pytorch installation:
|
9 |
import torch, torchvision
|
10 |
print(torch.__version__, torch.cuda.is_available())
|
@@ -43,8 +41,7 @@ predictor = DefaultPredictor(cfg)
|
|
43 |
|
44 |
|
45 |
def inference(img):
|
46 |
-
|
47 |
-
im = cv2.imread(img)
|
48 |
outputs = predictor(im)
|
49 |
|
50 |
take = outputs['instances'].scores >= 0.5 #Threshold
|
|
|
1 |
import os
|
2 |
os.system('pip install detectron2 -f https://dl.fbaipublicfiles.com/detectron2/wheels/cu102/torch1.9/index.html')
|
|
|
|
|
|
|
3 |
os.system('pip install torch==1.9.0 torchvision==0.10.0')
|
4 |
|
5 |
+
import gradio as gr
|
6 |
# check pytorch installation:
|
7 |
import torch, torchvision
|
8 |
print(torch.__version__, torch.cuda.is_available())
|
|
|
41 |
|
42 |
|
43 |
def inference(img):
|
44 |
+
im = np.asarray(Image.open(img).convert('RGB'))
|
|
|
45 |
outputs = predictor(im)
|
46 |
|
47 |
take = outputs['instances'].scores >= 0.5 #Threshold
|