Add (ai gen)
This commit is contained in:
@@ -219,7 +219,7 @@ private static function filterImages(array $images, string $proxy, string $user_
|
||||
];
|
||||
$image['color_counts'] = self::isMostlyTextBasedOnUniqueColors($interventionImage);
|
||||
//$image['img'] = $interventionImage;
|
||||
$costs['count-'.$count] = calculate_smartproxy_cost($sizeKb);
|
||||
$costs['count-'.$count] = calculate_smartproxy_cost($sizeKb, 'rotating_global');
|
||||
|
||||
$filteredImages[] = $image;
|
||||
|
||||
@@ -240,17 +240,22 @@ private static function filterImages(array $images, string $proxy, string $user_
|
||||
$colorCounts[] = $image['color_counts'];
|
||||
}
|
||||
|
||||
// Compute the median of the color counts
|
||||
sort($colorCounts);
|
||||
$count = count($colorCounts);
|
||||
$middleIndex = floor($count / 2);
|
||||
$median = $count % 2 === 0 ? ($colorCounts[$middleIndex - 1] + $colorCounts[$middleIndex]) / 2 : $colorCounts[$middleIndex];
|
||||
if (! empty($colorCounts)) {
|
||||
// Compute the median of the color counts
|
||||
sort($colorCounts);
|
||||
$count = count($colorCounts);
|
||||
$middleIndex = floor($count / 2);
|
||||
$median = $count % 2 === 0 ? ($colorCounts[$middleIndex - 1] + $colorCounts[$middleIndex]) / 2 : $colorCounts[$middleIndex];
|
||||
|
||||
// Use the median to filter out the low outliers
|
||||
$threshold = 0.10 * $median; // Adjust this percentage as needed
|
||||
$filteredImages = array_filter($filteredImages, function ($image) use ($threshold) {
|
||||
return $image['color_counts'] > $threshold;
|
||||
});
|
||||
// Use the median to filter out the low outliers
|
||||
$threshold = 0.10 * $median; // Adjust this percentage as needed
|
||||
$filteredImages = array_filter($filteredImages, function ($image) use ($threshold) {
|
||||
return $image['color_counts'] > $threshold;
|
||||
});
|
||||
} else {
|
||||
// No images found
|
||||
$filteredImages = []; // Clear the array or take any other appropriate action
|
||||
}
|
||||
|
||||
usort($filteredImages, function ($a, $b) {
|
||||
return $b['sizeKb'] <=> $a['sizeKb']; // Using the spaceship operator to sort in descending order
|
||||
@@ -296,7 +301,7 @@ private static function getProductImage(array $jsonLdData, string $proxy, string
|
||||
$sizeInKb = strlen($interventionImage->encode()) / 1024; // Convert bytes to kilobytes
|
||||
|
||||
// Calculate the cost
|
||||
$cost = calculate_smartproxy_cost($sizeInKb);
|
||||
$cost = calculate_smartproxy_cost($sizeInKb, 'rotating_global');
|
||||
|
||||
$costs['product_image'] = $cost;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user