LapStore commited on
Commit ·
96ae4b8
1
Parent(s): b68e332
make better error handling
Browse files
server.py
CHANGED
|
@@ -96,13 +96,14 @@ class SegmenterBackground():
|
|
| 96 |
|
| 97 |
results, class_names = self.predict_image(raw_image)
|
| 98 |
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
if len(masks)==0:
|
| 102 |
return ("No thing in image") ,0 # 0 error happened ,if so it's 2 returns ,first is message
|
| 103 |
|
| 104 |
#----------> other methods
|
| 105 |
|
|
|
|
|
|
|
|
|
|
| 106 |
##### put masks on image
|
| 107 |
outpt = self.putMaskImage(raw_image,masks,background_image,blur_radius)
|
| 108 |
|
|
|
|
| 96 |
|
| 97 |
results, class_names = self.predict_image(raw_image)
|
| 98 |
|
| 99 |
+
if len(results[0].masks.data)==0:
|
|
|
|
|
|
|
| 100 |
return ("No thing in image") ,0 # 0 error happened ,if so it's 2 returns ,first is message
|
| 101 |
|
| 102 |
#----------> other methods
|
| 103 |
|
| 104 |
+
masks = [results[0].masks.data[i].cpu().numpy() for i in range(len(results[0].masks.data))]
|
| 105 |
+
|
| 106 |
+
|
| 107 |
##### put masks on image
|
| 108 |
outpt = self.putMaskImage(raw_image,masks,background_image,blur_radius)
|
| 109 |
|