These days, with more apps using location services and more time spent on social media, smartphone batteries often fail to last a full day even as their capacities keep growing.
At the same time, with things like mobile payments, running out of battery has become a serious inconvenience in daily life — which is exactly why demand for power banks is greater now than ever.
What is MagSafe?
With an ordinary power bank, you also need a cable to connect it to your phone, so you end up carrying more stuff, and the power bank itself is fairly heavy — all rather annoying.
Some batteries come with an attached cable, but the cable is so short that it isn’t well suited to using your phone while charging.
Recently, Apple introduced MagSafe — magnet-based wireless charging — starting with the iPhone 12 series. Magnets are embedded in the back of the phone, so the wireless charger snaps into place magnetically and there’s no worry about it slipping out of alignment.
MagSafe has been included since the iPhone 12, and some models don’t support it (such as the iPhone SE), but as long as your phone supports wireless charging, you can buy a MagSafe-compatible case and use MagSafe accessories with it.
The magnetic hold isn’t noticeably weaker either — it’s very strong. (I’m actually using this setup with an iPhone SE 3.)
The Anker 622 Magnetic Battery is just too good
You can attach chargers or phone grips as MagSafe accessories, but personally I think a power bank is the best choice.
There are several MagSafe power banks out there, and the most impressive of them all was the Anker 622.
Some models are just plain batteries, but this one also works as a stand.
You can also toggle charging on and off with the button on the battery, so you can leave it attached and charge only when you need to — meaning it doubles as a simple stand. And because the magnet is circular, you can use your phone in landscape orientation too.
The magnet is strong enough that the battery won’t fall off if you shake the phone, yet it detaches easily when you want it to — just the right amount of holding force.
It comes in plenty of colors, and the size and weight are modest enough not to get in the way. Excellent all around.
As for the all-important charging speed: it isn’t as fast as a wired connection, but it’s fast enough that your battery percentage still climbs even while you’re watching YouTube.
What’s more, you can charge the battery itself while it’s attached to and charging your phone (pass-through), which effectively gives you the same experience as if the iPhone’s charging port were USB Type-C.
The downsides are, unsurprisingly, weight and charging speed. There’s no getting around the added weight — the combination is heavier than the phone alone, so you definitely notice it in your pocket. And since charging isn’t rapid, it’s best to think of it as an extended battery for your phone.
It’s been a while since I came across such a great product, so I wanted to share it.
Among the many releases in the YOLO series, the newest one, YOLOX, came out in July 2021.
The YOLOX paper is available here (currently a preprint). The GitHub repository is here.
YOLO is an object detection algorithm. It is designed to run in real time, so it is extremely lightweight (inference alone can even run on a smartphone), it is easy to build systems around, and it has been adopted in many IoT devices.
“Object detection algorithm” may sound complicated, but an easy example to picture is a camera’s automatic face or eye focus. A marker appears telling you “here is a face”; the same idea applies to other objects as well, and each one can be classified as to what it is.
There are many versions in the YOLO series: YOLO, YOLOv2, YOLOv3, YOLOv4, YOLOv5, and YOLOX. It also runs not only on Python but on MATLAB as well, so you can adapt it to whichever platform you use.
Unlike the system used from YOLOv3 onward, YOLOX is based on the system of the original YOLO (the first published method), and it is said to be both faster and considerably more accurate.
Other blogs cover the details as well.
How to install YOLOX
Installation instructions are given on the GitHub page, but they are in English and do not cover using a virtual environment, so here I explain how to do it with an Anaconda virtual environment.
On both Windows and Mac, following the YOLOX manual exactly produced a string of errors. The errors will likely keep changing with future versions, so look them up as they come up.
See below for how to use the conda command in the macOS Terminal.
Open Terminal (Anaconda Prompt), and a black window filled with text will appear. To the left of the last line you should see (base). At this point you are not inside a virtual environment.
YOLOX will run without a virtual environment, but since environments can conflict with other packages, I recommend creating one.
First, enter the following code to create the virtual environment.
conda create -n YoloX python=3.8
YoloX is the name of the virtual environment; you can use any other name. You can also specify the Python version with python=3.8.
Then enter the virtual environment with the following code.
conda activate YoloX
If the (base) on the left has changed to (YoloX), you have succeeded.
Installing CUDA
First, if this is your first time installing machine learning libraries and you plan to train YOLO on a GPU, install CUDA. (Training on a CPU takes an absurdly long time, so I do not recommend it. Note, however, that GPUs cannot currently be used on Apple Silicon machines.) CUDA can be downloaded from the official site.
As for the CUDA version, I suggest checking which CUDA version PyTorch supports and then installing that version. PyTorch official site
To install an older version, click Download now and then, on the following screen, scroll down to Resources and use Archive of Previous CUDA Releases.
The latest version may well work too, but for now, matching the version to PyTorch should let you run everything without trouble.
To check whether it is installed on Windows, open “Edit the system environment variables,” go to Advanced > Environment Variables, and check whether there is a path beginning with CUDA_PATH. The number after the V indicates the version.
Installing PyTorch
Before installing, update pip. Enter the virtual environment in Anaconda Prompt and run the following command.
python -m pip install --upgrade pip
Go to the PyTorch official site and select the installation method that matches your environment. One thing to watch out for is the Package field: here, choose pip. Installing with conda will cause errors later on.
Copy and paste the command shown under “Run this Command” to install it in your virtual environment.
Once the installation finishes, use the following command to check that PyTorch is installed.
pip list
As long as torch appears in this list, you’re good to go!!! Just to make sure everything works, launch python and run the following command.
import torch
print(torch.cuda.is_available())
If the output is True, the installation went through without problems and torch is ready to run on the GPU. (On a Mac or on a computer without a GPU, you will get False, but as long as the import works you’re fine.) If you get an error, go back and check the installation again.
Installing the packages required for YOLOX
Download (clone) the various YOLOX files from GitHub. If you can use Git commands, you can clone it with the code below.
Next, navigate into the cloned folder and install the required packages.
First, edit the contents of requirements.txt in the cloned YOLOX folder as follows.
# TODO: Update with exact module version
numpy
#torch>=1.7
opencv_python
loguru
tqdm
#torchvision
thop
ninja
tabulate
# verified versions
# pycocotools corresponds to https://github.com/ppwwyyxx/cocoapi
#pycocotools>=2.0.2
#onnx==1.8.1
onnxruntime==1.8.0
onnx-simplifier==0.3.5
It seems that packages such as pycocotools cannot be installed with this command.
Once you’ve done that, save requirements.txt and run the command below in the terminal (Anaconda prompt).
cd YOLOX
pip3 install -r requirements.txt
pip3 install cython pycocotools
The YOLOX folder you downloaded contains a file called “requirements.txt” that lists the required packages. The second command opens this file in read-only mode and installs the packages listed in it.
pip3 install cython pycocotools
This command installs cython and pycocotools. It appears these need to be installed separately.
When you run this command, some of you may see the following error.
building 'pycocotools._mask' extension
error: Microsoft Visual C++ 14.0 or greater is required. Get it with "Microsoft C++ Build Tools": https://visualstudio.microsoft.com/visual-cpp-build-tools/
Apparently pycocotools requires Microsoft C++ Build Tools. (Even though there is no Mac version, the error still shows up on Mac.) If you’re on Windows, it’s a good idea to install it just in case.
Install it, then try installing again with the code below.
If that still doesn’t work, install it with the following command.
conda install -c conda-forge pycocotools
In general we’ve been installing these packages with pip, but since this one simply won’t install that way, we fall back on the last resort of installing it with conda.
Next, download yolox_x.pth. The download starts as soon as you click the link.
Move the downloaded file into the YOLOX folder you cloned from GitHub. This gives you the model used for detection in the demo, placed wherever you like.
Add the following lines near the top of tools/demo.py so that the script can access the yolox folder.
#demo.pyの中身に書き込みましょう。
import sys
import os
sys.path.append(os.path.join(os.path.dirname(__file__), '..'))
Without this, you will get an error saying that the yolox package cannot be found.
Then run the following command in the terminal. This lets you check whether the demo runs correctly.
I often pick out computers and give advice on them, and many friends told me I could make money doing computer consultations. Inspired by that, I decided to give it a try!
I’ll recommend a computer that suits what you plan to use it for and your budget. In particular, I’ve chosen and used many computers for machine learning.
And if you’d like, I can also advise you on what to look for the next time you buy a computer.
Computers I’ve picked out so far include lab analysis machines, everyday-use machines, game-streaming machines, machines for incoming university students, machines for architecture students that can run CAD, and basic no-frills machines.
I use both Mac and Windows, so I can talk about and recommend either!
What gets downloaded is an app you can run as is, so just move it into the Applications folder on your Mac.
Switching VS Code to Japanese
Install the “Japanese Language Pack for Visual Studio Code”.
Select Extensions from the menu bar on the left and type “Japanese Language Pack for Visual Studio Code”.
Then install the package with that same name that appears at the top of the list.
After that, restart VS Code and check that the interface is now in Japanese.
Installing the Python extension
Next, install the Python extension in the same way.
Select Extensions from the menu bar on the left, type “Python,” and install Python.
This sets up a Python development environment: you can use Jupyter when writing Python programs in VS Code, and the syntax is automatically recognized and color-coded.
Checking that it actually works
Create a file called test.py in any directory you like.
Create a new file, choose a text file, and specify Python as the language.
Then name it test.py and enter the following program:
print(“Hello World!!”)
Type that in.
Then run it with the play button in the upper right.
Hello World!! will be printed in the terminal below. Once you get this far, your Python development environment is up and running.
If you have set up virtual environments with Anaconda, you can select the one you want from the Python interpreter selector in the lower right. Alternatively, you can activate a virtual environment with the conda command in the terminal.