Wednesday, January 17, 2018

Google Code-In 2017: My Story


Weeks before GCI (Google Code-In) even started, I keep debating with myself whether to join GCI 2017 or not. I was a GCI 2016 participant and my experience with it was not so good. It was kinda a traumatic experience for me.

Long story short, I decided to join. The first thing I have to do is chose an organization I'm interested in. I already knew which organization I'd contribute to, even before I joined; Zulip.

But joining GCI more than a week late (I had some internet problems) ruins my plan. Zulip is a huge community. There sure were a lot of participants. That means I have to do a lot of tasks in order to, well, win? I never expect myself to be a finalist, let alone winning, but I want to push myself to the limit. The competition would be too tough for me, so I prefer to chose other organization.

I scroll through the available organizations and observe them. Surprisingly, a few organizations caught my eyes. OpenWISP, LiquidGalaxy, and CloudCV, to name a few. I feel like I was sorta qualified for them. Not only that, they're all new organizations! A good thing to forget my past, GCI 2016.

I choose CloudCV as the organization I want to work with. I chose it because it's related to Machine Learning, a thing that I've been interested in for the past several months. Perfect.

CloudCV is a young open source organization which builds some platforms for AI and/or Machine Learning. The goal of CloudCV is to make AI research more reproducible. CloudCV has 3 main projects, EvalAIOrigami, and Fabrik.

Fabrik's page


CloudCV's task choices, however, were so limited. At one point, it even only had 7 tasks choices (not counting the beginner tasks)! I mostly give my contributions to Fabrik, such as adding neural network models to its model zoo. Adding a model to Fabrik's model zoo was like a gambling game for me. When you're lucky, it was so easy you feel like you've done nothing. But other times it's really hard I feel like I want to give up.

The first thing I have to do when I want to add a new model to Fabrik is to find a neural network model. At this time of writing, Fabrik only supports 3 frameworks, Caffe, Keras, and Tensorflow. However, Fabrik still has some problems with tensorflow models. I don't have any experience with Caffe so I prefer to go with keras.

After cloning a model I want to add, I have to make sure that the model works perfectly. Some models work well in keras 2, while some others don't. Some works in tensorflow 1.4.1, some don't, etcetera. After running the model smoothly, I have to make a JSON file from it. Then, I have to make sure that Fabrik supports the layers in the model.

Sometimes Fabrik throw me an error and I have to find another model. If Fabrik keeps throwing errors, I have to change the model I want to import, and start working from zero again. Repeat.

In this blog post, I've listed some models I've tried to add to Fabrik. There's more to it though. Right now I have a collection of more than 20 different neural networks models, only because I keep getting errors on most models I tried! Almost all of them use keras as their framework.

Another thing I did was finding AI challenges on the internet. I already know one website; kaggle! But this task makes me even more creative and I scoured the internet for every possible AI challenge I can find. Some of them can be found here.

I also made some graphics for CloudCV:
A logo for Origami



An illustration for Fabrik

I enjoyed working with CloudCV. I like the atmosphere, the community, the nice and helping people, and pretty much everything, even the timezones. Most students in other organization usually have problems with a huge time zone difference with their mentors and ended up being awake all night long. In CloudCV, I was thankful to have mentors whose timezones were close to mine.

One thing that bugs me a little is that CloudCV only had a few mentors. I counted all the mentors whose name appeared on the task pages, and there were only 9 mentors!

A random screenshot of my terminal

Working with CloudCV gave me the experience about programming in the real world. Programming isn't all about coding. Sometimes when you find a problem, you gotta solve it yourself because StackOverflow doesn't have all the answer. Setting up a development environment is the hardest of all. Package versions aren't just numbers, but it plays an important role in a project.

In the future, I hope to contribute more to CloudCV whenever I have enough time.

I got into the leaderboard and I'm pretty happy with that. Thank you to everyone who has helped me through contributing to CloudCV, including my family, other students, and of course, and my mentors. Thanks for dealing with my dumb questions and dealing with me in general.

