Share your work here ✅

Built a Pokemon image predictor using fastdotai and KaggleDatasets (https://www.kaggle.com/thedagger/pokemon-generation-one#dataset.zip) . The docker image is deployed on heroku (https://salty-headland-83874.herokuapp.com/ ). You can find the docker image here https://hub.docker.com/r/vardhanapoorv/pokemon-predictor . If anyone knows a better dataset for Pokemon, let me know. I have built it using what I have learned till lesson2. Would soon be writing a deployment guide. If anyone needs any help or want to share what they think would love to hear it.
Would like to get feedback about this . You can find the code here - https://gist.github.com/vardhanapoorv/30bdd984f9e8d59ea1af203882f085b6 , will write a article about deployment also soon

2 Likes

I live in Asia and thought this would be an interesting first project. I’ve trained two models to predict which traditional East Asian dress a female is wearing. Feedback is greatly valued. Thanks in advance.

Hanfu
download%20(1)

Kimono
download

Hanbok
download%20(2)

  1. Hanfu (Chinese) vs Hanbok (Korean) vs Kimono (Japanese). Based on feedback I received here

Github

Colab

  1. Qipao (Chinese) vs Hanbok (Korean) vs Kimono (Japanese)

Github

Colab

I would like to increase the accuracy but I have only watched lesson 1 so far. Any tips is greatly appreciated.

1 Like

Hi @piaoya I have access to a server at work and it’s what I’ve been using. Did you downloaded the images yourself? I downloaded a zip that someone posted on the dataset’s discussion and had to do some cleanup after that, you can find that on the my notebook.
I haven’t used kaggle kernels so I’m not sure of the limitations but 500 pics seems quite limiting.
Glad you liked it, please let me know if you find anything more about it or have any questions or suggestions about my work.
cheers

I recently created a blog post that animates and annotates each step of the forward pass for recurrent neural networks. I think many people here will find it interesting if they’re trying to understand exactly what’s going on under the hood with RNNs.

http://joshvarty.github.io/VisualizingRNNs/

Here’s a quick preview of one of the animations. You can hover over the code and see exactly what corresponds to what in the diagram.

25 Likes

I put together a tiny notebook to illustrate the absolute basics of CUDA in pytorch. I.e. when does a tensor operation happen on the GPU? How do you tell? etc. Mostly made to cement my own understanding but I figured it might be worth sharing.

5 Likes

How to run Pytorch 1.0 and Fast.ai 1.0 on an Nvidia Jetson Nano Board:

The Nvidia Jetson Nano is an incredible value for an ARM Cortex A57 processor board with 4GB of RAM and that runs both CUDA and pytoch. Here’s how you can also make it run the latest and greatest (as of April 2019) version of pytorch and fast.ai. This install is for Python3 only . This install is NOT recommended if you don’t have much linux experience, don’t know how to use ssh, or have no idea how IP networking works or what an IP address is.

What You Need:

  1. A ($99) Nvidia Jetson Nano development board – These can be ordered from many places, I got mine from SparkFun. My only comment is that if you order one, pay extra for fast shipping as these are in limited supply and take over a week to ship using their Fedex/Post Office shipping method.
  2. A (~$15) Class 10 64GB Micro SD Card . – Make sure it’s class 10 or higher speedwise.
  3. A USB Keyboard – Got a PC? Use that one.
  4. A (~11$) 2.5Amp power cable that has a micro-usb plug.
  5. An HDMI or DisplayPort cable and monitor – note that some monitor’s won’t work, so if your cool new 4K monitor doesn’t work (like mine), hook up a 1080p TV using HDMI.
  6. An Ethernet cable , a Wireless router or HUB on your network . This box has no native wireless support, so make sure you have a viable wired network.
  7. A PC that you can plug the Micro SD card into to flash it. If you only have USB ports, that’s fine. Spend the extra $10 and buy a USB to SD card adapter .
  8. Software for your PC that can create an SSH terminal , and software that can transfer files using SSH . For Windows I recommend Tera Term (free) and WinSCP (free). Use google to find where you can download these if you don’t have them already.
  9. Download This Zip File to your PC which contains the scripts I’ve written and remember where you put it. It contains these files:
    setup_swapfile.sh
    fastai_jetson.sh
    setup_jupyter.sh
    jetson_headless.sh
    jupyter_notebook_config.py

What to do first:

After you shiny new box arrives, ignore their stupid paper stand and find yourself some anti-static foam or similar material and put your new board on. Go to the Nvidia developer website and follow These Instructions to get started. Be sure you do all of the following:

  1. Download the Nvidia zip file with the SD card image.
  2. Flash it to the SD card using their instructions.
  3. Put the SD card into the Nano, plug in the USB keyboard, monitor and Ethernet cable attached to the router (must have internet access).
  4. Boot the machine, accept their license, etc.
  5. Pick a machine name that works on you network, pick a user name and password you can remember, you’ll need it!

Once it boots up and you’ve verified it’s on your network and the Internet:

  1. Go to the Network Settings and find the IP V4 address of your machine, write it down , or if you understand IP networking set up a fixed IP address .
  2. Use the PC terminal program to open an SSH session with your Jetson Nano.
  3. Use your file transfer program to transfer the files in the zip File to your Nano’s user home directory.
  4. From your PC ssh into the IP address in step 1 above.
  5. From either the console or via an SSH connection, set execute permissions on the scripts you’ve just downloaded:

chmod +x fastai_jetson.sh
chmod +x jetson_headless.sh
chmod +x setup_swapfile.sh
chmod +x setup_jupyter.sh

Set up a Swap File:

The Nano has only 4GB of RAM (which the GPU shares), you’re going to need to setup up a swap file. If you already have one, skip this step. You can just run the setup_swapfile.sh from your terminal session:

./setup_swapfile.sh

Be sure to ONLY DO THIS ONCE, as it has nothing in the script to check if it was already setup. Verify you swap file is setup by doing:

free

you should see an 8GB swap file created

Install pytorch and fast.ai:

If at this point you want to try the standard fast.ai and pytorch install, go right ahead, it will fail. For a bunch of reasons I’m not going to go into now, the standard pip commands simply won’t work for this. But if you just run the fastai_jetson.sh script you downloaded it will install both. Now this will take a couple of hours at best, so don’t hold your breath.

./fastai_jetson.sh

Install jupyter notebook:

After fast.ai is installed, it tells you:
Done with part1 – now logout, login again and run setup_jupyter.sh

This is because the jupyter install doesn’t export the shell variables it need to run. So shutdown all your terminals, SSH sessions etc. and just reboot the Nano from the GUI. Once it comes back up. Open up a terminal from the GUI and :

  1. Make sure that the jupyter_notebook_config.py file you downloaded is in the nano’s home directory.
  2. run ./setup_jupyter.sh

./setup_jupyter.sh

This also takes a while, so again don’t hold your breath . The last step of this script asks for your jupyter password. This IS NOT your login password, this is a separate password you can use to log into jupyter notebook from any PC on your network, so pick an appropriate password and write it down. The default jupyter notebook install only lets you log in from the console or GUI, the modified jupyter_notebook_config.py file you downloaded and the script installs allows you to login from any machine on your network. To run jupyter notebook you will have to open a terminal or ssh instance and run:

jupyter notebook

If it doesn’t run, it’s probably because you didn’t log out and in again.
That’s it. Your done, You can now run pytorch and fast.ai. But if you’re like me, you don’t need a GUI on the nano, and want all the memory you can get to run programs.

A Note about Python, Pip and VirtualEnv:

Some experienced python users are used to a virtual environment (virtualenv, conda) which requires you to activate it ‘source activate’ before you install or run software you’ve installed in that environment. We haven’t installed that (Yes we probably should have), one of the side effects of this is that the pip and python commands will run python3 or pip3 automatically, if that’s the active environment.
You must use pip3 and python3 to run pip and python respectively. So if you’re running some notebook that uses !python xyz, it won’t work unless you change it’s code to !python3 xyz.

Memory isn’t everything, but it’s definitely something:

Back in the old days (of say 2010), 4GB was a lot of memory. And If you’re not using the GPU on this board, it is enough to get your notebooks running well (the 8 GB of swap file helps quite a bit). But if you’re using CUDA, it doesn’t run on the swap disk, so you need each and every byte of that 4GB. To get that, it’s time to jettison the GUI and run via a remote console using SSH. Running the jetson_headless.sh script will uninstall the GUI, and purge a couple of unnecessary packages that take up over 300MB of RAM. So after you run this and reboot, you’ll only have console access to the Nano, but you’re the machine will start using only about 378MB of RAM, leaving you with 3.6GB for pytorch and fast.ai.

1.run:
./jetson_headless.sh
2. reboot and ssh into your nano.

A Note about changes:

As of April 2019, this hacky install method works and installs the latest versions of both pytorch 1.0 and fast.ai 1.0, but things change. In the future you will have to update one or more packages or fast.ai itself. Hopefully some clever soul will figure out how to do that and maybe even build a git repo. My work here is done.

41 Likes

Hi,

I tried sports classification over 22 types of sports.

I got the following confusion matrix and accuracy of 97%

acc_sports

To play with the model, I tried predicting the sport type of Jeremy’s twitter wallpaper

jeremy

And I got the classification as Category motogp

You can find the repository here

5 Likes

Very cool! The question we all want to know - how’s the performance?

I’m working on a side project parsing python repos off github to find the most common libraries and functions. I think it would be awesome to be able to see the functions of each library listed from most to least used, especially for new students. I’m a bit stuck because of python’s dynamic typing, so if anybody here has experiencing using Abstract Syntax Trees or parsing source code and wants to help, please let me know!

This is a quick writeup that covers python’s builtin functions and special dunder methods (e.g. __len__) showing them in order of most used to least used, along with some visualizations. Hope you enjoy.

6 Likes

That’s amazing @Interogativ

btw, are you Tilii?

Thanks! Sorry, Not Tilli, just me.

1 Like

Hello. Fast.ai is a cool thing for quick solution of problems on images, texts, etc.
And when I needed to play with sparse 3D data such as point cloud, depth maps and even mesh - to process data from LIDAR - I was terribly short of such a library.

In short, I implemented another application (in addition to visual, text, collab, tabular) - sparse - a wrapper around Benjamin Graham’s SparseConvNet. I.e. new DataBunch, DataSets, Items, Transforms compatible with fast.ai learner are implemented.

Here is an example of a solution to the problem of 3D segmentation of indoor scenes.

And this is the result of the transformation chain (point sampling, affine transformations, elastic transforsm, voxelization, color noise):

Github repository.

Now you can quickly explore models and try out ideas on SparseConvNet and go beyond the 2D world

21 Likes

I have checked the github repo. it is really good work.
The data is huge, where did you find the data?

I gathered the data with the help of gi2ds tool from images.google.com.

For more information on downloading the data, you can check out this notebook of course.fast.ai.

2 Likes

During the last 2 weeks, I’ve been working on a project to upscale music using deep learning.

Here’s a link to the repo : https://github.com/StatisticDean/Crystal_Clear

I was very impressed by the results from lesson 7 of superresolution and I wanted to see if it was possible to get similar results in the musical field. So my idea was the following :

  • Take the superres.ipynb notebook from lesson seven
  • Find musical data
  • Find a way to feed the musical data to the same model architecture
  • Find a way to reconstruct musical data from the output of the model
  • Enjoy?

To achieve that :

  • I started looking for a good musical dataset. I stumbled upon https://github.com/mdeff/fma which had everything I wanted and more. 900 Go of free of right music with metada easy to download. At the moments, i only used the small version of the dataset which contains 9 Go of data in the form of around 8k mp3 files that last around 30 sec. This was perfect.
  • To feed the data to the superres model, my idea was to interpret the spectrogram as an image and reconstruct that image. So for a given music, I took the stft using scipy with nperseg = 254 to generate a n_channels by 128 by the number of frames “image” where each point of the image corresponds to the amplitude of the frequency in a short window around the frame. The idea was to pass this image to the model, and then use the original phases from the music to reconstruct the music. Since the model eats square image with 3 channels, I did the following thing : create 1 or 2 extra channel(depending if the original audio was mono or stereo) and cut my long spectrogram in a sequence of square images.
  • To train the model, one needs to give it good quality data and bad quality data so it can learn to create the good quality data from the bad quality data. To “crappify” my musical data, i encoded in mp3 with a low bitrate(32k). At the moment, this is the only crappification I made, and I plan to test more varied crappifications.
  • This is what it looks like crap orig
    On the left, the crappified version is a much poorer spectrogram than the spectrogram of the original version.
  • 30 seconds of musics corresponds to roughly 82 windows of 128 frames which means I had a dataset of 600k images.
  • The first thing I did with those image to have an intuition on if they could be used to realize my project was to perform a classification task. The music I had was split into 8 genres, so I trained a resnet to recognize the genre of a spectrogram. The result I had was around 50 % accuracy. This is pretty good considering with have 8 classes(much better than random guess), and each spectrogram corresponds to only around 0.4 sec of audio.
  • Once this was done, I was confident that the project could work. In order to train the reconstructing network, I needed a feature loss. The one used in the superres.ipynb was based on a Vgg16 trained on imagenet. This was not very relevant for my kind of images so I retrained Vgg16 overnight on my classification task with my 600k images(- around 20% for validation), and I reached the same 50% accuracy I had with my first classification resnet. I did this directly in pytorch.
  • At this point everything was in place, and I could start training the superresolution model. I used the featureloss from my new vgg16, and trained for a few epochs (4 epochs of around 3 hours on my personnal GPU). I havn’t had time to train more yet, or to unfreeze the network, so I think there is room for a lot of improvement here.
    We can see that the model is filling in previously missing frequencies.
  • Now to apply the model on music, we take the music, generate its spectrogram, cut it in squares, feed it to the network, update the music spectrograms by using the old phase, and we’re good to go. It takes around 1 sec to deal with 70 windows on my GPU and 10 times longer on CPU.

TODO :

  • A better reconstruction could be achieved by considering overlapping windows and for each frame, and average of the prediction of all the windows that contains this frame. We could also use overlapping windows to have a bigger training dataset.
  • More training
  • Use different kinds of crappification
  • Use a bigger part of the dataset
  • Make a web app to be able to use the model.
  • Make my repo usable for training the models.

If you want to see(hear) for yourself, you can clone my repo and download the model from the link in the README. You just have to install the environment from the .yml file, and you should be able to use the model by launching the upscale.ipynb notebook. If you don’t want to download the model, you can just get the repo and use the 'sample.ipynb` notebook to listen to already processed samples.

I havn’t been over all the details of this project in this post, I’ll probably make a more detailed version later, this is to give you an overview of my project.

Please feel free to point out mistakes in this post or in the project, to make issues/PR on github, or to ask me any question about the project.

16 Likes

This is really great. Thanks for sharing

Hi,

Looks like the link to the notebook is broken. Can you please fix it?
Thanks

Very cool @anubhavmaity - I’ll have to revisit a similar project I did during part 1. I got to about 95% with resnet34 and 448x448 images - compared to your 299x299 and resnet50 that is better.

I made a classifier for Australian birds [https://github.com/Josh-Myers/Australian-birds-classifier/blob/master/birds.ipynb] - it’s really cool to be able to make something like this after only one lesson.

1 Like

I was interested in the fast.ai library and decided to watch the first lesson. I haven’t had so much fun with playing with a library in a while :slight_smile: In just an hour I understood how to use the library and get some results out of it*

My topic was of course cats: In what posture is a cat? Sitting, lounging, curled up or walking. The error rate was 17%, which is quite ok considering the bad figures and my own confusion on the definition of the poses :sweat_smile:

There is a small writeup available on my own blog if you want to read the details:
https://www.vanderzwaan.dev/posts/2019/04/cature/

Given sufficient free time I’ll see if I can improve it. The final goal is to use a RaspberryPI and a camera to track my own cat and see how it actually spends it day.

*totally incomparable to the time it took me to get useful things out of other libraries and visualize it.