Skip to content

Commit 1e741d9

Browse files
authored
Merge pull request #33 from Copyleaks/add-ai-image-detection
Add support for image detection
2 parents a25d47c + 43d4178 commit 1e741d9

31 files changed

+1359
-268
lines changed

README.md

Lines changed: 39 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,6 @@ Use the AI detection client to determine if content was generated by artificial
106106
// --- Your Credentials ---
107107
$EMAIL_ADDRESS = 'YOUR_EMAIL_ADDRESS';
108108
$KEY = 'YOUR_API_KEY';
109-
$WEBHOOK_URL = 'https://your-server.com/webhook/{STATUS}';
110109
// --------------------
111110

112111
$sampleText = "Lions are social animals, living in groups called prides, typically consisting of several females, their offspring, and a few males. Female lions are the primary hunters, working together to catch prey. Lions are known for their strength, teamwork, and complex social structures.";
@@ -135,7 +134,6 @@ Get intelligent suggestions for improving grammar, spelling, style, and overall
135134
// --- Your Credentials ---
136135
$EMAIL_ADDRESS = 'YOUR_EMAIL_ADDRESS';
137136
$KEY = 'YOUR_API_KEY';
138-
$WEBHOOK_URL = 'https://your-server.com/webhook/{STATUS}';
139137
// --------------------
140138

141139
$sampleText = "Lions are the only cat that live in groups, called pride. A prides typically consists of a few adult males, several feales, and their offspring. This social structure is essential for hunting and raising young cubs. Female lions, or lionesses are the primary hunters of the prid. They work together in cordinated groups to take down prey usually targeting large herbiores like zbras, wildebeest and buffalo. Their teamwork and strategy during hunts highlight the intelligence and coperation that are key to their survival.";
@@ -175,7 +173,6 @@ Scan and moderate text content for unsafe, inappropriate, or policy-violating ma
175173
// --- Your Credentials ---
176174
$EMAIL_ADDRESS = 'YOUR_EMAIL_ADDRESS';
177175
$KEY = 'YOUR_API_KEY';
178-
$WEBHOOK_URL = 'https://your-server.com/webhook/{STATUS}';
179176
// --------------------
180177

181178
$labelsArray=[
@@ -208,7 +205,45 @@ For a full guide please refer to our step by step [Guide](https://docs.copyleaks
208205

209206
For a detailed understanding of the Text moderation process, refer to the Copyleaks text moderation Endpoint [Documentation](https://docs.copyleaks.com/reference/actions/text-moderation/check/)
210207
##
211-
## Further Resources
208+
### AI Image Detection
209+
Determine if a given image was generated or partially generated by an AI.
210+
211+
```php
212+
<?php
213+
require_once(__DIR__ . '/vendor/autoload.php');
214+
215+
use Copyleaks\Copyleaks;
216+
use Copyleaks\CopyleaksAuthToken;
217+
use Copyleaks\CopyleaksAiImageDetectionRequestModel;
218+
use Copyleaks\CopyleaksAiImageDetectionResponseModel;
219+
use Copyleaks\CopyleaksAiImageDetectionModels;
220+
// --- Your Credentials ---
221+
$EMAIL_ADDRESS = 'YOUR_EMAIL_ADDRESS';
222+
$KEY = 'YOUR_API_KEY';
223+
// --
224+
225+
// Read and encode your image file to base64
226+
$imagePath = "path/to/your/image.jpg"; // Update this path to your actual image file
227+
228+
$base64Image = base64_encode(file_get_contents($imagePath));
229+
$fileName = basename($imagePath);
230+
231+
$submission = new CopyleaksAiImageDetectionRequestModel(
232+
$base64Image,
233+
$fileName,
234+
CopyleaksAiImageDetectionModels::AI_IMAGE_1_ULTRA,
235+
true // Use sandbox mode for testing
236+
);
237+
238+
$response = $copyleaks->aiImageDetectionClient->submit($authToken, time(), $submission);
239+
$imageDetectionResponse = CopyleaksAiImageDetectionResponseModel::fromArray(json_decode(json_encode($response), true));
240+
```
241+
For a full guide please refer to our step by step [Guide](https://docs.copyleaks.com/guides/ai-detector/ai-image-detection/)
242+
243+
For a detailed understanding of the AI image detection process, refer to the Copyleaks AI image detection Endpoint [Documentation](https://docs.copyleaks.com/reference/actions/ai-image-detector/check/)
244+
245+
##
246+
### Further Resources
212247

213248
* **Copyleaks API Dashboard:** Manage your API keys, monitor usage, and view analytics from your personalized dashboard. [Access Dashboard](https://api.copyleaks.com/dashboard)
214249
* **Copyleaks SDK Documentation:** Explore comprehensive guides, API references, and code examples for seamless integration. [Read Documentation](https://docs.copyleaks.com/resources/sdks/overview/)

0 commit comments

Comments
 (0)