ps: if you want to ask me questions about GCI, feel free to, I'd be happy to answer.

Friday, January 12, 2018

Keras Neural Networks and Fabrik

A screenshot of Fabrik

I tried to import several keras neural networks  to Fabrik, and this is the result:
These are the models I successfully imported:
Model LinkFabrik Link
https://github.com/anantzoid/VQA-Keras-Visual-Question-Answeringhttp://fabrik.cloudcv.org/caffe/load?id=20180105045732jmyeu
https://github.com/LemonATsu/Keras-Image-Caption
http://kodu.ut.ee/~leopoldp/2016_DeepYeast/code/caffe_model/http://fabrik.cloudcv.org/caffe/load?id=20180102135425bzkzy

And these are some models I had troubles with:
Model LinkSuccessfully Generated the JSON Model?ProblemError Message
https://github.com/ykamikawa/SegNetYesError when importingValueError: Unknown layer: MaxPoolingWithArgmax2D
https://github.com/zhixuhao/unetYesError when exporting ValueError: `Concatenate` layer requires inputs with matching shapes except for the concat axis. Got inputs shapes: [(None, 64, 64, 512), (None, 63, 63, 512)]
https://github.com/yihui-he/u-netYesError when exportingValueError: `Concatenate` layer requires inputs with matching shapes except for the concat axis. Got inputs shapes: [(None, -1, 19, 256), (None, 0, 20, 256)]
https://github.com/aitorzip/Keras-ICNetYesError when importing
ValueError: bad marshal data (unknown type code)
https://github.com/preddy5/segnetYesError when importingCannot import layer of Layer type
https://github.com/k3nt0w/FCN_via_keras/NoValueError: The input must have 3 channels; got `input_shape=(3, 224, 224)`
https://github.com/0bserver07/Keras-SegNet-BasicNo
ValueError: total size of new array must be unchanged

Thursday, January 11, 2018

How to Save a Keras Model to a JSON file

To save a keras model to a json file, simply use this code:

model_json = model.to_json()
with open("model.json", "w") as json_file:
    json_file.write(model_json)

where model is a keras model object.

Tuesday, January 2, 2018

Image Captioning Models and Fabrik

No
Name
URL
Framework
Note
Fabrik
1NeuralTalkhttps://github.com/karpathy/neuraltalkPython + numpyobsoleted by NeuralTalk2
2NeuralTalk2https://github.com/karpathy/neuraltalk2TorchTorch incompatible with Fabriq
3Show and Tellhttps://github.com/tensorflow/models/tree/master/research/im2txtTensorflowTensorflow parser Fabriq incompatible with Fabriq
4Keras Image Captionhttps://github.com/LemonATsu/Keras-Image-CaptionKeras
requires python 3.4+
fail with python 3.6
5 https://github.com/amaiasalvador/imcap_kerasKerasperlu MSCOCO
6Neural Image Captioninghttps://github.com/oarriaga/neural_image_captioningKerasTimeDistributed Layer incompatible with 


I want to add an Image Captioning model to Fabrik. It seems pretty easy, all you have to do is find a JSON format of the model you want, and there you go! All done. But in reality, it wasn't that easy.

First, I have to find an image captioning mode. My first choice landed to NeuralTalk since it's pretty popular. After heading to the GitHub page, it seems like NeuralTalk is obsoleted by NeuralTalk2, so I take NeuralTalk2 After having a hard time trying to install it and trying to make the JSON file, I realized something. NeuralTalk2 use torch as its framework and Fabrik doesn't support torch. Fabrik only supports Caffe, Keras, and Tensorflow. (I never made the JSON file by the way)

I have to try another model. I ended up trying Neural Image Captioning by oarriaga on github. Unlike NeuralTalk2, making the JSON file was pretty smooth. 
So I try to find another model. Show and Tell looks good. It uses Tensorflow as its framework, but unfortunately Fabrik <><><>< so I have to find another model

Simple Image Classification with Keras

Keras logo There are several kind of image classification: Binary classification Multiclass classification Multi label classificat...