Spaces:
Sleeping
Sleeping
Fix: update app and requirement
Browse files- app.py +3 -4
- requirements.txt +1 -0
app.py
CHANGED
|
@@ -47,7 +47,6 @@ class Pytorch_model:
|
|
| 47 |
:param min_area: 小于该尺度的bbox忽略
|
| 48 |
:return:
|
| 49 |
'''
|
| 50 |
-
img = cv2.imread(img)
|
| 51 |
if self.img_channel == 3:
|
| 52 |
img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
|
| 53 |
h, w = img.shape[:2]
|
|
@@ -59,10 +58,10 @@ class Pytorch_model:
|
|
| 59 |
|
| 60 |
tensor = tensor.to(self.device)
|
| 61 |
with torch.no_grad():
|
| 62 |
-
torch.cuda.synchronize(self.device)
|
| 63 |
start = time.time()
|
| 64 |
preds = self.net(tensor)[0]
|
| 65 |
-
torch.cuda.synchronize(self.device)
|
| 66 |
scale = (preds.shape[2] / w, preds.shape[1] / h)
|
| 67 |
t = time.time() - start
|
| 68 |
|
|
@@ -112,7 +111,7 @@ class Pytorch_model:
|
|
| 112 |
|
| 113 |
def run(img):
|
| 114 |
# os.environ["CUDA_VISIBLE_DEVICES"] = "5"
|
| 115 |
-
model_path = '
|
| 116 |
|
| 117 |
# init model
|
| 118 |
model = Pytorch_model(model_path, gpu_id = None) ## set GPU id or None if you only have cpu
|
|
|
|
| 47 |
:param min_area: 小于该尺度的bbox忽略
|
| 48 |
:return:
|
| 49 |
'''
|
|
|
|
| 50 |
if self.img_channel == 3:
|
| 51 |
img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
|
| 52 |
h, w = img.shape[:2]
|
|
|
|
| 58 |
|
| 59 |
tensor = tensor.to(self.device)
|
| 60 |
with torch.no_grad():
|
| 61 |
+
# torch.cuda.synchronize(self.device)
|
| 62 |
start = time.time()
|
| 63 |
preds = self.net(tensor)[0]
|
| 64 |
+
# torch.cuda.synchronize(self.device)
|
| 65 |
scale = (preds.shape[2] / w, preds.shape[1] / h)
|
| 66 |
t = time.time() - start
|
| 67 |
|
|
|
|
| 111 |
|
| 112 |
def run(img):
|
| 113 |
# os.environ["CUDA_VISIBLE_DEVICES"] = "5"
|
| 114 |
+
model_path = 'MobileNetv2_best_loss.pth'
|
| 115 |
|
| 116 |
# init model
|
| 117 |
model = Pytorch_model(model_path, gpu_id = None) ## set GPU id or None if you only have cpu
|
requirements.txt
CHANGED
|
@@ -5,3 +5,4 @@ numpy
|
|
| 5 |
pyclipper
|
| 6 |
gradio
|
| 7 |
matplotlib
|
|
|
|
|
|
| 5 |
pyclipper
|
| 6 |
gradio
|
| 7 |
matplotlib
|
| 8 |
+
shapely
|