Skip to content

Commit

Permalink
updateee
Browse files Browse the repository at this point in the history
  • Loading branch information
Archii0 committed Feb 25, 2024
1 parent 61cf6d7 commit b202971
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 7 deletions.
7 changes: 7 additions & 0 deletions AI/SpeedTesting.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

emotion_dict = {0: "Angry", 1: "Disgusted", 2: "Fearful", 3: "Happy", 4: "Neutral", 5: "Sad", 6: "Surprised"}

cumulativeEmotionArray = [0] *7

# load json and create model
json_file = open("AI/model/emotion_model.json", 'r')
Expand Down Expand Up @@ -36,8 +37,14 @@ def takeSinglePhoto(frame):
# predict the emotions
emotion_prediction = emotion_model.predict(cropped_img)
maxindex = int(np.argmax(emotion_prediction))
if (maxindex != -1):
cumulativeEmotionArray[maxindex] += 1
return [maxindex, x, y, w, h]


def getCumulativeArray():
return cumulativeEmotionArray

def mainLoop(frame):

# arrayOfEmotions = [0,0,0,0,0,0,0]
Expand Down
Binary file modified AI/__pycache__/SpeedTesting.cpython-310.pyc
Binary file not shown.
41 changes: 39 additions & 2 deletions app.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from AI.SpeedTesting import mainLoop
from AI.SpeedTesting import mainLoop, getCumulativeArray
from APIStuff.OpenAPI.initialPrompt import main
from flask import Flask, request
from flask_cors import CORS
from io import BytesIO
Expand Down Expand Up @@ -48,7 +49,7 @@ def index():



# Code without websocket

@app.route("/api/frame", methods=["POST"])
def imageProcess():

Expand All @@ -75,5 +76,41 @@ def imageProcess():
return img_str


@app.route("/api/emotionsArray", methods=["POST"])
def getEmotionsArray():

array = getCumulativeArray()
array = main()

newImg = list(map(str, array))
img_str = json.dumps(newImg)

return img_str

@app.route("/api/promt", methods=["POST"])
def getGPTOutput():

# Get array from json request - might not work ahahahh loser
jsonResponse = request.json()

# Parse the JSON data
parsedData = json.loads(jsonResponse)

# Access the array
dataArray = parsedData['data']

prompt = main(dataArray)

# newImg = list(map(str, array))
# img_str = json.dumps(newImg)



return img_str





if __name__ == "__main__":
app.run(port=2223)
2 changes: 1 addition & 1 deletion frontend/src/components/BoundingBox.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@ const BoundingBox = ({ boxData }) => {
</div>
);
};
export default BoundingBox
export default BoundingBox
6 changes: 3 additions & 3 deletions frontend/src/components/CustomWebcam.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,15 +80,15 @@ const CustomWebcam = ({ onHide }) => {
<div className="" style={{position: 'relative'}}>
<Webcam videoConstraints={videoConstraints} ref={webcamRef} class="camera"/>
{data && data[0] != 0 && <BoundingBox class="shift-to-center" boxData={data} />}
<p>Hold still for 8 seconds!</p>
<h4>Hold still while we analyse your mood!</h4>
</div></div>) : (<></>)}

</>

)}

</div>
<div class="">
{/* <div class="">
{loading ? (
<div class="text-center">
<p>Capturing face...</p>
Expand All @@ -99,7 +99,7 @@ const CustomWebcam = ({ onHide }) => {
<></>
)
}
</div>
</div> */}

</div>
);
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/Footer.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const Footer = () => {

return (

<footer class="footer">
<footer class="footer mt-5 pt-5">


<section class="grey py-4 mt-5 border-top border-light">
Expand Down

0 comments on commit b202971

Please sign in to comment.