testdump1 commited on
Commit
93aed6f
·
verified ·
1 Parent(s): ea8dfd4

Upload 9 files

Browse files
.gitattributes CHANGED
@@ -33,3 +33,5 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ humerunthroughpicture.jpg filter=lfs diff=lfs merge=lfs -text
37
+ IMG_6115.MOV filter=lfs diff=lfs merge=lfs -text
HumeBatch.py ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from hume import HumeBatchClient
2
+ from hume.models.config import FaceConfig
3
+
4
+
5
+ newTimeOut = 3000
6
+ client = HumeBatchClient("<your-api-key-here>", timeout=newTimeOut)
7
+
8
+
9
+ files = ["/Users/jetlin/Desktop/HackMercedWorkshops/HumeRunthrough/humerunthroughpicture.jpg"]
10
+ configs = [FaceConfig(identify_faces=True)]
11
+ job = client.submit_job(urls=[], configs=configs, files=files)
12
+
13
+ print(job)
14
+ print("Running...")
15
+
16
+ job.await_complete()
17
+ job.download_predictions("predictions.json")
18
+ print("Predictions downloaded to predictions.json")
19
+
20
+ job.download_artifacts("artifacts.zip")
21
+ print("Artifacts downloaded to artifacts.zip")
22
+
23
+ print(job.get_predictions())
HumeGradioBatch.py ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from hume import HumeBatchClient
2
+ from hume.models.config import FaceConfig
3
+ import gradio as gr
4
+
5
+
6
+ def HumeBatch(client_key, file):
7
+ newTimeOut = 3000
8
+ client = HumeBatchClient(client_key, timeout=newTimeOut)
9
+
10
+ files = [file]
11
+
12
+ configs = [FaceConfig(identify_faces=True)]
13
+ job = client.submit_job(urls=[], configs=configs, files=files)
14
+
15
+ print(job)
16
+ print("Running...")
17
+ job.await_complete()
18
+ job.download_predictions("predictions.json")
19
+ job.download_artifacts("artifacts.zip")
20
+ return (job, job.get_predictions())
21
+
22
+
23
+ interface = gr.Interface(
24
+ fn = HumeBatch,
25
+ inputs = ["text", gr.Image(label = "Image to analyze", type="filepath")], #client key, files
26
+ outputs = ["text", "text"],# for predictions, and for artifacts
27
+ description = "Enter a picture for emotion analysis"
28
+ ).launch(share=True, auth=("jet", "pass"), auth_message="check your email for username and password")
29
+
30
+
31
+ # print(job)
32
+ # print("Running...")
33
+
34
+ # job.await_complete()
35
+ # job.download_predictions("predictions.json")
36
+ # print("Predictions downloaded to predictions.json")
37
+
38
+ # job.download_artifacts("artifacts.zip")
39
+ # print("Artifacts downloaded to artifacts.zip")
40
+
41
+ # print(job.get_predictions())
HumeGradioStream.py ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from hume import HumeStreamClient
2
+ from hume.models.config import FaceConfig
3
+ from hume.models.config import ProsodyConfig
4
+ import gradio as gr
5
+
6
+ import asyncio
7
+
8
+ async def HumeStream(client_key, video_file):
9
+ newOpenTimeOut = 3000
10
+ newCloseTimeOut = 3000
11
+
12
+ client = HumeStreamClient(client_key, open_timeout=newOpenTimeOut, close_timeout=newCloseTimeOut)
13
+
14
+ file = video_file
15
+
16
+ configs = [FaceConfig(identify_faces=True), ProsodyConfig()]
17
+ async with client.connect(configs) as socket:
18
+ result = await socket.send_file(file)
19
+ return result
20
+
21
+
22
+
23
+ interface = gr.Interface( # inputs key, and video file #outputs: prediction json
24
+ fn = HumeStream,
25
+ inputs = ["text", gr.Video(label = "Video to analyze", format="mp4")], #client key, video file
26
+ outputs = ["text"],# for predictions in JSON
27
+ description = "Enter a video for emotion analysis"
28
+ ).launch(share=True, auth=("jet", "pass"), auth_message="check your email for username and password")
29
+
HumeStream.py ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from hume import HumeStreamClient
2
+ from hume.models.config import FaceConfig
3
+ from hume.models.config import ProsodyConfig
4
+
5
+ import asyncio
6
+
7
+ async def main():
8
+ newOpenTimeOut = 3000
9
+ newCloseTimeOut = 3000
10
+ client = HumeStreamClient("<your-api-key-here>", open_timeout=newOpenTimeOut, close_timeout=newCloseTimeOut)
11
+ configs = [FaceConfig(identify_faces=True), ProsodyConfig()]
12
+ async with client.connect(configs) as socket:
13
+ result = await socket.send_file("/Users/jetlin/Desktop/HackMercedWorkshops/HumeRunthrough/IMG_6115.MOV")
14
+ print(result)
15
+
16
+ asyncio.run(main())
IMG_6115.MOV ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:80e230bf9f40672aa079c9c550a3f7718ce6947466d16639912f20b815911649
3
+ size 1295643
README.md CHANGED
@@ -1,3 +1,31 @@
1
- ---
2
- license: mit
3
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # HumeGradio
2
+ This is a website that I created using Hume AI and Gradio web interface.
3
+
4
+ With the website you can enter images or video and you can get predictions of emotions based on the faces present in the video or image
5
+
6
+ This is code from my HackMerced Workshop
7
+
8
+ Here is my notion document going through the workshop!
9
+
10
+ https://opaque-saxophone-bd8.notion.site/Hume-AI-Gradio-Workshop-85837ad117ac4f15a618f0c031ec59b2?pvs=4
11
+
12
+ here are some examples
13
+
14
+ HumeGradioBatch.py
15
+ <img width="1440" alt="Hume Gradio Batch" src="https://github.com/Lin-Jet/HumeGradio/assets/110573869/0ef80df8-19d0-4d55-8d24-09f9ec982bda">
16
+
17
+ HumeGradioStream.py
18
+ <img width="1440" alt="Hume Gradio Stream " src="https://github.com/Lin-Jet/HumeGradio/assets/110573869/3a3e0df4-45cd-46ce-b6bd-cb8c7634cd41">
19
+
20
+ to run:
21
+
22
+ start by running in terminal
23
+ pip install gradio
24
+
25
+ then...
26
+
27
+ gradio HumeGradioBatch.py
28
+
29
+ or
30
+
31
+ gardio HumeGradioStream.py
artifacts.zip ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:2c905bf44f18ef13707e0462d44f6cf929fe08d671337f3f7cc83ff18ad21b30
3
+ size 2711
humerunthroughpicture.jpg ADDED

