Skip to content

Commit b35d455

Browse files
committed
fix enhance_contranst_yolo
1 parent 4bd80a3 commit b35d455

1 file changed

Lines changed: 15 additions & 1 deletion

File tree

api_ml.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -980,6 +980,17 @@ def enhance_contrast(image):
980980
enhanced = clahe.apply(gray)
981981
return enhanced
982982

983+
def enhance_contrast_rgb(image):
984+
lab = cv2.cvtColor(image, cv2.COLOR_BGR2LAB)
985+
l, a, b = cv2.split(lab)
986+
987+
clahe = cv2.createCLAHE(clipLimit=3.0, tileGridSize=(8, 8))
988+
cl = clahe.apply(l)
989+
990+
enhanced_lab = cv2.merge((cl, a, b))
991+
enhanced_img = cv2.cvtColor(enhanced_lab, cv2.COLOR_LAB2BGR)
992+
return enhanced_img
993+
983994
@app.route("/stars_run_pidinet", methods=["POST"])
984995
def run_pidinet():
985996
try:
@@ -1037,7 +1048,10 @@ def process_image():
10371048

10381049
# /////////////////////////////////////////////
10391050

1040-
results = yolo_model(image_path, imgsz=512)
1051+
img = cv2.imread(image_path)
1052+
enhanced_img = enhance_contrast_rgb(img)
1053+
1054+
results = yolo_model(enhanced_img, imgsz=512)
10411055
boxes = results[0].boxes.xyxy.cpu().numpy()
10421056

10431057
x = point[0]

0 commit comments

Comments
 (0)