I got data from here. You should apply for permission first. Download it and name it as data
.
You can download a pretrained model from here. It's a fine-tuned EfficientNet-b3 using pytorch-lightning
- A unix or unix-like x86 machine
- Python 3.8 or higher.
- Running in a virtual environment (e.g., conda, virtualenv, etc.) is highly recommended so that you don't mess up with the system Python.
pip install -r requirements.txt
- Check out
explore-data.ipynb
to explore dataset. - Run
train.py
to train.train.py [-h] [--seed SEED] [--batch-size BATCH_SIZE] [--image-size IMAGE_SIZE] [--limit-data LIMIT_DATA] [--num-classes NUM_CLASSES] [--data-dir DATA_DIR] [--efficientnet EFFICIENTNET] [--epochs EPOCHS] [--use-gpu] [--precision PRECISION] [--patience PATIENCE]
- Check out
evaluation.py
to evaluate and see some samples.
This Flask server is implemented in app.py
. It receives an image and outputs a
probability distribution over the seven room types (i.e., interior, bathroom, bedroom, exterior, living_room, kitchen, and dining_room).
There are two ways to run the server. You can either run it natively in Python or as a docker container. The docker way is recommended.
-
The docker way (recommended)
- Install docker.
- For GPU,
docker run -it --rm -p 10005:10005 --gpus all tae898/room-classification-cuda
- For CPU,
docker run -it --rm -p 10005:10005 tae898/room-classification
-
Running natively in Python (GPUs are supported)
- First do Prerequisites
- Download
model.ckpt
and place it in the root repo directory. -
python app.py
The Python client sends an image to the server. This image is either an image saved in your disk or your webcam stream.
- First do Prerequisites
- Install requirements
pip install -r requirements-client.txt
- Run the server
-
Run the room-classifier on the image saved in your disk:
python client.py --mode image --image-path path/to/the/image.jpg
This will save the results at
path/to/the/image.jpg.json
. It'll look something like this:"interior": 0.0012067470233887434, "bathroom": 0.004016552586108446, "bedroom": 0.9945330619812012, "exterior": 9.643802059144946e-07, "living_room": 0.00022632408945355564, "kitchen": 9.742022484715562e-06, "dining_room": 6.571232916030567e-06
-
Run the room-classifier on webcam:
python client.py --mode webcam
- Make it lighter.
- Better docstring.
- More love.
Contributions are what make the open source community such an amazing place to be learn, inspire, and create. Any contributions you make are greatly appreciated.
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature
) - Run
make style && make quality
in the root repo directory, to ensure code quality. - Commit your Changes (
git commit -m 'Add some AmazingFeature'
) - Push to the Branch (
git push origin feature/AmazingFeature
) - Open a Pull Request