muhammadsalmanalfaridzi commited on
Commit
019eaa3
·
verified ·
1 Parent(s): 94f96f8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -6
app.py CHANGED
@@ -3,14 +3,19 @@ from roboflow import Roboflow
3
  import tempfile
4
  import os
5
 
6
- # Inisialisasi Roboflow
7
- rf = Roboflow(api_key="Otg64Ra6wNOgDyjuhMYU")
8
- project = rf.workspace("alat-pelindung-diri").project("nescafe-4base")
9
- model = project.version(46).model
 
 
 
 
 
10
 
11
  # Fungsi untuk menangani input dan output gambar
12
  def detect_objects(image):
13
- # Menyimpan gambar yang diupload sebagai file sementara
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()