Merge remote-tracking branch 'origin/dev/dev' into dev/dev
# Conflicts: # src/main/java/com/ai/da/python/PythonService.java
This commit is contained in:
@@ -3920,9 +3920,9 @@ public class PythonService {
|
||||
// accessPythonPort,
|
||||
// userHolder.getId(),
|
||||
// category);
|
||||
String url = String.format("%s:%s/recommend/%d/%s/1",
|
||||
"127.0.0.1",
|
||||
"8000",
|
||||
String url = String.format("%s:%s/api/recommend/%d/%s/1",
|
||||
"http://18.167.251.121",
|
||||
"9994",
|
||||
userHolder.getId(),
|
||||
category);
|
||||
|
||||
@@ -3966,6 +3966,56 @@ public class PythonService {
|
||||
}
|
||||
}
|
||||
|
||||
public JSONObject segProduct(String url) {
|
||||
OkHttpClient client = new OkHttpClient().newBuilder()
|
||||
.connectTimeout(30, TimeUnit.SECONDS)
|
||||
.pingInterval(5, TimeUnit.SECONDS)//websocket轮训间隔(单位:秒)
|
||||
.readTimeout(60, TimeUnit.SECONDS)//读取超时(单位:秒)
|
||||
.writeTimeout(60, TimeUnit.SECONDS)//写入超时(单位:秒)
|
||||
.build();
|
||||
MediaType mediaType = MediaType.parse("application/json");
|
||||
//关闭FastJson的引用检测 防止出现$ref 现象
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("image_url", url);
|
||||
map.put("is_brand_dna", Boolean.TRUE);
|
||||
log.info("bright请求python 参数:####{}", map);
|
||||
String param = JSON.toJSONString(map, SerializerFeature.WriteNullStringAsEmpty);
|
||||
log.info(param);
|
||||
RequestBody body = RequestBody.create(mediaType, param);
|
||||
Request request = new Request.Builder()
|
||||
// .url(accessPythonIp + ":" + accessPythonPort + "/api/generate_product_image")
|
||||
// .url(accessPythonIp + ":9996/api/generate_product_image")
|
||||
.url(accessPythonIp + ":" + accessPythonPort + "/api/seg_product")
|
||||
.method("POST", body)
|
||||
.addHeader("Authorization", "Basic YWlkbGFiOjEyMw==")
|
||||
.addHeader("Content-Type", "application/json")
|
||||
.build();
|
||||
Response response;
|
||||
String responseBody;
|
||||
try {
|
||||
response = client.newCall(request).execute();
|
||||
} catch (IOException ioException) {
|
||||
log.error("PythonService##bright异常###{}", ExceptionUtil.getThrowableList(ioException));
|
||||
throw new BusinessException("segProduct.interface.exception");
|
||||
}
|
||||
if (response.isSuccessful()) {
|
||||
try {
|
||||
if (Objects.nonNull(response.body())) {
|
||||
responseBody = response.body().string();
|
||||
JSONObject responseObject = JSON.parseObject(responseBody);
|
||||
log.info("PythonService##responseObject###{}", responseObject);
|
||||
return responseObject;
|
||||
}
|
||||
throw new BusinessException("segProduct.interface.exception");
|
||||
} catch (IOException | JSONException e) {
|
||||
log.error("PythonService##segProduct异常###{}", e.getMessage());
|
||||
throw new BusinessException("segProduct.interface.exception");
|
||||
}
|
||||
}
|
||||
log.error("PythonService##segProduct异常response###{}", response);
|
||||
//生成失败
|
||||
throw new BusinessException("segProduct.interface.exception");
|
||||
}
|
||||
public Boolean poseTransformation(String productImage, int poseId, String taskId) {
|
||||
OkHttpClient client = new OkHttpClient().newBuilder()
|
||||
.connectTimeout(30, TimeUnit.SECONDS)
|
||||
|
||||
Reference in New Issue
Block a user