Merge branch 'dev/dev_xp' into dev/dev
# Conflicts: # src/main/java/com/ai/da/service/CollectionElementService.java # src/main/java/com/ai/da/service/impl/CollectionElementServiceImpl.java
This commit is contained in:
@@ -21,10 +21,7 @@ import com.ai.da.python.vo.*;
|
||||
import com.ai.da.service.DesignHistoryService;
|
||||
import com.ai.da.service.PythonTAllInfoService;
|
||||
import com.ai.da.service.SysFileService;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONException;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.alibaba.fastjson.*;
|
||||
import com.alibaba.fastjson.serializer.SerializerFeature;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.google.common.collect.Lists;
|
||||
@@ -4199,4 +4196,58 @@ public class PythonService {
|
||||
//生成失败
|
||||
throw new BusinessException("brandDNAGenerate.interface.exception");
|
||||
}
|
||||
|
||||
public List<ImageSegmentation.ImageDate> imageSegmentation(ImageSegmentation imageSegmentation) {
|
||||
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");
|
||||
RequestBody body = RequestBody.create(mediaType, JSON.toJSONString(imageSegmentation));
|
||||
|
||||
log.info("modifyModelProportion 请求地址: {},\n 参数:{}", accessPythonIp + ":" + accessPythonPort + "/api/clothing_seg", JSON.toJSONString(imageSegmentation));
|
||||
Request request = new Request.Builder()
|
||||
.url(accessPythonIp + ":" + accessPythonPort + "/api/clothing_seg")
|
||||
.method("POST", body)
|
||||
.addHeader("Content-Type", "application/json")
|
||||
.build();
|
||||
Response response = null;
|
||||
try {
|
||||
response = client.newCall(request).execute();
|
||||
} catch (IOException ioException) {
|
||||
log.error("PythonService##imageSegmentation异常###{}", ExceptionUtil.getThrowableList(ioException));
|
||||
throw new BusinessException("generate.interface.error");
|
||||
}
|
||||
int responseCode = response.code();
|
||||
String bodyString;
|
||||
try {
|
||||
bodyString = response.body().string();
|
||||
if (responseCode != HttpURLConnection.HTTP_OK) {
|
||||
// 基本不会有除200以外的code
|
||||
log.info("imageSegmentation 失败。 Response code {}", responseCode);
|
||||
throw new BusinessException("imageSegmentation 失败。 Response code " + responseCode);
|
||||
}
|
||||
JSONObject jsonObject = JSON.parseObject(bodyString);
|
||||
if (response.isSuccessful() && jsonObject.get("msg").equals("OK!")) {
|
||||
log.info("imageSegmentation 结果 : {}", jsonObject.get("data").toString());
|
||||
List<ImageSegmentation.ImageDate> seg = JSONObject.parseObject(
|
||||
jsonObject.get("data").toString(),
|
||||
new TypeReference<List<ImageSegmentation.ImageDate>>() {}
|
||||
);
|
||||
return seg;
|
||||
}else {
|
||||
log.info("imageSegmentation 失败。 Response code {}", responseCode);
|
||||
throw new BusinessException("imageSegmentation 失败。 Response code " + responseCode);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
log.error("imageSegmentation 失败; error message => {}", e.getMessage());
|
||||
response.close();
|
||||
throw new BusinessException("generate.interface.error");
|
||||
} finally {
|
||||
response.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
20
src/main/java/com/ai/da/python/vo/ImageSegmentation.java
Normal file
20
src/main/java/com/ai/da/python/vo/ImageSegmentation.java
Normal file
@@ -0,0 +1,20 @@
|
||||
package com.ai.da.python.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class ImageSegmentation {
|
||||
|
||||
private Long user_id;
|
||||
private List<ImageDate> image_data;
|
||||
|
||||
@Data
|
||||
public class ImageDate{
|
||||
public String image_url;
|
||||
public String image_type;
|
||||
// 作为入参时一起传入会怎样?
|
||||
public List<String> clothing_url;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user