Update app.py
Browse files
app.py
CHANGED
@@ -6,7 +6,7 @@ import os
|
|
6 |
# Inisialisasi Roboflow
|
7 |
rf = Roboflow(api_key="Otg64Ra6wNOgDyjuhMYU")
|
8 |
project = rf.workspace("alat-pelindung-diri").project("nescafe-4base")
|
9 |
-
model = project.version(
|
10 |
|
11 |
# Fungsi untuk menangani input dan output gambar
|
12 |
def detect_objects(image):
|
@@ -16,7 +16,7 @@ def detect_objects(image):
|
|
16 |
temp_file_path = temp_file.name
|
17 |
|
18 |
# Lakukan prediksi pada gambar
|
19 |
-
predictions = model.predict(temp_file_path, confidence=
|
20 |
|
21 |
# Menghitung jumlah objek per kelas
|
22 |
class_count = {}
|
@@ -33,7 +33,7 @@ def detect_objects(image):
|
|
33 |
result_text += f"{class_name}: {count} objek\n"
|
34 |
|
35 |
# Menyimpan gambar dengan prediksi
|
36 |
-
output_image = model.predict(temp_file_path, confidence=
|
37 |
|
38 |
# Hapus file sementara setelah prediksi
|
39 |
os.remove(temp_file_path)
|
|
|
6 |
# Inisialisasi Roboflow
|
7 |
rf = Roboflow(api_key="Otg64Ra6wNOgDyjuhMYU")
|
8 |
project = rf.workspace("alat-pelindung-diri").project("nescafe-4base")
|
9 |
+
model = project.version(36).model
|
10 |
|
11 |
# Fungsi untuk menangani input dan output gambar
|
12 |
def detect_objects(image):
|
|
|
16 |
temp_file_path = temp_file.name
|
17 |
|
18 |
# Lakukan prediksi pada gambar
|
19 |
+
predictions = model.predict(temp_file_path, confidence=70, overlap=80).json()
|
20 |
|
21 |
# Menghitung jumlah objek per kelas
|
22 |
class_count = {}
|
|
|
33 |
result_text += f"{class_name}: {count} objek\n"
|
34 |
|
35 |
# Menyimpan gambar dengan prediksi
|
36 |
+
output_image = model.predict(temp_file_path, confidence=70, overlap=80).save("/tmp/prediction.jpg")
|
37 |
|
38 |
# Hapus file sementara setelah prediksi
|
39 |
os.remove(temp_file_path)
|