Hey, guys! I use bentoml 0.13.1 and I want to use ...
# ask-for-help
л
Hey, guys! I use bentoml 0.13.1 and I want to use JsonInput for predict method. When I call requests.post, I have some troubles with JSON data. Could you help me please? 🙏🏻 import requests import base64 pbar = tqdm(total=len(df)) df_test_predict_rzd = [] df_test_predict_inner = [] with torch.no_grad(): for id_row, row in df.iterrows(): f_path = row.path train_type = row.train_type number = row.number with open(f_path, 'rb') as file_to_send: binary_data = file_to_send.read() data = { "train_type": train_type, "file_stream": binary_data } json_data = json.dumps(data) out_response = requests.post(predict_api_endpoint, headers=headers, data=json_data) texts, scores = out_response.json() if train_type == 'rzd': df_test_predict_rzd.append([f_path, texts, number, scores]) else: df_test_predict_inner.append([f_path, texts, number, scores]) pbar.update(1) pbar.close() df_test_predict_rzd = pd.DataFrame(df_test_predict_rzd, columns=['path', 'pred_number', 'real_number', 'scores']) df_test_predict_inner = pd.DataFrame(df_test_predict_inner, columns=['path', 'pred_number', 'real_number', 'scores'])