#python #google-colaboratory
Вопрос:
def ensemble_predict(scheme_model,quality_model,rotate_model,img,y=None):
quality_labels = ["blur","sharp","torch"]
rotate_labels = [0,90,-90,180]
bgr_labels = ["bgr","rgb"]
scheme_pred = scheme_model.predict(img)[0]
quality_pred = quality_model.predict(img)[0]
rotate_pred = rotate_model.predict(img)[0]
cv2_imshow(cv2.resize(img[0]*255,(256,256)))
p = scheme_pred
scheme_pred = 0 if scheme_pred < 0.5 else 1
print("Predict BGR or RGB:", bgr_labels[scheme_pred], ", p:",p[0])
print("Predict quality:", quality_labels[np.argmax(quality_pred)], ", p:", quality_pred[np.argmax(quality_pred)])
print("Predict rotation:" ,rotate_labels[np.argmax(rotate_pred)], ", p:", rotate_pred[np.argmax(rotate_pred)])
print()
if y is not None:
q_l = quality_labels[y[0]]
r_l = rotate_labels[y[1]]
b_l = bgr_labels[y[2]]
print("True BGR or RGB:", b_l)
print("True quality:", q_l)
print("True rotation:" ,r_l)
print()
print()
Я работаю в Google colab, как я могу сделать печать справа от изображения, которое я вывожу через cv2_imшоу Я прикрепил пример кода, я рад видеть решение, но я также готов применить альтернативу
Ответ №1:
Попробуй это:
def ensemble_predict(scheme_model,quality_model,rotate_model,img,y=None):
quality_labels = ["blur","sharp","torch"]
rotate_labels = [0,90,-90,180]
bgr_labels = ["bgr","rgb"]
scheme_pred = scheme_model.predict(img)[0]
quality_pred = quality_model.predict(img)[0]
rotate_pred = rotate_model.predict(img)[0]
cv2_imshow(cv2.resize(img[0]*255,(256,256)))
print("",end='')
p = scheme_pred
scheme_pred = 0 if scheme_pred < 0.5 else 1
print("t Predict BGR or RGB:", bgr_labels[scheme_pred], ", p:",p[0],end='')
print("t Predict quality:", quality_labels[np.argmax(quality_pred)], ", p:", quality_pred[np.argmax(quality_pred)],end='')
print("t Predict rotation:" ,rotate_labels[np.argmax(rotate_pred)], ", p:", rotate_pred[np.argmax(rotate_pred)],end='')
print()
if y is not None:
q_l = quality_labels[y[0]]
r_l = rotate_labels[y[1]]
b_l = bgr_labels[y[2]]
print("True BGR or RGB:", b_l)
print("True quality:", q_l)
print("True rotation:" ,r_l)
print()
print()
Комментарии:
1. он просто делает несколько шагов
2. Как? не могли бы вы предоставить скриншот?