{"id":21448040,"url":"https://github.com/windsting/yoni","last_synced_at":"2025-03-17T02:09:23.928Z","repository":{"id":39740464,"uuid":"115197995","full_name":"windsting/yoni","owner":"windsting","description":"Yes or no image","archived":false,"fork":false,"pushed_at":"2022-12-07T23:44:38.000Z","size":4523,"stargazers_count":1,"open_issues_count":12,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-23T11:45:20.920Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://yoni.windsting.com","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/windsting.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-12-23T13:41:53.000Z","updated_at":"2020-05-19T05:23:09.000Z","dependencies_parsed_at":"2022-08-25T19:13:15.523Z","dependency_job_id":null,"html_url":"https://github.com/windsting/yoni","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/windsting%2Fyoni","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/windsting%2Fyoni/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/windsting%2Fyoni/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/windsting%2Fyoni/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/windsting","download_url":"https://codeload.github.com/windsting/yoni/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243960665,"owners_count":20375104,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-23T03:13:50.858Z","updated_at":"2025-03-17T02:09:23.912Z","avatar_url":"https://github.com/windsting.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Yes Or No Image\n\n\u003cp align=\"right\"\u003e\n    \u003ca href=\"README_CN.md\"\u003e中文版\u003c/a\u003e\n\u003c/p\u003e\n\nThis project is a learning result of a training on Meachine Learning. It's a simple(**is** or **is not**) image classify framework, using deep learning Convolutional Neural Network, contains tools for:\n\n1. gathering dataset images for training\n1. single or batch model training -- this step consume most of your time\n1. examine and deploy trained model with http access\n\n\n## Usage\n\n### Prepare you environment\n\nThis project was create with Python 2.7.14, and not checked on Python 3.x\n\nIt's recommand to create a virtual environment for the experiment, to keep your local machine clean, to create virtual environment, please check the [User Guide of `virtualenv`](https://virtualenv.pypa.io/en/stable/userguide/).\n\nAll required package were listed in the `requirements.txt`, use this command in the root folder of project to install them:\n\n    pip install -r requirements.txt\n\nThat's it, you've prepared.\n\n### Gathering dataset images\n\n1. Read the `getDataSet.md`, to obtain URL lists for both **is** and **is not** images\n1. Download them into different directories, for a list with name `yes-urls.txt`, the command can be:\n\n    ```sh\n    python download_images.py -u yes-urls.txt -o images/yes\n    hello from download_images.py\n    gonna save to: images/yes\n    file line count: 10\n    url count: 6\n    [INFO] downloaded: images/yes/00000005.jpg\n    [INFO] downloaded: images/yes/00000000.jpg\n    [INFO] downloaded: images/yes/00000002.jpg\n    [INFO] downloaded: images/yes/00000003.jpg\n    [INFO] downloaded: images/yes/00000001.jpg\n    [INFO] downloaded: images/yes/00000004.jpg\n    3 in 6 files removed.\n    ```\n1. Do the same on the `no-urls.txt`, only save them into another directory aside `yes`\n1. Check all your dataset images, to remove invalid images, non-target image in `yes` directory, and target image in other directories.\n\n#### Note:\n\n* The only **MUST BE** directory name is `yes`, it'll be used by the training step to determine the target object, the others directory can be `no` or anything you want.\n* The downloader script will remove those invalid images if they:\n    1. Can not be `imread` by cv2\n    1. Have a same MD5 hash value with existing image\n\n### Training your Neural Network\n\nThe Neural Network was defined in the **nn/mycnn.py**, you should edit it or use another python module to **create your own Neural Network**, don't forget to edit `train_network.py` for importing Neural Network from your own module, if you do have your own module.\n\nTo train your network can use the `train_network.py` with this command:  \n\n```shell\npython train_network.py -d images/ -m guitar_model\n```\n\nafter training, if you didn't changed the default output path, the model will be stored in folder `output`, along the training information plot image:  \n![guitar_training_plot](./asset/guitar_training_plot.png)\n\nOr you can edit the `batch_train.py`, all editable variables are obvious, just insert your desired values,  and the command is a little shorter:\n\n```shell\npython batch_train.py\n```\n\nthe models stored in the same output location of `train_network.py`, but with this script, you get all models with combination of those variables, I just run this command and sleep, and check the result plot images on the morning.\n\n### Testing and deploy your trained model\n\n\n#### Testing on the command line\n\nTo test the trained model, you can use the `test_network.py` script, just specify the **trained model**, **yes label**, and **image for testing**:\n\n```shell\npython test_network.py  -m output/guitar -l Guitar -i images/testing/no/00000200.jpg\nUsing TensorFlow backend.\n[INFO] loading network...\nprob is:0.99967110157, 0.000328877591528\nNot Guitar: 99.97%\n```\n\nyou can read the probability of both `yes` and `no` on the command line, and the label choosed by model on the result image like this:  \n![web-test-result-image](./asset/web-test-result-image.jpg)\nto close the image, click on the image, and press any key on the keyboard.\n\n* If you choosed a different `train_image_size` other then default value `28`, don't forget to specify it with the option `-s`.\n\n#### Testing with web interface and use it to deploy\n\nIt's tolerable to test with command line, but not convenient, to drag \u0026 drop image for testing, you can use the `web_test.py` script:\n\n```shell\npython web_test.py -m output/guitar_EPOCHS5_LR0.001_BS32_TIS28_DSS1952 -l Guitar\n```\n\nThe options are same as `test_network.py`, just no **image path** needed, and this start a web server on `http://127.0.0.1:5000/`, open it with your favourite web browser, just drag a test image, and drop in to the **red square** with `Drop Here` in it, the result image will be shown on the right side of it.\n\n#### Deploy the model\n\nWith the `web_test.py` script, we have a web server listening on the `5000` port on the localhost interface, the only thing you need to publish it is a reverse proxy server like Nginx or Apache, that's beyond the topic of this project, please search and check related documents.\n\n## Referenced tutorial\n* [How to create a deep learning dataset using Google Images](https://www.pyimagesearch.com/2017/12/04/how-to-create-a-deep-learning-dataset-using-google-images/)\n* [Image classification with Keras and deep learning](https://www.pyimagesearch.com/2017/12/11/image-classification-with-keras-and-deep-learning/)\n\nI can't understand these tutorials Without the knowledge learning from this training, the core concept of this project is the same as those tutorials, but I adapted them, to make it generic, not only used on the **Santa Clause** recognizing.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwindsting%2Fyoni","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwindsting%2Fyoni","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwindsting%2Fyoni/lists"}