Git LFS Details

  • SHA256: c4e355fa48acb8b2420104a0e382c0aed9edb6aeace796c3021c68f6d88d8bdd
  • Pointer size: 132 Bytes
  • Size of remote file: 1.33 MB
predictions.json ADDED
@@ -0,0 +1 @@
 
 
1
+ [{"source": {"type": "file", "filename": "webcam.png", "content_type": null, "md5sum": "81e40fb68cf9df7c53b0796d41e1371b"}, "results": {"predictions": [{"file": "webcam.png", "file_type": "image", "models": {"face": {"metadata": null, "grouped_predictions": [{"id": "face_0", "predictions": [{"frame": 0, "time": 0.0, "prob": 0.9999127388000488, "box": {"x": 444.5480651855469, "y": 51.3579216003418, "w": 325.3928527832031, "h": 393.1644477844238}, "emotions": [{"name": "Admiration", "score": 0.16120806336402893}, {"name": "Adoration", "score": 0.20312044024467468}, {"name": "Aesthetic Appreciation", "score": 0.06651479750871658}, {"name": "Amusement", "score": 0.826917290687561}, {"name": "Anger", "score": 0.02351520210504532}, {"name": "Anxiety", "score": 0.04760069400072098}, {"name": "Awe", "score": 0.07075104117393494}, {"name": "Awkwardness", "score": 0.1362791210412979}, {"name": "Boredom", "score": 0.04541467875242233}, {"name": "Calmness", "score": 0.1670946478843689}, {"name": "Concentration", "score": 0.07362263649702072}, {"name": "Confusion", "score": 0.06727410107851028}, {"name": "Contemplation", "score": 0.036862120032310486}, {"name": "Contempt", "score": 0.051071301102638245}, {"name": "Contentment", "score": 0.2734031677246094}, {"name": "Craving", "score": 0.029621867462992668}, {"name": "Desire", "score": 0.04719311371445656}, {"name": "Determination", "score": 0.04065866023302078}, {"name": "Disappointment", "score": 0.05134189501404762}, {"name": "Disgust", "score": 0.027609722688794136}, {"name": "Distress", "score": 0.06621058285236359}, {"name": "Doubt", "score": 0.044190678745508194}, {"name": "Ecstasy", "score": 0.26069584488868713}, {"name": "Embarrassment", "score": 0.0635683685541153}, {"name": "Empathic Pain", "score": 0.03382478281855583}, {"name": "Entrancement", "score": 0.07183327525854111}, {"name": "Envy", "score": 0.018353179097175598}, {"name": "Excitement", "score": 0.5597581267356873}, {"name": "Fear", "score": 0.040145114064216614}, {"name": "Guilt", "score": 0.021526945754885674}, {"name": "Horror", "score": 0.02508113905787468}, {"name": "Interest", "score": 0.27689945697784424}, {"name": "Joy", "score": 0.8952057957649231}, {"name": "Love", "score": 0.42375367879867554}, {"name": "Nostalgia", "score": 0.06938042491674423}, {"name": "Pain", "score": 0.07562015950679779}, {"name": "Pride", "score": 0.15439681708812714}, {"name": "Realization", "score": 0.0845857784152031}, {"name": "Relief", "score": 0.15109769999980927}, {"name": "Romance", "score": 0.0684647411108017}, {"name": "Sadness", "score": 0.04426600784063339}, {"name": "Satisfaction", "score": 0.45255377888679504}, {"name": "Shame", "score": 0.024297092109918594}, {"name": "Surprise (negative)", "score": 0.019590219482779503}, {"name": "Surprise (positive)", "score": 0.03406026214361191}, {"name": "Sympathy", "score": 0.05253610014915466}, {"name": "Tiredness", "score": 0.051115233451128006}, {"name": "Triumph", "score": 0.15405380725860596}], "facs": null, "descriptions": null}]}]}}}], "errors": []}}]