Is there anyway to save the image with the predictions and their bounding boxes after printing the result ?
from darkflow.net.build import TFNet
import cv2
options = {"model": "cfg/yolo.cfg", "load": "bin/yolo.weights", "threshold": 0.1}
tfnet = TFNet(options)
imgcv = cv2.imread("./sample_img/sample_dog.jpg")
result = tfnet.return_predict(imgcv)
print(result)
You will have to write your own function to draw the boxes and write the image after parsing the json output.
You can use code like this
cv2.rectangle(imgcv,
(result["topleft"]["x"], result["topleft"]["y"]),
(result["bottomright"]["x"],
result["bottomright"]["y"]),
(0, 255, 0), 4)
text_x, text_y = result["topleft"][
"x"] - 10, result["topleft"]["y"] - 10
cv2.putText(imgcv, result["label"], (text_x, text_y),
cv2.FONT_HERSHEY_SIMPLEX, 0.8, (0, 255, 0), 2, cv2.LINE_AA)
Where result is single element from list of results returned by return predict method and imgcv is the original image. Hope this help!
Thank you !
Is there anyway to save the image with the predictions and their bounding boxes after printing the result ?
from darkflow.net.build import TFNet
import cv2options = {"model": "cfg/yolo.cfg", "load": "bin/yolo.weights", "threshold": 0.1}
tfnet = TFNet(options)
imgcv = cv2.imread("./sample_img/sample_dog.jpg")
result = tfnet.return_predict(imgcv)
print(result)
I am having an issue while executing this code. Can you please tell me about "load" parameter.
Is there anyway to save the image with the predictions and their bounding boxes after printing the result ?
from darkflow.net.build import TFNet
import cv2
options = {"model": "cfg/yolo.cfg", "load": "bin/yolo.weights", "threshold": 0.1}
tfnet = TFNet(options)
imgcv = cv2.imread("./sample_img/sample_dog.jpg")
result = tfnet.return_predict(imgcv)
print(result)I am having an issue while executing this code. Can you please tell me about "load" parameter.
@abhishek795jha "load" parameter is your weight files .......initial we take yolo weight file after training you create .pb file for testing as a weight file . In training time you have to use comand "--savepb" to save .pb file using with flow command .
Most helpful comment
You can use code like this
Where result is single element from list of results returned by return predict method and imgcv is the original image. Hope this help!