Spaces:
Paused
Paused
Update server.py
Browse files
server.py
CHANGED
|
@@ -353,6 +353,7 @@ def predict():
|
|
| 353 |
|
| 354 |
@app.route('/predict_4x4', methods=['POST'])
|
| 355 |
def predict_4x4():
|
|
|
|
| 356 |
import time
|
| 357 |
start_time = time.time()
|
| 358 |
try:
|
|
@@ -378,6 +379,9 @@ def predict_4x4():
|
|
| 378 |
if image_pil is None: return jsonify({"error": "Invalid image data"}), 400
|
| 379 |
image_cv2 = cv2.cvtColor(np.array(image_pil), cv2.COLOR_RGB2BGR)
|
| 380 |
|
|
|
|
|
|
|
|
|
|
| 381 |
results = model(image_cv2, verbose=False)
|
| 382 |
indices_to_click = []
|
| 383 |
if results and results[0].masks is not None and results[0].boxes is not None:
|
|
|
|
| 353 |
|
| 354 |
@app.route('/predict_4x4', methods=['POST'])
|
| 355 |
def predict_4x4():
|
| 356 |
+
"""Optimized 4x4 prediction endpoint"""
|
| 357 |
import time
|
| 358 |
start_time = time.time()
|
| 359 |
try:
|
|
|
|
| 379 |
if image_pil is None: return jsonify({"error": "Invalid image data"}), 400
|
| 380 |
image_cv2 = cv2.cvtColor(np.array(image_pil), cv2.COLOR_RGB2BGR)
|
| 381 |
|
| 382 |
+
# baru perbaikan: Baris ini hilang dan menyebabkan NameError. Kita tambahkan kembali.
|
| 383 |
+
grid_images, grid_coordinates = divide_image_into_4x4_grid(image_cv2)
|
| 384 |
+
|
| 385 |
results = model(image_cv2, verbose=False)
|
| 386 |
indices_to_click = []
|
| 387 |
if results and results[0].masks is not None and results[0].boxes is not None:
|