crabbly commited on
Commit
70bd897
·
verified ·
1 Parent(s): b8a666f

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +3 -8
main.py CHANGED
@@ -17,8 +17,8 @@ import uvicorn
17
  from skimage import color
18
  import hashlib
19
 
20
- # Speed up YOLO for Hugging Face's 2-core CPUs
21
- torch.set_num_threads(2)
22
 
23
  # --- CONFIGURATION ---
24
  MODEL_PATH = "best.pt"
@@ -596,12 +596,7 @@ class WatermelonProcessor:
596
  cv2.circle(output, pt_bot, 8, (255, 255, 255), -1)
597
 
598
  cv2.polylines(output, [fit_pts.astype(np.int32)], True, (0, 255, 0), 3)
599
- # --- SPEED FIX: Shrink the preview image to eliminate Network/Base64 Lag ---
600
- prev_h, prev_w = output.shape[:2]
601
- if max(prev_h, prev_w) > 640:
602
- p_scale = 640.0 / max(prev_h, prev_w)
603
- output = cv2.resize(output, (int(prev_w * p_scale), int(prev_h * p_scale)), interpolation=cv2.INTER_AREA)
604
-
605
  _, buffer = cv2.imencode(".jpg", output, [cv2.IMWRITE_JPEG_QUALITY, 80])
606
  img_base64 = base64.b64encode(buffer).decode("utf-8")
607
  mark("render")
 
17
  from skimage import color
18
  import hashlib
19
 
20
+ # OOM PREVENTION
21
+ torch.set_num_threads(1)
22
 
23
  # --- CONFIGURATION ---
24
  MODEL_PATH = "best.pt"
 
596
  cv2.circle(output, pt_bot, 8, (255, 255, 255), -1)
597
 
598
  cv2.polylines(output, [fit_pts.astype(np.int32)], True, (0, 255, 0), 3)
599
+
 
 
 
 
 
600
  _, buffer = cv2.imencode(".jpg", output, [cv2.IMWRITE_JPEG_QUALITY, 80])
601
  img_base64 = base64.b64encode(buffer).decode("utf-8")
602
  mark("render")