Skip to content
Open
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
37 changes: 3 additions & 34 deletions AI_main/src/services/post.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ def Checksum(last_status, cur_status):
return True

def post(q):
<<<<<<< ours
"""
This function is module that send JSON data to the server.

Expand All @@ -67,19 +66,16 @@ def post(q):
headers = { "Content-Type":"application/json" }
response = None # reset response object. without this line, could be occur runtime error.
load_dotenv() # .env file load. file contains url of server.
=======
headers = { "Content-Type":"application/json" }
load_dotenv()
>>>>>>> theirs

url = os.getenv("API_BASE_URL")
url_Sendpoint = "/api/movie/agegroup"
url_Getpoint = "/api/movie/user"
url = url+url_Sendpoint

workcounter = 0 # just counter for prompt.
last_status = "" # reset last_status.
try :
while True:
<<<<<<< ours
start = time.time() # processing time check

try:
Expand All @@ -106,35 +102,12 @@ def post(q):
else :
# if data is duplicated, just restart loop. nothing do (wait).
continue

end = time.time()
if response :
print(f"| Request ... {workcounter} : ( DONE {end-start:.3f}s ) {response.text}")
else :
print(f"| Request ... {workcounter} : ( Response Error {end-start:.3f}s )")
workcounter += 1

=======
start = time.time()
print(f"Sending Requests {q.get()}")
if q.get()=="2-19":
s="아이"
elif q.get()=="20-60":
s="성인"
elif q.get()=="61+":
s="노인"
else :
s="노인"
data = { "ageGroup": s }
json_data = json.dumps(data)
try:
response = requests.post(url, data=json_data, headers=headers)
except Exception as request_e:
print(request_e)
end = time.time()
print(f"| ( DONE {end-start:.3f}s ) {response.text}")
# print(response.text)
>>>>>>> theirs
except Exception as e:
print(e)
pass
Expand All @@ -144,10 +117,6 @@ def post(q):
print("EXIT Post Module...")

if __name__ == "__main__" :
<<<<<<< ours
# s = "20-60"
s = queue.Queue(maxsize = 1)
=======
s = "20-60"
>>>>>>> theirs
#s = "20-60"
post(s)
17 changes: 5 additions & 12 deletions AI_main/src/utils/AgeFilter.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,13 @@ def AgeAnalyze(frame_data, age_data):
model_path = "src/model/age_classification_model_40_v4.keras"
model = keras.saving.load_model(model_path)
print("Model loaded successfully")
analyzecounter = 1
analyzecounter = 0
categories = ['2-19', '20-60', '61+']

while True:
<<<<<<< ours
start = time.time()
analyzecounter += 1
print(f"Analyzing {analyzecounter}")
=======
print("Analyzing...")
start = time.time()
>>>>>>> theirs
analyzecounter += 1
try:
frame = frame_data.get(timeout=0.5) # 1/2초 대기
processed_frame = preprocess_frame(frame)
Expand All @@ -38,11 +33,7 @@ def AgeAnalyze(frame_data, age_data):

age_data.put(predicted_age_group, block = False)
end = time.time()
<<<<<<< ours
print(f"| Analyzing {analyzecounter} : ( DONE {end-start:.2f}s ) {predicted_age_group}")
=======
print(f"| ( Analyzing DONE {end-start:.2f}s ) {predicted_age_group}")
>>>>>>> theirs

except queue.Full:
age_data.get()
Expand All @@ -61,4 +52,6 @@ def AgeAnalyze(frame_data, age_data):
break

if __name__ == "__main__":
AgeAnalyze()
a = queue.Queue(maxsize = 1)
b = queue.Queue(maxsize = 1)
AgeAnalyze(a,b)