update GIMP examples and eval
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
import os
|
import os
|
||||||
|
from PIL import Image, ImageChops, ImageStat
|
||||||
|
|
||||||
def get_gimp_export_path():
|
def get_gimp_export_path():
|
||||||
# Path to GIMP's configuration file. This example assumes GIMP version 2.10.
|
# Path to GIMP's configuration file. This example assumes GIMP version 2.10.
|
||||||
@@ -21,21 +21,19 @@ def get_gimp_export_path():
|
|||||||
print("GIMP configuration file not found")
|
print("GIMP configuration file not found")
|
||||||
return False
|
return False
|
||||||
|
|
||||||
from PIL import Image, ImageChops, ImageStat
|
def increase_saturation(image1_path: str, image2_path: str) -> float:
|
||||||
|
def calculate_saturation(image):
|
||||||
|
# convert the image to HSV mode
|
||||||
|
hsv_image = image.convert("HSV")
|
||||||
|
|
||||||
def calculate_saturation(image):
|
saturation_channel = hsv_image.split()[1]
|
||||||
# convert the image to HSV mode
|
|
||||||
hsv_image = image.convert("HSV")
|
|
||||||
|
|
||||||
saturation_channel = hsv_image.split()[1]
|
# calculate the mean saturation level
|
||||||
|
stat = ImageStat.Stat(saturation_channel)
|
||||||
|
mean_saturation = stat.mean[0]
|
||||||
|
|
||||||
# calculate the mean saturation level
|
return mean_saturation
|
||||||
stat = ImageStat.Stat(saturation_channel)
|
|
||||||
mean_saturation = stat.mean[0]
|
|
||||||
|
|
||||||
return mean_saturation
|
|
||||||
|
|
||||||
def increase_saturation(image1_path, image2_path):
|
|
||||||
image1 = Image.open(image1_path)
|
image1 = Image.open(image1_path)
|
||||||
image2 = Image.open(image2_path)
|
image2 = Image.open(image2_path)
|
||||||
|
|
||||||
@@ -45,17 +43,17 @@ def increase_saturation(image1_path, image2_path):
|
|||||||
|
|
||||||
return 1 if saturation1 < saturation2 else 0
|
return 1 if saturation1 < saturation2 else 0
|
||||||
|
|
||||||
def calculate_brightness(image):
|
def decrease_brightness(image1_path: str, image2_path: str) -> float:
|
||||||
# Convert the image to grayscale mode
|
def calculate_brightness(image):
|
||||||
grayscale_image = image.convert("L")
|
# Convert the image to grayscale mode
|
||||||
|
grayscale_image = image.convert("L")
|
||||||
|
|
||||||
# Get the image data
|
# Get the image data
|
||||||
pixels = list(grayscale_image.getdata())
|
pixels = list(grayscale_image.getdata())
|
||||||
|
|
||||||
brightness = sum(pixels) / len(pixels)
|
brightness = sum(pixels) / len(pixels)
|
||||||
return brightness
|
return brightness
|
||||||
|
|
||||||
def decrease_brightness(image1_path, image2_path):
|
|
||||||
image1 = Image.open(image1_path)
|
image1 = Image.open(image1_path)
|
||||||
image2 = Image.open(image2_path)
|
image2 = Image.open(image2_path)
|
||||||
|
|
||||||
@@ -65,12 +63,9 @@ def decrease_brightness(image1_path, image2_path):
|
|||||||
return 1 if brightness1 > brightness2 else 0
|
return 1 if brightness1 > brightness2 else 0
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
# 输入两张图片的路径
|
|
||||||
image1_path = "../Downloads/1.png"
|
image1_path = "../Downloads/1.png"
|
||||||
image2_path = "../Downloads/edited_darker.png"
|
image2_path = "../Downloads/edited_darker.png"
|
||||||
|
|
||||||
# 比较图片亮度
|
|
||||||
decrease_brightness(image1_path, image2_path)
|
decrease_brightness(image1_path, image2_path)
|
||||||
|
|
||||||
# 比较图片饱和度
|
|
||||||
increase_saturation(image1_path, image2_path)
|
increase_saturation(image1_path, image2_path)
|
||||||
|
|||||||
@@ -9,8 +9,8 @@
|
|||||||
"parameters": {
|
"parameters": {
|
||||||
"files": [
|
"files": [
|
||||||
{
|
{
|
||||||
"url": "https://drive.usercontent.google.com/download?id=1SIvX9Wimyw6i2UvnoLTNDHIObvDLAsIM&export=download&authuser=0&confirm=t&uuid=a48447ab-13a2-421f-9662-6ffff8f6f6d5&at=APZUnTVRxofs822XxgEv33WwYCkb:1705046264363",
|
"url": "",
|
||||||
"path": "Desktop/1.png"
|
"path": "Desktop/2.png"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@@ -18,7 +18,7 @@
|
|||||||
{
|
{
|
||||||
"type": "open",
|
"type": "open",
|
||||||
"parameters": {
|
"parameters": {
|
||||||
"path": "Desktop/View_Person_Organizational_Summary.docx"
|
"path": "Desktop/2.png"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
@@ -28,15 +28,15 @@
|
|||||||
],
|
],
|
||||||
"evaluator": {
|
"evaluator": {
|
||||||
"func": "increase_saturation",
|
"func": "increase_saturation",
|
||||||
|
"expected": {
|
||||||
|
"type": "cloud_file",
|
||||||
|
"path": "",
|
||||||
|
"dest": "edited_colorful.png"
|
||||||
|
},
|
||||||
"result": {
|
"result": {
|
||||||
"type": "vm_file",
|
"type": "vm_file",
|
||||||
"path": "Desktop/1.png",
|
"path": "Desktop/2.png",
|
||||||
"dest": "1.png"
|
"dest": "2.png"
|
||||||
},
|
|
||||||
"expected": {
|
|
||||||
"type": "vm_file",
|
|
||||||
"path": "Desktop/edited_colorful.png",
|
|
||||||
"dest": "edited_colorful.png"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -18,7 +18,7 @@
|
|||||||
{
|
{
|
||||||
"type": "open",
|
"type": "open",
|
||||||
"parameters": {
|
"parameters": {
|
||||||
"path": "Desktop/View_Person_Organizational_Summary.docx"
|
"path": "Desktop/1.png"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
@@ -28,15 +28,15 @@
|
|||||||
],
|
],
|
||||||
"evaluator": {
|
"evaluator": {
|
||||||
"func": "decrease_brightness",
|
"func": "decrease_brightness",
|
||||||
|
"expected": {
|
||||||
|
"type": "cloud_file",
|
||||||
|
"path": "https://drive.usercontent.google.com/download?id=1M7T5iPv0kWvmZBbdTcRdG45zIpHMtrBn&export=download&authuser=0&confirm=t&uuid=d95db1f8-27dc-4532-9976-ea99c293f53e&at=APZUnTXfpgNCtXDtlqd55LgmrIAj:1705048270986",
|
||||||
|
"dest": "edited_darker.png"
|
||||||
|
},
|
||||||
"result": {
|
"result": {
|
||||||
"type": "vm_file",
|
"type": "vm_file",
|
||||||
"path": "Desktop/1.png",
|
"path": "Desktop/1.png",
|
||||||
"dest": "1.png"
|
"dest": "1.png"
|
||||||
},
|
|
||||||
"expected": {
|
|
||||||
"type": "vm_file",
|
|
||||||
"path": "Desktop/edited_darker.png",
|
|
||||||
"dest": "edited_darker.png"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user