machinelearning

Machine learning code
git clone git://git.laack.co/machinelearning.git
Log | Files | Refs

TrickImageDetection.ipynb (1991B)


      1 {
      2  "cells": [
      3   {
      4    "cell_type": "code",
      5    "execution_count": 174,
      6    "metadata": {},
      7    "outputs": [],
      8    "source": [
      9     "from PIL import Image, ImageFilter\n",
     10     "import random\n",
     11     "from random import gauss\n",
     12     "\n",
     13     "img = Image.open('img/AiImage.png')\n",
     14     "img = img.convert('RGB')\n",
     15     "img = img.crop(box=(250, 0, 950, 550))\n",
     16     "\n",
     17     "\n",
     18     "\n",
     19     "\n",
     20     "def rndNoise():\n",
     21     "    return round(gauss(0,2))\n",
     22     "\n",
     23     "\n",
     24     "\n",
     25     "img = img.filter(ImageFilter.SHARPEN)\n",
     26     "img = img.filter(ImageFilter.SHARPEN)\n",
     27     "img = img.filter(ImageFilter.SHARPEN)\n",
     28     "\n",
     29     "pixels = img.load() # Pixel map\n",
     30     "\n",
     31     "\n",
     32     "\n",
     33     "\n",
     34     "img.save('img/ManipulatedImg.png')"
     35    ]
     36   },
     37   {
     38    "cell_type": "code",
     39    "execution_count": 172,
     40    "metadata": {},
     41    "outputs": [
     42     {
     43      "data": {
     44       "text/plain": [
     45        "(550, 700, 3)"
     46       ]
     47      },
     48      "execution_count": 172,
     49      "metadata": {},
     50      "output_type": "execute_result"
     51     }
     52    ],
     53    "source": [
     54     "import numpy as np\n",
     55     "arr = np.array(img)\n",
     56     "arr.shape"
     57    ]
     58   },
     59   {
     60    "cell_type": "markdown",
     61    "metadata": {},
     62    "source": [
     63     "* 1400 = x\n",
     64     "* 933 = y"
     65    ]
     66   },
     67   {
     68    "cell_type": "code",
     69    "execution_count": 173,
     70    "metadata": {},
     71    "outputs": [
     72     {
     73      "data": {
     74       "text/plain": [
     75        "(700, 3)"
     76       ]
     77      },
     78      "execution_count": 173,
     79      "metadata": {},
     80      "output_type": "execute_result"
     81     }
     82    ],
     83    "source": [
     84     "arr[0].shape"
     85    ]
     86   }
     87  ],
     88  "metadata": {
     89   "kernelspec": {
     90    "display_name": ".venv",
     91    "language": "python",
     92    "name": "python3"
     93   },
     94   "language_info": {
     95    "codemirror_mode": {
     96     "name": "ipython",
     97     "version": 3
     98    },
     99    "file_extension": ".py",
    100    "mimetype": "text/x-python",
    101    "name": "python",
    102    "nbconvert_exporter": "python",
    103    "pygments_lexer": "ipython3",
    104    "version": "3.11.2"
    105   }
    106  },
    107  "nbformat": 4,
    108  "nbformat_minor": 2
    109 }