Skip to content

Instantly share code, notes, and snippets.

@bala-codes
Last active August 12, 2020 17:32
Show Gist options
  • Save bala-codes/7e04dae81548447a67366d9e08987763 to your computer and use it in GitHub Desktop.
Save bala-codes/7e04dae81548447a67366d9e08987763 to your computer and use it in GitHub Desktop.
Yolo_to_production
import os, sys, random
from glob import glob
import matplotlib.pyplot as plt
%matplotlib inline
!pip install -qr '/content/drive/My Drive/Machine Learning Projects/YOLO/SOURCE/requirements.txt' # install dependencies
## Add the path where you have stored the neccessary supporting files to run detect.py ##
## Replace this with your path.##
sys.path.insert(0, '/content/drive/My Drive/Machine Learning Projects/YOLO/SOURCE/')
print(sys.path)
cwd = os.getcwd()
print(cwd)
## Single Image prediction
## Beware the contents in the output folder will be deleted for every prediction
output = !python '/content/drive/My Drive/Machine Learning Projects/YOLO/SOURCE/detect.py'
--source '/content/BloodImage_00026.jpg'
--weights '/content/drive/My Drive/Machine Learning Projects/YOLO/SOURCE/best_BCCM.pt'
--output '/content/OUTPUTS/' --device 'cpu'
print(output)
img = plt.imread('/content/OUTPUTS/BloodImage_00026.jpg')
plt.imshow(img)
## Folder Prediction
output = !python '/content/drive/My Drive/Machine Learning Projects/YOLO/SOURCE/detect.py'
--source '/content/inputs/'
--weights '/content/drive/My Drive/Machine Learning Projects/YOLO/SOURCE/best_BCCM.pt'
--output '/content/OUTPUTS/' --device 'cpu'
print(output)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment