Update app.py
Browse files
app.py
CHANGED
@@ -3,7 +3,6 @@ from roboflow import Roboflow
|
|
3 |
import tempfile
|
4 |
import os
|
5 |
from sahi.slicing import slice_image
|
6 |
-
from sahi import get_sliced_prediction
|
7 |
from sahi.postprocess import postprocess_predictions
|
8 |
|
9 |
# Inisialisasi Roboflow (for model path)
|
@@ -29,12 +28,20 @@ def detect_objects(image):
|
|
29 |
overlap_width_ratio=0.1
|
30 |
)
|
31 |
|
32 |
-
#
|
33 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
34 |
|
35 |
# Postprocess dan gabungkan hasil prediksi
|
36 |
postprocessed_predictions = postprocess_predictions(
|
37 |
-
predictions=
|
38 |
postprocess_type='NMS',
|
39 |
iou_threshold=0.5
|
40 |
)
|
|
|
3 |
import tempfile
|
4 |
import os
|
5 |
from sahi.slicing import slice_image
|
|
|
6 |
from sahi.postprocess import postprocess_predictions
|
7 |
|
8 |
# Inisialisasi Roboflow (for model path)
|
|
|
28 |
overlap_width_ratio=0.1
|
29 |
)
|
30 |
|
31 |
+
# Mendapatkan path-potongan gambar
|
32 |
+
sliced_image_paths = slice_image_result['sliced_image_paths']
|
33 |
+
|
34 |
+
# Menyimpan semua prediksi untuk setiap potongan gambar
|
35 |
+
all_predictions = []
|
36 |
+
|
37 |
+
# Prediksi pada setiap potongan gambar
|
38 |
+
for sliced_image_path in sliced_image_paths:
|
39 |
+
predictions = model.predict(image_path=sliced_image_path).json()
|
40 |
+
all_predictions.extend(predictions['predictions'])
|
41 |
|
42 |
# Postprocess dan gabungkan hasil prediksi
|
43 |
postprocessed_predictions = postprocess_predictions(
|
44 |
+
predictions=all_predictions,
|
45 |
postprocess_type='NMS',
|
46 |
iou_threshold=0.5
|
47 |
)
|