{"id":45939389,"url":"https://github.com/imartinezl/picnic-hackathon-2019","last_synced_at":"2026-02-28T10:24:34.227Z","repository":{"id":37102440,"uuid":"178944873","full_name":"imartinezl/picnic-hackathon-2019","owner":"imartinezl","description":"Picnic Image Classification Hackathon on Devpost 📷🍏🍎","archived":false,"fork":false,"pushed_at":"2025-10-27T10:01:19.000Z","size":122,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-27T11:43:43.533Z","etag":null,"topics":["gpu","image-classification","jetson-tx2","keras","python","tensorflow"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/imartinezl.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2019-04-01T20:50:57.000Z","updated_at":"2025-10-27T10:01:18.000Z","dependencies_parsed_at":"2024-01-13T14:35:51.605Z","dependency_job_id":"8de1d0a4-73f7-4e70-993d-5fe842a2e625","html_url":"https://github.com/imartinezl/picnic-hackathon-2019","commit_stats":{"total_commits":75,"total_committers":3,"mean_commits":25.0,"dds":"0.43999999999999995","last_synced_commit":"e19e4f482f541753c1c280386e2b1465c1c1c691"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/imartinezl/picnic-hackathon-2019","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imartinezl%2Fpicnic-hackathon-2019","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imartinezl%2Fpicnic-hackathon-2019/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imartinezl%2Fpicnic-hackathon-2019/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imartinezl%2Fpicnic-hackathon-2019/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/imartinezl","download_url":"https://codeload.github.com/imartinezl/picnic-hackathon-2019/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imartinezl%2Fpicnic-hackathon-2019/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29930344,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-28T09:58:13.507Z","status":"ssl_error","status_checked_at":"2026-02-28T09:57:57.047Z","response_time":90,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6: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":["gpu","image-classification","jetson-tx2","keras","python","tensorflow"],"created_at":"2026-02-28T10:24:33.806Z","updated_at":"2026-02-28T10:24:34.221Z","avatar_url":"https://github.com/imartinezl.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Picnic Image Classification Hackathon 📷🍏🍎\n\nThis repo contains the code for the [Picnic Image Classification Hackathon](https://picnic.devpost.com/) on [Devpost](https://devpost.com/).\n\nThe challenge was to design a solution to help in the classification of images of products for customer support.\n\n\n\u003cimg src='https://res.cloudinary.com/devpost/image/fetch/s--3uci4Nf2--/c_limit,f_auto,fl_lossy,q_auto:eco,w_900/https://siliconcanals.nl/wp-content/uploads/2015/08/picnic-thumb.jpg'\u003e\n\n\n## What it does\n\nBasically take some labeled images and build a CNN model to predict the label of unclasssified images. More in detail:\n1. Setup a Tensorflow data pipeline\n2. Image preprocessing: decode + resize + normalize\n3. Prepare dataset: repeat + batch + prefetch + change_range\n4. Model building on Keras +  Transfer Learning [InceptionV3](https://keras.io/applications/#inceptionv3) as the base model \n5. Model training: fine tuning of top dense layers\n6. Predict test labels\n\n## How I built it\n\n- [Python](https://www.python.org/) - Programming Language / 3.5.2\n- [pandas](https://pandas.pydata.org/) - High-performance data analysis / 0.24.2\n- [numpy](https://www.numpy.org/) -  Package for scientific computing / 1.16.2\n- [tensorflow](https://www.tensorflow.org/) -  Machine learning library / 1.13.1\n- [scikit-learn](https://scikit-learn.org/stable/) -  Machine learning library / 0.20.3\n- [matplotlib](https://matplotlib.org/) -  Plotting library / 3.0.3\n\n\n## Challenges I ran into\n\n- NVIDIA Jetson TX2 setup\n\nRecently I adquired a [NVIDIA Jetson TX2](https://www.nvidia.com/en-us/autonomous-machines/embedded-systems/jetson-tx2/). Tasks such as image classification are solved with large deep learning models that require a lot of computational resources.\nThe Jetson TX2 is a fast and power-efficient embedded AI computing device, which is suitable for this purpose. However, I run across some problems to setup the system in order to install tensorflow with GPU support.\n\n- Tensorflow models RAM consumption\n\nConvolutional Neural Networks have millions of parameters that need to be stored on the RAM memory for training and inference.\nGiven the size of these models, Tensorflow was consuming lots of GB from my 8GB RAM, leaving almost no room for the training task. At such situation, I had to configure the Tensorflow session in order to constraint the maximum GPU memory fraction (to 15%).\n\n```\nconfig = tf.ConfigProto()\nconfig.gpu_options.per_process_gpu_memory_fraction = 0.15\nsess = tf.Session(config=config)\ntf.keras.backend.set_session(sess)\n```\n\n- Tensorflow pipeline design\n\nI had to go through several iterations until I found an understandable way to design the pipelines. There have been some recent changes on the Tensorflow API, so it is hard to find examples on the community that fit your version, at least from what I have seen.\n\n## Accomplishments that I'm proud of\n\n- Fast training\n\nGiven the amount of training data (almost 8000 images), I was quite surprised about the elapsed training times. I suppose that the pipeline strategy and the hardware (Jetson TX2) helped in rthe reduction of this time.\n\n- Surprisingly good results\n\nGiven that I did not make any data exploration nor research about the influence of resizing or normalizing the images, it was wonderful to find that the results were very decent. Obtaining better classification scores will require more research and tests.\n\n- Rapid project\n\nThanks to the Tensorflow documentation and the existing tutorials from the community, I was able to setup, learn the know-how and implement a solution in less than a week. It is also true that I was lucky the hackathon deadline was postponed for few days.\n\n## What I learned\n\nThis was my first time attempting to design a image classifier. It was really fun, and I discovered several machine learning libraries that allow to build image classification models. Given my previous experience with Tensorflow on other type of models (regression models basically), and the vast community behind it, I decided to choose Tensorflow to train the image classifier.\n\nOn other terms, I also learned the importance of transfer learning, and I was surprised that how well it works! Of course, I realized that the world of image classification is huge, and that there are no magical rules that you can follow to obtain a better solution. This requires experience, tests and a lot of time.\n\n## What's next for Picnic Hackathon\n\n- Data Exploration\n\nI would like to explore the data in order to understand more about the labels and the features that can be relevant for the classification task. I believe that the human knowledge can be critical in order to add some prior information to the model.\n\n- Visualize Results\n\nAfter finishing the training of a model, I would like to visualize the hidden intermediate layers of the network, in order to know what are the features that the model is capturing for making the classification decision. Even though the base of the model is copied from InceptionV3, it can be relevant to visualize the output of this model. Based on the output features, the dense layers architecture could be modified.\n\n- Image augmentation\n\nThis is something that I wanted to implement for this hackathon, but I run out of time. This is something that could improve a lot the classification scores. Image augmentation, such as rotating, cropping, scaling, flipping, etc. bring some crucial advantages to the task. First, it increases the size of the training dataset, thus improving the training accuracy of the neural network. Second, it helps in the generalization capabilities of the model. Here the assumption is that augmenting or modifying the image will not remove the critical features that we as humans use to classify an image. Therefore, augmented images will make the model more robust and more able to detect the important features.\n\n## Re-Producing the Result\n\nIf you want to get the submitted result, you just need to follow this instructions:\n\n- Clone this repo\n```\ngit clone https://github.com/imartinezl/picnic-hackathon-2019.git\ncd picnic-hackathon-2019\n```\n- Create a virtual environment and install requirements\n```\nvirtualenv venv\nvirtualenv -p /usr/bin/python3 venv\nsource venv/bin/activate\npip install -r requirements.txt\n```\n\n- Download data set from [Drive](https://drive.google.com/open?id=1XSoOCPpndRCUIzz2LyRH0y01q35J7mgC)\n```\nmkdir data\nunzip 'The Picnic Hackathon 2019.zip' 'The Picnic Hackathon 2019/*' -d data \n```\n-  Execute [`Image_classification_pipeline.py`](https://github.com/imartinezl/picnic-hackathon-2019/blob/master/Image_classification_pipeline.py).\n\n\n## Trained models\n\nIf you want to avoid the tedious training, submitted models are available at the `models` folder of this repo.\nThe corresponding macro-average F1 scores of such models were:\n- 18-04-19_1.tsv: 0.590454\n- 18-04-19_2.tsv: 0.568230\n- 18-04-19_3.tsv: 0.549844\n\nPlease take into account that the winner of the hackathon obtained 0.889674. Given that this was my first image classification competition, I feel very satisfied, but there is plenty of room for improvement, for sure!\n\n## Tensorflow data API\n\nTensorflow provides multiple ways to build and train image classification models. Most beginner tensorflow tutorials introduce the reader to the feed_dict method of loading data into your model where data is passed through the tf.Session.run() function call. However, there is a much better and almost easier way of doing this. \n\nAs new computing devices (such as GPUs and TPUs) make it possible to train neural networks at an increasingly fast rate, the CPU processing is prone to becoming the bottleneck. The [tf.data API](https://www.tensorflow.org/guide/performance/datasets) provides users with building blocks to design input pipelines that effectively utilize the CPU, optimizing each step of the ETL process.\n\n- In a naive feed_dict pipeline the GPU always sits by idly whenever it has to wait for the CPU to provide it with the next batch of data.\n\u003cp align=\"center\"\u003e\n \u003cimg src='https://dominikschmidt.xyz/tensorflow-data-pipeline/assets/feed_dict_pipeline.png' width='80%'\u003e\n\u003c/p\u003e\n\n- A tf.data pipeline, however, can prefetch the next batches asynchronously to minimize the total idle time. \nThe pipeline can be further speed up by parallelizing the loading and preprocessing operations.\n\n\u003cp align=\"center\"\u003e\n \u003cimg src='https://dominikschmidt.xyz/tensorflow-data-pipeline/assets/tf_data_pipeline.png' width='80%'\u003e\n\u003c/p\u003e\n\nSource [https://dominikschmidt.xyz/tensorflow-data-pipeline/](https://dominikschmidt.xyz/tensorflow-data-pipeline/)\n\nGiven the huge size of the training dataset, in this case the most suitable method was the [tf.data](https://www.tensorflow.org/api_docs/python/tf/data) API.\n\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fimartinezl%2Fpicnic-hackathon-2019","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fimartinezl%2Fpicnic-hackathon-2019","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fimartinezl%2Fpicnic-hackathon-2019/lists"}