Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -459,19 +459,34 @@ def create_sensation_map(width, height, keypoints):
|
|
459 |
def create_heatmap(sensation_map, sensation_type):
|
460 |
plt.figure(figsize=(10, 15))
|
461 |
sns.heatmap(sensation_map[:, :, sensation_type], cmap='viridis')
|
462 |
-
plt.title(f'{["Pain", "Pleasure", "Pressure", "Temperature", "Texture", "EM Field", "Tickle", "Itch", "Quantum", "Neural", "Proprioception", "Synesthesia"][sensation_type]} Sensation Map')
|
463 |
-
plt.axis('off')
|
464 |
|
465 |
-
|
466 |
-
plt.
|
467 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
468 |
|
469 |
-
data = base64.b64encode(buf.getvalue()).decode('utf-8')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
470 |
|
471 |
-
|
|
|
|
|
|
|
|
|
472 |
|
473 |
-
return
|
474 |
-
f'data:image/png;base64,{data}'
|
475 |
|
476 |
# Streamlit app
|
477 |
st.title("NeuraSense AI - Humanoid Touch Point Detection")
|
@@ -505,22 +520,11 @@ if uploaded_file is not None:
|
|
505 |
|
506 |
# Generate AI response based on the image and sensations
|
507 |
if st.button("Generate AI Response"):
|
508 |
-
# You can customize this part to generate more specific responses based on the detected keypoints and sensations
|
509 |
response = generate_ai_response(keypoints, sensation_map)
|
510 |
st.write("AI Response:", response)
|
511 |
|
512 |
-
|
513 |
-
|
514 |
-
num_keypoints = len(keypoints)
|
515 |
-
avg_sensations = np.mean(sensation_map, axis=(0, 1))
|
516 |
-
|
517 |
-
response = f"I detect {num_keypoints} key points on the humanoid figure. "
|
518 |
-
response += "The average sensations across the body are:\n"
|
519 |
-
for i, sensation in enumerate(["Pain", "Pleasure", "Pressure", "Temperature", "Texture", "EM Field",
|
520 |
-
"Tickle", "Itch", "Quantum", "Neural", "Proprioception", "Synesthesia"]):
|
521 |
-
response += f"{sensation}: {avg_sensations[i]:.2f}\n"
|
522 |
-
|
523 |
-
return response
|
524 |
|
525 |
|
526 |
# Create futuristic human-like avatar
|
|
|
459 |
def create_heatmap(sensation_map, sensation_type):
|
460 |
plt.figure(figsize=(10, 15))
|
461 |
sns.heatmap(sensation_map[:, :, sensation_type], cmap='viridis')
|
|
|
|
|
462 |
|
463 |
+
def create_heatmap(sensation_map, sensation_type):
|
464 |
+
plt.figure(figsize=(10, 15))
|
465 |
+
sns.heatmap(sensation_map[:, :, sensation_type], cmap='viridis')
|
466 |
+
plt.title(f'{["Pain", "Pleasure", "Pressure", "Temperature", "Texture", "EM Field", "Tickle", "Itch", "Quantum", "Neural", "Proprioception", "Synesthesia"][sensation_type]} Sensation Map')
|
467 |
+
plt.axis('off')
|
468 |
+
|
469 |
+
buf = io.BytesIO()
|
470 |
+
plt.savefig(buf, format='png')
|
471 |
+
buf.seek(0)
|
472 |
|
473 |
+
data = base64.b64encode(buf.getvalue()).decode('utf-8')
|
474 |
+
|
475 |
+
plt.close()
|
476 |
+
|
477 |
+
return f'data:image/png;base64,{data}'
|
478 |
+
|
479 |
+
def generate_ai_response(keypoints, sensation_map):
|
480 |
+
num_keypoints = len(keypoints)
|
481 |
+
avg_sensations = np.mean(sensation_map, axis=(0, 1))
|
482 |
|
483 |
+
response = f"I detect {num_keypoints} key points on the humanoid figure. "
|
484 |
+
response += "The average sensations across the body are:\n"
|
485 |
+
for i, sensation in enumerate(["Pain", "Pleasure", "Pressure", "Temperature", "Texture", "EM Field",
|
486 |
+
"Tickle", "Itch", "Quantum", "Neural", "Proprioception", "Synesthesia"]):
|
487 |
+
response += f"{sensation}: {avg_sensations[i]:.2f}\n"
|
488 |
|
489 |
+
return response
|
|
|
490 |
|
491 |
# Streamlit app
|
492 |
st.title("NeuraSense AI - Humanoid Touch Point Detection")
|
|
|
520 |
|
521 |
# Generate AI response based on the image and sensations
|
522 |
if st.button("Generate AI Response"):
|
|
|
523 |
response = generate_ai_response(keypoints, sensation_map)
|
524 |
st.write("AI Response:", response)
|
525 |
|
526 |
+
|
527 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
528 |
|
529 |
|
530 |
# Create futuristic human-like avatar
|