Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX] 미션 수행 전용 서버가 다운되는 문제 #21

Merged
merged 4 commits into from
Aug 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,10 @@ out/
### application.yml ###
application-dev.yml
application-prod.yml
application-local.yml
application-oauth.properties

### firebase sdk json ###
togetup-26b96-firebase-adminsdk-3l3ah-3164ed8f18.json
togetup-26b96-firebase-adminsdk-3l3ah-3164ed8f18.json

### log files ###
/logs
69 changes: 0 additions & 69 deletions logs/app.log

This file was deleted.

Binary file removed logs/error-2023-06-13.0.gz
Binary file not shown.
218 changes: 0 additions & 218 deletions logs/error.log

This file was deleted.

10 changes: 0 additions & 10 deletions src/main/java/com/wakeUpTogetUp/togetUp/alarm/model/Alarm.java
Original file line number Diff line number Diff line change
Expand Up @@ -75,27 +75,17 @@ public void modifyProperties(Mission mission, String name, String icon, String s
private String name;
private String icon;
private String sound;
@Column(columnDefinition = "tinyint")
private Boolean isVibrate;
@Column(columnDefinition = "tinyint")
private Boolean isRoutineOn;
private Integer snoozeInterval;
private Integer snoozeCnt;
private Time alarmTime;
@Column(columnDefinition = "tinyint")
private Boolean monday;
@Column(columnDefinition = "tinyint")
private Boolean tuesday;
@Column(columnDefinition = "tinyint")
private Boolean wednesday;
@Column(columnDefinition = "tinyint")
private Boolean thursday;
@Column(columnDefinition = "tinyint")
private Boolean friday;
@Column(columnDefinition = "tinyint")
private Boolean saturday;
@Column(columnDefinition = "tinyint")
private Boolean sunday;
@Column(columnDefinition = "tinyint")
private Boolean isActivated;
}
26 changes: 23 additions & 3 deletions src/main/java/com/wakeUpTogetUp/togetUp/config/ODConfig.java
Original file line number Diff line number Diff line change
@@ -1,15 +1,35 @@
package com.wakeUpTogetUp.togetUp.config;

import ai.onnxruntime.OrtEnvironment;
import ai.onnxruntime.OrtException;
import ai.onnxruntime.OrtSession;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;

import javax.annotation.PostConstruct;
import java.util.Random;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.HashMap;

public final class ODConfig {
public static final String modelPath = "src\\main\\resources\\model\\yolov7-d6.onnx";
// public static final String savePicPath = "src\\images\\result\\img_test.png";
@Configuration
public class ODConfig {
@PostConstruct
public void init() throws OrtException {
// ONNX 모델 로드
environment = OrtEnvironment.getEnvironment();
sessionOptions = new OrtSession.SessionOptions();
session = environment.createSession(modelPath, sessionOptions);
}
public static OrtSession session;
public static OrtEnvironment environment;
public static OrtSession.SessionOptions sessionOptions;

@Value("${my.path.model-path}")
public String modelPath;

public static final Integer lineThicknessRatio = 333;
public static final Double fontSizeRatio = 1145.14;
private static final List<String> names = new ArrayList<>(Arrays.asList(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

@RestControllerAdvice
public class GlobalExceptionHandler {

final Logger logger = LoggerFactory.getLogger(this.getClass());

// Catch Custom Exception(BaseException)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public class MappingGroupUserController {

@ResponseBody
@PostMapping("/{userId}/{groupId}/registration")
public BaseResponse create(@PathVariable("userId") Integer userId,@PathVariable("groupId")Integer groupId,@RequestBody MappingGroupUserReq mappingGroupUserReq) {
public BaseResponse create(@PathVariable("userId") Integer userId, @PathVariable("groupId")Integer groupId,@RequestBody MappingGroupUserReq mappingGroupUserReq) {
try {

//TODO : 그 그룹에 Host 유저가 있는지. (host는 한명)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ public Mission(String name, String object) {
private String createdAt;
@Column(columnDefinition = "Timestamp")
private String updatedAt;
@Column(name = "isActivated", columnDefinition = "tinyint")
private Boolean isActivated;

@OneToMany(mappedBy = "mission")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,5 @@ public MissionCompleteLog(String type, String title, String picLink, User user,
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "alarmId")
private Alarm alarm;
@Column(columnDefinition = "tinyint")
private Boolean isActivated;
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,11 @@
public class ObjectDetection {
public ArrayList<String> detectObject(MultipartFile missionImage) {
try{
// ONNX 모델 로드
OrtEnvironment environment = OrtEnvironment.getEnvironment();
OrtSession.SessionOptions sessionOptions = new OrtSession.SessionOptions();
OrtSession session = environment.createSession(ODConfig.modelPath, sessionOptions);
// 기본 정보 출력
session.getInputInfo().keySet().forEach(x-> {
ODConfig.session.getInputInfo().keySet().forEach(x-> {
try {
System.out.println("input name = " + x);
System.out.println(session.getInputInfo().get(x).getInfo().toString());
System.out.println(ODConfig.session.getInputInfo().get(x).getInfo().toString());
} catch (OrtException e) {
throw new RuntimeException(e);
}
Expand Down Expand Up @@ -78,12 +74,12 @@ public ArrayList<String> detectObject(MultipartFile missionImage) {

// OnnxTensor 개체 만들기
long[] shape = { 1L, (long)channels, (long)rows, (long)cols };
OnnxTensor tensor = OnnxTensor.createTensor(environment, FloatBuffer.wrap(pixels), shape);
OnnxTensor tensor = OnnxTensor.createTensor(ODConfig.environment, FloatBuffer.wrap(pixels), shape);
HashMap<String, OnnxTensor> stringOnnxTensorHashMap = new HashMap<>();
stringOnnxTensorHashMap.put(session.getInputInfo().keySet().iterator().next(), tensor);
stringOnnxTensorHashMap.put(ODConfig.session.getInputInfo().keySet().iterator().next(), tensor);

// 실행 모델
OrtSession.Result output = session.run(stringOnnxTensorHashMap);
OrtSession.Result output = ODConfig.session.run(stringOnnxTensorHashMap);

// 결과를 얻다
float[][] outputData = (float[][]) output.get(0).getValue();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ public class User {
private Timestamp tokenUpdated;



@OneToMany(mappedBy = "user")
private List<MappingGroupUser> mappingGroupUsers = new ArrayList<>();

Expand Down