goldenbrown commited on
Commit
04cd511
1 Parent(s): 7303d67

Update index.html

Browse files
Files changed (1) hide show
  1. index.html +13 -29
index.html CHANGED
@@ -37,39 +37,23 @@
37
  resultDiv.textContent = 'Checking...';
38
 
39
  try {
40
- const reader = new FileReader();
41
- reader.readAsDataURL(file);
 
 
42
 
43
- reader.onloadend = async function () {
44
- const base64Image = reader.result.split(',')[1]; // Get base64 image without metadata
45
 
46
- const response = await fetch('https://api-inference.huggingface.co/models/Organika/sdxl-detector', {
47
- method: 'POST',
48
- headers: {
49
- 'Authorization': 'Bearer YOUR_HUGGINGFACE_API_KEY',
50
- 'Content-Type': 'application/json'
51
- },
52
- body: JSON.stringify({
53
- inputs: base64Image,
54
- options: {
55
- wait_for_model: true
56
- }
57
- })
58
- });
59
-
60
- const result = await response.json();
61
-
62
- if (response.ok) {
63
- const isAI = result[0]?.label === "AI-generated";
64
- if (isAI) {
65
- resultDiv.textContent = "This image is AI-generated.";
66
- } else {
67
- resultDiv.textContent = "This image is not AI-generated.";
68
- }
69
  } else {
70
- resultDiv.textContent = "Error occurred: " + result.error;
71
  }
72
- };
 
 
73
  } catch (error) {
74
  resultDiv.textContent = "Error occurred while checking the image.";
75
  }
 
37
  resultDiv.textContent = 'Checking...';
38
 
39
  try {
40
+ const response = await fetch('/check_image', {
41
+ method: 'POST',
42
+ body: formData
43
+ });
44
 
45
+ const result = await response.json();
 
46
 
47
+ if (response.ok) {
48
+ const isAI = result[0]?.label === "AI-generated";
49
+ if (isAI) {
50
+ resultDiv.textContent = "This image is AI-generated.";
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
51
  } else {
52
+ resultDiv.textContent = "This image is not AI-generated.";
53
  }
54
+ } else {
55
+ resultDiv.textContent = "Error occurred: " + result.error;
56
+ }
57
  } catch (error) {
58
  resultDiv.textContent = "Error occurred while checking the image.";
59
  }