Browse Author

Andy Wu

A full-time college student as well as a passionate programmer.

Train a CNN model to identify captcha code with TensorFlow and Keras

In the last post (Automatically fill in captcha code in course selection system), we exploited the "Play Audio" button function to obtain the captcha code in the course selection system from my college. Today, we will be going through another approch to identify the captcha code by training a CNN model with TensorFlow and Keras.

A captcha code from the course selection system.

 

Install Needed Packages

Below are the environment and package versions that I perform the training in this post.

MacOS 10.14.6
Python: 3.7.3
numpy: 1.18.0
scikit-learn: 0.22
TensorFlow: 2.0.0
Pillow: 6.2.1

If lacking any of these packages, just simply install them with the following commands.

NumPy: pip install numpy
scikit-learn: pip install scikit-learn
TensorFlow: pip install tensorflow
Pillow: pip install Pillow

Keep Reading

Automatically fill in captcha code in course selection system

Captcha code is broadly used in different websites to ensure the contents are only accessible by humans rather than bots. The course selection system in my college has also been adopting captcha code in the login page to reduce momentary load of its server. (by slowing down everyone's time to fill in the code and hit log in)

Besides that, the system was kindly designed a "Play Audio" button as well for visually impaired people to "hear" the captcha code. However, it becomes a defect that we can take advantage of the "Play Audio" button function to fill in the captcha code programmatically for us.

Since I have done my last course selection in my college life, I will demonstrate how to fill in the captcha code by exploiting the "Play Audio" button function in below.


Keep Reading

Using FFmpeg concatenate multiple videos

Some cameras split a sigle video into multiple files during recoding due to the limitation of the maximum file size in the file system(E.g. maximum single file size for FAT32 is 4GB). In this post, we will take advantage of FFmpeg to merge back our video fragments into a continuous single video.

 

To begin with, we put all our video fragments into the same folder and create a new file called clips.txt. Next, we add the filenames of the video fragments into clips.txt in the order we want to concatenate and seperate them by new lines.

An example of clips.txt.

file 'first.mp4'
file 'second.mp4'
...

Last, running the following command will generate the concatenated video named output.mp4 for us:)

ffmpeg -f concat -i clips.txt -c copy output.mp4

[Matplotlib] Multiple axes with different scales

It's quite often for me to plot out the statistical data while training machine learning models. E.g., teaching models to play games.

As the records increase, the chart becomes crowded as well as difficult to see how the line grows. Therefore, a strategy come up that only plotting out the average of each 250 records in a chart.

Keep Reading

Docker Compose file (TensorFlow)

TensorFlow has supported Docker containers that could save the time from installing lots of stuffs on our operating system and messing around. Besides typing long Docker commands each time in the terminal for launching the container, using Docker Compose file is another easy way to achieve it.

To begin with, create a new file called TensorFlow.yml and paste everything below into that file. Freely to change the path in volumes in accordance with our computer's path.

 

version: '3.1'

services:

	TernsorFlow:
		container_name: TensorFlow
		image: tensorflow/tensorflow:latest-py3
		restart: unless-stopped
		network_mode: "bridge"
		ports:
			- 6006:6006
		tty: true
		command: /bin/bash
		volumes:
			- /Users/AndyWu/Documents/Docker/TensorFlow:/TensorFlow

 
To create and start a new TensorFlow container from docker compose file, run the command below.

docker-compose -f TensorFlow.yml up -d

Now our newly created container should start running. Execute the bash shell in the container and interact with the pseudo-TTY by providing the options-it.

docker exec -it TensorFlow bash

We are now able to run our TensorFlow codes with python in the container:)

  • 1
  • 2