anthng / Car-Parking-Occupancy-Detection

The implementation of "Acharya, D., Yan, D., Khoshelham, K., (2018) Real-time image-based parking occupancy detection using deep learning, In the proceedings of the 5th Annual Conference of Research@Locate, Adelaide, Australia, CEUR Workshop Proceedings. 2087: 33-40".
http://ceur-ws.org/Vol-2087/paper5.pdf
MIT License
0 stars 0 forks source link

how to inference on a video input #2

Open linchunmian opened 4 years ago

linchunmian commented 4 years ago

HI, thanks for your great work. I want to use the pretrained model on PKL dataset to test a video, how should I do step by step? How to save the model and how to input a video for inference?

anthng commented 4 years ago

HI, thanks for your great work. I want to use the pretrained model on PKL dataset to test a video, how should I do step by step? How to save the model and how to input a video for inference?

I wrote "How to use" at the "Usage" section in README.md. In order to input for a video, you refer to Face detection using a webcam. Good luck!

Preparation

  1. Git clone https://github.com/anthng/Car-Parking-Occupancy-Detection.git
  2. Download Dataset: link
  3. Create folder: 'dataset', and then move the dataset zip into 'dataset' folder. Finally, unzip the dataset zip.
  4. Open terminal in the root project folder: run pip install -r requirements.txt in your terminal.

Run

In your terminal

Feature extraction by CNN, and SVM classifier

Save model

In python svm_clf_from_cnn_feats.py, you import pickle library. Add pickle.dump(...) line after clf.fit(X_train, y_train).

E.g:

import pickle
...
clf.fit(X_train, y_train)
pickle.dump(clf, open('<path_to_save_model>', 'wb'))

Load model

clf= pickle.load(open('<path_to_save_model>', 'rb'))
linchunmian commented 4 years ago

Thanks. But how to use the train.py? Is it for model training? I am confused that how to use these scripts step by step, and save a good model for video inference. Please help me! Thanks.

linchunmian commented 4 years ago

I mean, if I want to connect to a wecam to conduct parking slot surveillance online, how should I train a model and use for inference?

anthng commented 3 years ago

I mean, if I want to connect to a wecam to conduct parking slot surveillance online, how should I train a model and use for inference?

Do you want to apply this repo to an online system? I can show you an overview of what to do.

You use train.py to train the model and save the best model. You need to write a prediction file (predict.py).

In prediction file,

image = cv2.imread(img)
image = cv2.resize(image, (WIDTH, HEIGHT))
image_x = np.expand_dims(image, axis=0)
image_x = preprocess_input(image_x)

That's all, I hope this is helpful to you.

linchunmian commented 3 years ago

Many Thanks for your kindness and help.