{"id":20469537,"url":"https://github.com/huixxi/image-classification-using-flowers-dataset","last_synced_at":"2026-05-18T15:39:55.460Z","repository":{"id":129596552,"uuid":"155041396","full_name":"Huixxi/Image-Classification-using-Flowers-dataset","owner":"Huixxi","description":null,"archived":false,"fork":false,"pushed_at":"2019-05-13T04:20:32.000Z","size":35546,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-07-09T01:53:56.029Z","etag":null,"topics":["data-augmentation","image-classification","pre-trained","tensorflow","tfrecords-files","transfer-learning"],"latest_commit_sha":null,"homepage":null,"language":"Jupyter Notebook","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/Huixxi.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2018-10-28T06:17:41.000Z","updated_at":"2020-05-28T15:54:17.000Z","dependencies_parsed_at":"2023-05-05T15:31:07.666Z","dependency_job_id":null,"html_url":"https://github.com/Huixxi/Image-Classification-using-Flowers-dataset","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Huixxi/Image-Classification-using-Flowers-dataset","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Huixxi%2FImage-Classification-using-Flowers-dataset","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Huixxi%2FImage-Classification-using-Flowers-dataset/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Huixxi%2FImage-Classification-using-Flowers-dataset/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Huixxi%2FImage-Classification-using-Flowers-dataset/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Huixxi","download_url":"https://codeload.github.com/Huixxi/Image-Classification-using-Flowers-dataset/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Huixxi%2FImage-Classification-using-Flowers-dataset/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33183278,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-18T09:27:30.708Z","status":"ssl_error","status_checked_at":"2026-05-18T09:27:28.300Z","response_time":71,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["data-augmentation","image-classification","pre-trained","tensorflow","tfrecords-files","transfer-learning"],"created_at":"2024-11-15T14:09:22.688Z","updated_at":"2026-05-18T15:39:55.454Z","avatar_url":"https://github.com/Huixxi.png","language":"Jupyter Notebook","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Image-Classification-using-Flowers-dataset Competition\nIn “Panorama AI Competition”\n\n这是本人作为小白第一次参加类似的竞赛，总结的这近一个月的时间内踩过的坑，走过的弯路和积累的一些有用的Tricks，分享给和我一样的新手小白们。\n【所有参考的Blogs, Tutorials等都给出了明确的出处，有部分资料需要翻墙访问】  \n\n\n## What is TFRecords File\n在此次竞赛中，训练的图像数据集相对较小，共3500(350x10)张灰度图像(Grayscale)，包含5类花朵图片(1-玫瑰(rose), 2-向日葵(sunflower), \n3-雏菊(daisy), 4-蒲公英(dandelion), 5-郁金香(tulip))，以*.tfrecord(s)类型文件存储。我是第一次接触这种类型的数据格式，所以也花了很长\n时间去理解学习，简单地说：*tfrecord file: images which are numpy arrays and labels which are a list of strings*，是一种将\\*.jpeg \n或 \\*.png 等类型图像解码后再储存成tfrecord文件，所以体积会比较大(比如：我在Google Image上面额外找的794M用于扩充训练集的5类花朵图片，\n转成.tfrecords文件有3.36G大小 Horrible....)。  \n这里推荐两篇Blogs供大家参考：  \n[1. Why Every Tensorflow Developer Should Know About Tfrecord](https://www.skcript.com/svr/why-every-tensorflow-developer-should-know-about-tfrecord/)  \n[2. Tensorflow Records? What they are and how to use them.](https://medium.com/mostly-ai/tensorflow-records-what-they-are-and-how-to-use-them-c46bc4bbb564)  \n\n## Read from a TFRecords file in Tensorflow\n拿到tfrecords类型的数据集之后，第一件事就是先把图片从里面读出来，看看图片是长什么样的，因为是很菜的小白，所以也为此头疼了好久，借鉴了一些非常优秀的教程，  \n这里是我本人的Notebook代码：  \n[Source Code: Read from TFRecords files and Plot](https://github.com/Huixxi/Image-Classification-using-Flowers-dataset/blob/master/bin/read_from_tfrecords_files_and_plot.ipynb)  \n参考的教程链接：  \n[Youtube Video Tutorial:Tensorflow tutorial_TFRecord tutorial_02](https://www.youtube.com/watch?v=jbLi8JHgl28\u0026list=LLUMZo4j7Z8dYMlWWpASiyIA\u0026t=11s\u0026index=21)    \n[上述视频教程中代码的GitHub地址](https://github.com/kevin28520/My-TensorFlow-tutorials/blob/master/03%20TFRecord/notMNIST_input.py)   \n\n## Write into a TFRecords file\n本人在进行数据集扩充进行数据增强的部分时，需要将自己在网上爬下来的图片转换成tfrecords文件，以便读入自己的模型用于模型的预训练，就顺便学习了一下该如何制作tfrecords文件，本该是后面的内容，就放在tfrecords文件这一块讲了。这里以一个例子进行说明：[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/)，同时这也是一篇非常棒的tutorial。  \n首先按照教程的操作，也可以直接看我本人整理好的[Notebook代码](https://github.com/Huixxi/Image-Classification-using-Flowers-dataset/blob/master/bin/create_a_deep-learning_dataset_using_google-images.ipynb)，将Google Image上的相关图片Download到本地。  \n接下来准备将下载好的全部图片进行标记并转化成tfrecords文件：  \n本人的Notebook代码：  \n[Source Code: Write_into_TFRecords_files](https://github.com/Huixxi/Image-Classification-using-Flowers-dataset/blob/master/bin/write_into_tfrecords_files.ipynb)   \n参考的教程链接(Vely Good!)：  \n[How to write into and read from a TFRecords file in TensorFlow](http://www.machinelearninguru.com/deep_learning/tensorflow/basics/tfrecord/tfrecord.html)    \n\n## Neural network architecture and Models\n终于到神经网络模型的部分了。因为做计算机视觉图像相关，而且又是图像分类这种很基础的方向，卷积神经网络-CNN一定是首选；对于如此小的数据集来说，要想达到一个不错的分类准确率，自然也避不开使用Pre-Trained Models和Transfer Learning。从2012年以来涌现的那么多神经网络模型，如Xception, VGG16, VGG19, ResNet50, InceptionV3, InceptionResNetV2, MobileNet等，我们该如何进行选择。这篇[Tutorial：Using Keras Pre-trained Deep Learning models for your own dataset](https://gogul09.github.io/software/flower-recognition-deep-learning)给了我很大的启发。最终我在本次竞赛中使用的是[MobileNets](https://arxiv.org/pdf/1704.04861.pdf)，因为和其他模型比起来，它的参数真的是太少了，并且也十分强大。  \n对于如何使用Pre_trained Models，我参考了如下教程(Still Vely Good!):  \n[1.MobileNet image Classification with Keras](https://www.youtube.com/watch?v=OO4HD-1wRN8\u0026list=PLZbbT5o_s2xrwRnXk_yCPtnqqo4_u2YGL\u0026index=31)  \n[2.Build image classifier using transfer learning - Fine-tuning MobileNet with Keras 1](https://www.youtube.com/watch?v=4Tcqw5oIfIg\u0026list=PLZbbT5o_s2xrwRnXk_yCPtnqqo4_u2YGL\u0026index=32)  \n[3.Train image classifier using transfer learning - Fine-tuning MobileNet with Keras 2](https://www.youtube.com/watch?v=-0Blng0Ww8c\u0026list=PLZbbT5o_s2xrwRnXk_yCPtnqqo4_u2YGL\u0026index=33)  \n[4.Sign language image classification - Fine-tuning MobileNet with Keras 3](https://www.youtube.com/watch?v=FNqp4ZY0wDY\u0026list=PLZbbT5o_s2xrwRnXk_yCPtnqqo4_u2YGL\u0026index=34)  \n\n由于这些预训练模型通常都是用RGB 3-channel 图片进行训练的，为此我对Grayscale训练数据集做了一些预处理工作，包括图片剪裁并将其转成3-channel的“Grayscale”图片（the trick: convert 1-channel grayscale to 3-channel grayscale is included in the final part）\n\n## Train and Test\n模型一开始是用CPU训练的，产能问题一度使我想要放弃，最后还是迁到了自己电脑上的GTX 950M，真香！  \n最终的模型：[final_model.h5](https://github.com/Huixxi/Image-Classification-using-Flowers-dataset/tree/master/bin/models)也是基于预训练模型的框架：[flowers_5.h5](https://github.com/Huixxi/Image-Classification-using-Flowers-dataset/tree/master/bin/models)，对全部参数进行重新训练，所以也就没有用到太多迁移学习的地方，但是用自己找的图片数据进行了预训练[pre_train_model.h5](https://github.com/Huixxi/Image-Classification-using-Flowers-dataset/tree/master/bin/models)。    \n\n[Train Code](https://github.com/Huixxi/Image-Classification-using-Flowers-dataset/blob/master/bin/train.py)  \n[Test Code](https://github.com/Huixxi/Image-Classification-using-Flowers-dataset/blob/master/bin/test.py)  \n\n参考Blogs:  \n[1.Data Augmentation Techniques in CNN using Tensorflow](https://medium.com/ymedialabs-innovation/data-augmentation-techniques-in-cnn-using-tensorflow-371ae43d5be9)   \n\n## Other Tricks(Including how to denoise grayscale image)\n其他的一些Tricks整理在这个[NoteBook文件](https://github.com/Huixxi/Image-Classification-using-Flowers-dataset/blob/master/bin/utils_in_pretrained_model.ipynb)  \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhuixxi%2Fimage-classification-using-flowers-dataset","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhuixxi%2Fimage-classification-using-flowers-dataset","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhuixxi%2Fimage-classification-using-flowers-dataset/lists"}