{ "cells": [ { "cell_type": "markdown", "id": "3725096f", "metadata": {}, "source": [ "# Detect Lewd Content in Images with Feluda\n", "\n", "This notebook demonstrates how to use the `DetectLewdImages` operator to analyze\n", "images for inappropriate content. It processes a sample image and displays the\n", "probability score indicating likelihood of lewd content." ] }, { "cell_type": "markdown", "id": "38455989", "metadata": {}, "source": [ "[![GitHub](https://img.shields.io/badge/GitHub-View%20Source-blue?logo=github)](https://github.com/tattle-made/feluda/blob/main/docs/examples/detect_lewd_images.ipynb) [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/tattle-made/feluda/blob/main/docs/examples/detect_lewd_images.ipynb)" ] }, { "cell_type": "markdown", "id": "b63d79e1", "metadata": {}, "source": [ "Install dependencies conditionally based on whether the notebook is running in Colab or locally." ] }, { "cell_type": "code", "execution_count": null, "id": "97d892e0", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Running Notebook locally\n", "\u001b[2mUsing Python 3.10.12 environment at: /home/aatman/Aatman/Tattle/feluda/.venv\u001b[0m\n", "\u001b[2mAudited \u001b[1m6 packages\u001b[0m \u001b[2min 11ms\u001b[0m\u001b[0m\n", "CPU times: user 6.38 ms, sys: 4.13 ms, total: 10.5 ms\n", "Wall time: 138 ms\n" ] } ], "source": [ "%%time\n", "import sys\n", "\n", "IN_COLAB = \"google.colab\" in sys.modules\n", "print(\"Running Notebook in Google Colab\" if IN_COLAB else \"Running Notebook locally\")\n", "\n", "if IN_COLAB:\n", " # Since Google Colab has preinstalled libraries like tensorflow and numba, we create a folder called feluda_custom_venv and isolate the environment there.\n", " # This is done to avoid any conflicts with the preinstalled libraries.\n", " %pip install uv\n", " !mkdir -p /content/feluda_custom_venv\n", " !uv pip install --target=/content/feluda_custom_venv --prerelease allow feluda feluda-detect-lewd-images > /dev/null 2>&1\n", "\n", " sys.path.insert(0, \"/content/feluda_custom_venv\")\n", "else:\n", " !uv pip install feluda feluda-detect_lewd-images > /dev/null 2>&1" ] }, { "cell_type": "markdown", "id": "35a99415-ca33-4395-8bf0-84b109bcd382", "metadata": {}, "source": [ "We'll use one operator for this example." ] }, { "cell_type": "code", "execution_count": null, "id": "2143fc54", "metadata": {}, "outputs": [ { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "e23195e656ce427cb7e29e1258de042f", "version_major": 2, "version_minor": 0 }, "text/plain": [ "Fetching 5 files: 0%| | 0/5 [00:00