Spaces:
Running
Running
Commit
·
c457ff3
1
Parent(s):
cd6e927
changes image quality check
Browse files
extract_tools.py
CHANGED
@@ -13,7 +13,7 @@ from utils import draw_panoptic_segmentation
|
|
13 |
from tool_utils.clip_segmentation import CLIPSEG
|
14 |
from tool_utils.object_extractor import create_object_extraction_chain
|
15 |
from tool_utils.yolo_world import YoloWorld
|
16 |
-
from tool_utils.
|
17 |
|
18 |
try:
|
19 |
from transformers import BlipProcessor, BlipForConditionalGeneration
|
@@ -170,9 +170,9 @@ def get_image_quality(image_path:str)->str:
|
|
170 |
image = cv2.imread(image_path)
|
171 |
image = cv2.cvtColor(image,cv2.COLOR_BGR2RGB)
|
172 |
|
173 |
-
brightness_text =
|
174 |
-
blurry_text =
|
175 |
-
snr_text =
|
176 |
final_text = "Image properties are :\n{}\n{}\n{}".format(blurry_text, brightness_text,snr_text)
|
177 |
return final_text
|
178 |
|
|
|
13 |
from tool_utils.clip_segmentation import CLIPSEG
|
14 |
from tool_utils.object_extractor import create_object_extraction_chain
|
15 |
from tool_utils.yolo_world import YoloWorld
|
16 |
+
from tool_utils.image_qualitycheck import brightness_check,gaussian_noise_check,snr_check
|
17 |
|
18 |
try:
|
19 |
from transformers import BlipProcessor, BlipForConditionalGeneration
|
|
|
170 |
image = cv2.imread(image_path)
|
171 |
image = cv2.cvtColor(image,cv2.COLOR_BGR2RGB)
|
172 |
|
173 |
+
brightness_text = brightness_check(image)
|
174 |
+
blurry_text = gaussian_noise_check(image)
|
175 |
+
snr_text = snr_check(image)
|
176 |
final_text = "Image properties are :\n{}\n{}\n{}".format(blurry_text, brightness_text,snr_text)
|
177 |
return final_text
|
178 |
|
tool_utils/{image_metadata.py → image_qualitycheck.py}
RENAMED
@@ -4,7 +4,7 @@ import cv2
|
|
4 |
from skimage.restoration import estimate_sigma
|
5 |
import logging
|
6 |
|
7 |
-
def
|
8 |
L,A,B = cv2.split(cv2.cvtColor(image,cv2.COLOR_BGR2LAB))
|
9 |
norm_L = L/np.max(L)
|
10 |
L_mean = np.mean(norm_L)
|
@@ -13,7 +13,7 @@ def image_brightness(image,thresh=0.37):
|
|
13 |
else:
|
14 |
return "image is not bright enough to process object detection and segmentation task "
|
15 |
|
16 |
-
def
|
17 |
# compute the Laplacian of the image and then return the focus
|
18 |
# measure, which is simply the variance of the Laplacian
|
19 |
gray = cv2.cvtColor(img, cv2.COLOR_RGB2GRAY)
|
@@ -27,7 +27,7 @@ def variance_of_laplacian(img,threshould=250):
|
|
27 |
elif laplacian_value >= 3*threshould:
|
28 |
return "Image has high sharpness , no need to process futher."
|
29 |
|
30 |
-
def
|
31 |
snr_text = None
|
32 |
snr_value = estimate_sigma(cv2.cvtColor(image,cv2.COLOR_RGB2GRAY), average_sigmas=False)
|
33 |
logging.info(snr_value)
|
|
|
4 |
from skimage.restoration import estimate_sigma
|
5 |
import logging
|
6 |
|
7 |
+
def brightness_check(image,thresh=0.37):
|
8 |
L,A,B = cv2.split(cv2.cvtColor(image,cv2.COLOR_BGR2LAB))
|
9 |
norm_L = L/np.max(L)
|
10 |
L_mean = np.mean(norm_L)
|
|
|
13 |
else:
|
14 |
return "image is not bright enough to process object detection and segmentation task "
|
15 |
|
16 |
+
def gaussian_noise_check(img,threshould=250):
|
17 |
# compute the Laplacian of the image and then return the focus
|
18 |
# measure, which is simply the variance of the Laplacian
|
19 |
gray = cv2.cvtColor(img, cv2.COLOR_RGB2GRAY)
|
|
|
27 |
elif laplacian_value >= 3*threshould:
|
28 |
return "Image has high sharpness , no need to process futher."
|
29 |
|
30 |
+
def snr_check(image):
|
31 |
snr_text = None
|
32 |
snr_value = estimate_sigma(cv2.cvtColor(image,cv2.COLOR_RGB2GRAY), average_sigmas=False)
|
33 |
logging.info(snr_value)
|