結果を印刷した後、予測とそのバウンディングボックスを使用して画像を保存する方法はありますか?
darkflow.net.buildからインポートTFNet
cv2をインポートする
options = {"model": "cfg / yolo.cfg"、 "load": "bin / yolo.weights"、 "threshold":0.1}
tfnet = TFNet(オプション)
imgcv = cv2.imread( "./ sample_img / sample_dog.jpg")
結果= tfnet.return_predict(imgcv)
print(result)
ボックスを描画し、json出力を解析した後に画像を書き込むには、独自の関数を作成する必要があります。
このようなコードを使用できます
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)
ここで、resultはreturnpredictメソッドによって返される結果のリストからの単一要素であり、imgcvは元の画像です。 この助けを願っています!
ありがとう !
結果を印刷した後、予測とそのバウンディングボックスを使用して画像を保存する方法はありますか?
darkflow.net.buildからインポートTFNet
cv2をインポートするoptions = {"model": "cfg / yolo.cfg"、 "load": "bin / yolo.weights"、 "threshold":0.1}
tfnet = TFNet(オプション)
imgcv = cv2.imread( "./ sample_img / sample_dog.jpg")
結果= tfnet.return_predict(imgcv)
print(result)
このコードの実行中に問題が発生しました。 「load」パラメータについて教えてください。
結果を印刷した後、予測とそのバウンディングボックスを使用して画像を保存する方法はありますか?
darkflow.net.buildからインポートTFNet
cv2をインポートする
options = {"model": "cfg / yolo.cfg"、 "load": "bin / yolo.weights"、 "threshold":0.1}
tfnet = TFNet(オプション)
imgcv = cv2.imread( "./ sample_img / sample_dog.jpg")
結果= tfnet.return_predict(imgcv)
print(result)このコードの実行中に問題が発生しました。 「load」パラメータについて教えてください。
@ abhishek795jha 「load」パラメータはウェイトファイルです.......最初に、トレーニング後にyoloウェイトファイルを取得し、ウェイトファイルとしてテストするための.pbファイルを作成します。 トレーニング時間では、コマンド「--savepb」を使用して、flowコマンドを使用して.pbファイルを保存する必要があります。
最も参考になるコメント
このようなコードを使用できます
ここで、resultはreturnpredictメソッドによって返される結果のリストからの単一要素であり、imgcvは元の画像です。 この助けを願っています!