Update utils/object_detection_brainai.py
Browse files
utils/object_detection_brainai.py
CHANGED
|
@@ -17,12 +17,7 @@ class ObjectDetectionModel():
|
|
| 17 |
with open("utils/game_classes.txt", "r") as file:
|
| 18 |
self.game_classes = [line.strip() for line in file if line.strip()]
|
| 19 |
|
| 20 |
-
|
| 21 |
-
result = self.model(img)
|
| 22 |
-
img_plot = result[0].plot()
|
| 23 |
-
|
| 24 |
-
return img_plot
|
| 25 |
-
|
| 26 |
def process_image(self, img):
|
| 27 |
|
| 28 |
if isinstance(img, np.ndarray):
|
|
@@ -30,6 +25,8 @@ class ObjectDetectionModel():
|
|
| 30 |
else:
|
| 31 |
uploaded_img = PIL.Image.open(img)
|
| 32 |
uploaded_img_cv = np.array(uploaded_img)
|
|
|
|
|
|
|
| 33 |
|
| 34 |
result = self.model(uploaded_img_cv, verbose=False)
|
| 35 |
img_plot = result[0].plot()
|
|
|
|
| 17 |
with open("utils/game_classes.txt", "r") as file:
|
| 18 |
self.game_classes = [line.strip() for line in file if line.strip()]
|
| 19 |
|
| 20 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
def process_image(self, img):
|
| 22 |
|
| 23 |
if isinstance(img, np.ndarray):
|
|
|
|
| 25 |
else:
|
| 26 |
uploaded_img = PIL.Image.open(img)
|
| 27 |
uploaded_img_cv = np.array(uploaded_img)
|
| 28 |
+
if uploaded_img_cv.shape[-1] == 4:
|
| 29 |
+
uploaded_img_cv = cv2.cvtColor(uploaded_img_cv, cv2.COLOR_RGBA2RGB)
|
| 30 |
|
| 31 |
result = self.model(uploaded_img_cv, verbose=False)
|
| 32 |
img_plot = result[0].plot()
|