Update app.py
Browse files
app.py
CHANGED
@@ -3,14 +3,19 @@ from roboflow import Roboflow
|
|
3 |
import tempfile
|
4 |
import os
|
5 |
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
|
|
|
|
|
|
|
|
|
|
10 |
|
11 |
# Fungsi untuk menangani input dan output gambar
|
12 |
def detect_objects(image):
|
13 |
-
#
|
14 |
with tempfile.NamedTemporaryFile(delete=False, suffix=".jpg") as temp_file:
|
15 |
image.save(temp_file, format="JPEG")
|
16 |
temp_file_path = temp_file.name
|
@@ -55,4 +60,4 @@ iface = gr.Interface(
|
|
55 |
)
|
56 |
|
57 |
# Menjalankan antarmuka
|
58 |
-
iface.launch()
|
|
|
3 |
import tempfile
|
4 |
import os
|
5 |
|
6 |
+
api_key = os.getenv("ROBOFLOW_API_KEY")
|
7 |
+
workspace = os.getenv("ROBOFLOW_WORKSPACE")
|
8 |
+
project_name = os.getenv("ROBOFLOW_PROJECT")
|
9 |
+
model_version = int(os.getenv("ROBOFLOW_MODEL_VERSION"))
|
10 |
+
|
11 |
+
# Inisialisasi Roboflow menggunakan data yang diambil dari secrets
|
12 |
+
rf = Roboflow(api_key=api_key)
|
13 |
+
project = rf.workspace(workspace).project(project_name)
|
14 |
+
model = project.version(model_version).model
|
15 |
|
16 |
# Fungsi untuk menangani input dan output gambar
|
17 |
def detect_objects(image):
|
18 |
+
# Simpan gambar yang diupload sebagai file sementara
|
19 |
with tempfile.NamedTemporaryFile(delete=False, suffix=".jpg") as temp_file:
|
20 |
image.save(temp_file, format="JPEG")
|
21 |
temp_file_path = temp_file.name
|
|
|
60 |
)
|
61 |
|
62 |
# Menjalankan antarmuka
|
63 |
+
iface.launch()
|