зеркало из
				https://github.com/ssciwr/AMMICO.git
				synced 2025-11-04 07:56:04 +02:00 
			
		
		
		
	* colors expression by KMean algorithm * object detection by imageai * object detection by cvlib * add encapsulation of object detection * remove encapsulation of objdetect v0 * objects expression to dict * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * added imageai to requirements * add objects to dictionary * update for AnalysisMethod baseline * add objects dection support explore_analysis display * extend python version of misinf to allow imageai * account for older python * use global functionality for dict to csv convert * update for docker build * docker will build now but ipywidgets still not working * test code * include test data folder in repo * add some sample images * load cvs labels to dict * add test data * retrigger checks * add map to human coding * get orders from dict, missing dep * add module to test accuracy * retrigger checks * retrigger checks * now removing imageai * removed imageai * move labelmanager to analyse * multiple faces in mydict * fix pre-commit issues * map mydict * hide imageai * objects default using cvlib, isolate and disable imageai * correct python version * refactor faces tests * refactor objects tests * sonarcloud issues * refactor utils tests * address code smells * update readme * update notebook without imageai Co-authored-by: Ma Xianghe <825074348@qq.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: iulusoy <inga.ulusoy@uni-heidelberg.de>
		
			
				
	
	
		
			148 строки
		
	
	
		
			4.5 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
			
		
		
	
	
			148 строки
		
	
	
		
			4.5 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
{
 | 
						||
 "cells": [
 | 
						||
  {
 | 
						||
   "cell_type": "markdown",
 | 
						||
   "metadata": {},
 | 
						||
   "source": [
 | 
						||
    "<span style =\" color : green ;font - weight : bold \">ImageAI for Object Detection</span>\n",
 | 
						||
    "http://imageai.org/#features"
 | 
						||
   ]
 | 
						||
  },
 | 
						||
  {
 | 
						||
   "cell_type": "markdown",
 | 
						||
   "metadata": {},
 | 
						||
   "source": [
 | 
						||
    "ImageAI provides API to recognize 1000 different objects in a picture using pre-trained models that were trained on the ImageNet-1000 dataset. The model implementations provided are SqueezeNet, ResNet, InceptionV3 and DenseNet.\n",
 | 
						||
    "</p>\n",
 | 
						||
    "ImageAI provides API to detect, locate and identify 80 most common objects in everyday life in a picture using pre-trained models that were trained on the COCO Dataset. The model implementations provided include RetinaNet, YOLOv3 and TinyYOLOv3."
 | 
						||
   ]
 | 
						||
  },
 | 
						||
  {
 | 
						||
   "cell_type": "markdown",
 | 
						||
   "metadata": {},
 | 
						||
   "source": [
 | 
						||
    "There are 80 possible objects that you can detect with the\n",
 | 
						||
    "ObjectDetection class, and they are as seen below.\n",
 | 
						||
    "\n",
 | 
						||
    "    person,   bicycle,   car,   motorcycle,   airplane,\n",
 | 
						||
    "    bus,   train,   truck,   boat,   traffic light,   fire hydrant,   stop_sign,\n",
 | 
						||
    "    parking meter,   bench,   bird,   cat,   dog,   horse,   sheep,   cow,   elephant,   bear,   zebra,\n",
 | 
						||
    "    giraffe,   backpack,   umbrella,   handbag,   tie,   suitcase,   frisbee,   skis,   snowboard,\n",
 | 
						||
    "    sports ball,   kite,   baseball bat,   baseball glove,   skateboard,   surfboard,   tennis racket,\n",
 | 
						||
    "    bottle,   wine glass,   cup,   fork,   knife,   spoon,   bowl,   banana,   apple,   sandwich,   orange,\n",
 | 
						||
    "    broccoli,   carrot,   hot dog,   pizza,   donot,   cake,   chair,   couch,   potted plant,   bed,\n",
 | 
						||
    "    dining table,   toilet,   tv,   laptop,   mouse,   remote,   keyboard,   cell phone,   microwave,\n",
 | 
						||
    "    oven,   toaster,   sink,   refrigerator,   book,   clock,   vase,   scissors,   teddy bear,   hair dryer,\n",
 | 
						||
    "    toothbrush."
 | 
						||
   ]
 | 
						||
  },
 | 
						||
  {
 | 
						||
   "cell_type": "markdown",
 | 
						||
   "metadata": {},
 | 
						||
   "source": [
 | 
						||
    "<p>requirements:</p>\n",
 | 
						||
    "<p>tensorflow==1.15.0</p>\n",
 | 
						||
    "<p>numpy==1.19.5</p>\n",
 | 
						||
    "<p>scipy==1.4.1</p>\n",
 | 
						||
    "<p>keras==2.1.0</p>\n",
 | 
						||
    "<p>imageai==2.0.2</p>\n",
 | 
						||
    "\n",
 | 
						||
    "<p>Or update to newest version, see https://github.com/OlafenwaMoses/ImageAI</p>"
 | 
						||
   ]
 | 
						||
  },
 | 
						||
  {
 | 
						||
   "cell_type": "markdown",
 | 
						||
   "metadata": {},
 | 
						||
   "source": [
 | 
						||
    "Download the RetinaNet model file for object detection\n",
 | 
						||
    "\n",
 | 
						||
    "https://github.com/OlafenwaMoses/ImageAI/releases/download/1.0/resnet50_coco_best_v2.0.1.h5"
 | 
						||
   ]
 | 
						||
  },
 | 
						||
  {
 | 
						||
   "cell_type": "code",
 | 
						||
   "execution_count": null,
 | 
						||
   "metadata": {},
 | 
						||
   "outputs": [],
 | 
						||
   "source": [
 | 
						||
    "from imageai.Detection import ObjectDetection\n",
 | 
						||
    "import matplotlib.pyplot as plt\n",
 | 
						||
    "import skimage.io\n",
 | 
						||
    "import os"
 | 
						||
   ]
 | 
						||
  },
 | 
						||
  {
 | 
						||
   "cell_type": "code",
 | 
						||
   "execution_count": null,
 | 
						||
   "metadata": {},
 | 
						||
   "outputs": [],
 | 
						||
   "source": [
 | 
						||
    "execution_path = os.getcwd()\n",
 | 
						||
    "\n",
 | 
						||
    "detector = ObjectDetection()\n",
 | 
						||
    "detector.setModelTypeAsRetinaNet()\n",
 | 
						||
    "detector.setModelPath(os.path.join(execution_path, \"resnet50_coco_best_v2.0.1.h5\"))\n",
 | 
						||
    "detector.loadModel()"
 | 
						||
   ]
 | 
						||
  },
 | 
						||
  {
 | 
						||
   "cell_type": "code",
 | 
						||
   "execution_count": null,
 | 
						||
   "metadata": {},
 | 
						||
   "outputs": [],
 | 
						||
   "source": [
 | 
						||
    "detections = detector.detectObjectsFromImage(\n",
 | 
						||
    "    input_image=os.path.join(execution_path, \"image.jpg\"),\n",
 | 
						||
    "    output_image_path=os.path.join(execution_path, \"imagenew.jpg\"),\n",
 | 
						||
    ")\n",
 | 
						||
    "\n",
 | 
						||
    "for eachObject in detections:\n",
 | 
						||
    "    print(eachObject[\"name\"], \" : \", eachObject[\"percentage_probability\"])"
 | 
						||
   ]
 | 
						||
  },
 | 
						||
  {
 | 
						||
   "cell_type": "code",
 | 
						||
   "execution_count": null,
 | 
						||
   "metadata": {},
 | 
						||
   "outputs": [],
 | 
						||
   "source": [
 | 
						||
    "image = skimage.io.imread(\"image.jpg\")\n",
 | 
						||
    "imagenew = skimage.io.imread(\"imagenew.jpg\")\n",
 | 
						||
    "\n",
 | 
						||
    "_, axis = plt.subplots(1, 2)\n",
 | 
						||
    "axis[0].imshow(image, cmap=\"gray\")\n",
 | 
						||
    "axis[1].imshow(imagenew, cmap=\"gray\")\n",
 | 
						||
    "plt.show()"
 | 
						||
   ]
 | 
						||
  },
 | 
						||
  {
 | 
						||
   "cell_type": "code",
 | 
						||
   "execution_count": null,
 | 
						||
   "metadata": {},
 | 
						||
   "outputs": [],
 | 
						||
   "source": []
 | 
						||
  }
 | 
						||
 ],
 | 
						||
 "metadata": {
 | 
						||
  "kernelspec": {
 | 
						||
   "display_name": "Python 3",
 | 
						||
   "language": "python",
 | 
						||
   "name": "python3"
 | 
						||
  },
 | 
						||
  "language_info": {
 | 
						||
   "codemirror_mode": {
 | 
						||
    "name": "ipython",
 | 
						||
    "version": 3
 | 
						||
   },
 | 
						||
   "file_extension": ".py",
 | 
						||
   "mimetype": "text/x-python",
 | 
						||
   "name": "python",
 | 
						||
   "nbconvert_exporter": "python",
 | 
						||
   "pygments_lexer": "ipython3",
 | 
						||
   "version": "3.7.3"
 | 
						||
  }
 | 
						||
 },
 | 
						||
 "nbformat": 4,
 | 
						||
 "nbformat_minor": 2
 | 
						||
}
 |