The model is built in pytorch and deployed as a REST API using Flask
pip install -r requirements.txt
Scraped 1200+ samples for model training, validation & testing using selenium
which then filterd to 1200 samples
Dataset is collected for 13 different countries from Europe, USA & Australia
Input data are resized, normalized accross the RGB channels & transformed to pytorch tensors:
transforms.Compose([
transforms.Resize((224,224)),
transforms.ToTensor(),
transforms.Normalize((0.5, 0.5, 0.5), (0.5, 0.5, 0.5))])
Model is finetuned on resnet-101 with Adam optimizer and hyperparameters:
batch_size = 32
n_epochs = 32
learning_rate = 0.0001
betas = (0.9, 0.999)
-
app.py: Flask API application
-
build_model.py: Utilities for building the inference model
-
scraping_data.ipynb: Jupyter notebook for scraping the data
-
train.classifier.ipynb: Jupyter notebook for training the model
-
lib/models: Should contain saved_weights for the trained model
-
You should make a new directory lib/models in the current working directory
-
mkdir lib && cd lib && mkdir models
-
Please download the model weights from this:
link
also, you'll find the scraped dataset through this link
- Run the Flask API locally for testing. Go to directory with
app.py
python app.py
- In a new terminal window, use HTTPie to make a GET request at the URL of the API or use
curl
command for the same purpose
curl -X GET http://127.0.0.1:5000/ -d img="img_path"
-X option for "Specifing request command to use"
Example of curl
request
curl -X GET http://127.0.0.1:5000/ -d img='/home/ayman/scraped_dataset/day/9ea6801b53.jpg'
- Example of successful output.
Serving Flask app "app" (lazy loading)
Environment: production
WARNING: This is a development server. Do not use it in a production deployment.
Use a production WSGI server instead.
Debug mode: on
Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
Restarting with inotify reloader
Debugger is active!
Debugger PIN: 167-245-170
127.0.0.1 - - [15/Feb/2021 20:35:31] "GET / HTTP/1.1" 200 -
{
"prediction: ": "Day",
"confidence: ": 0.9999970197677612
}