Created
October 10, 2024 08:16
-
-
Save natzir/8f87bd5e0936c5656f6b9f2858086f2a to your computer and use it in GitHub Desktop.
How to Fool Hive Moderation's AI-Generated Image Detection [Hack]
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"nbformat": 4, | |
"nbformat_minor": 0, | |
"metadata": { | |
"colab": { | |
"provenance": [], | |
"authorship_tag": "ABX9TyPUrrL6O3k3EDxTKsc8TlKV", | |
"include_colab_link": true | |
}, | |
"kernelspec": { | |
"name": "python3", | |
"display_name": "Python 3" | |
}, | |
"language_info": { | |
"name": "python" | |
} | |
}, | |
"cells": [ | |
{ | |
"cell_type": "markdown", | |
"metadata": { | |
"id": "view-in-github", | |
"colab_type": "text" | |
}, | |
"source": [ | |
"<a href=\"https://colab.research.google.com/gist/natzir/8f87bd5e0936c5656f6b9f2858086f2a/how-to-fool-hive-moderation-s-ai-generated-image-detection-hack.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"source": [ | |
"# Bypass Hive Moderation's AI-Generated Image Detection [Hack]\n", | |
"\n", | |
"---\n", | |
"\n", | |
"**Author:** Natzir, Technical SEO / Data Scientist\n", | |
"<br>**Twitter:** [@natzir9](https://twitter.com/natzir9)\n", | |
"\n", | |
"---" | |
], | |
"metadata": { | |
"id": "Mr3HVSLVtJay" | |
} | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": { | |
"colab": { | |
"base_uri": "https://localhost:8080/" | |
}, | |
"id": "ifUCYh3pOscO", | |
"outputId": "2284c281-a75c-4fec-d9b0-b20677ea128a" | |
}, | |
"outputs": [ | |
{ | |
"output_type": "execute_result", | |
"data": { | |
"text/plain": [ | |
"True" | |
] | |
}, | |
"metadata": {}, | |
"execution_count": 31 | |
} | |
], | |
"source": [ | |
"import cv2\n", | |
"import numpy as np\n", | |
"import matplotlib.pyplot as plt\n", | |
"\n", | |
"# Cargar las imágenes\n", | |
"def load_image(path):\n", | |
" img = cv2.imread(path)\n", | |
" img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)\n", | |
" return img\n", | |
"\n", | |
"img_path = 'image.png'\n", | |
"background_path = 'fondo.jpg'\n", | |
"\n", | |
"img = load_image(img_path)\n", | |
"background = load_image(background_path)\n", | |
"\n", | |
"# Redimensionar la imagen\n", | |
"background = cv2.resize(background, (img.shape[1], img.shape[0]))\n", | |
"\n", | |
"# Añadir opacidad\n", | |
"opacity = 0.04\n", | |
"combined_img = cv2.addWeighted(img, 1, background, opacity, 0)\n", | |
"\n", | |
"# Guardar la imagen\n", | |
"cv2.imwrite('modified_image.png', cv2.cvtColor(combined_img, cv2.COLOR_RGB2BGR))" | |
] | |
} | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment