Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -564,6 +564,7 @@ if uploaded_file is not None:
|
|
564 |
|
565 |
if st.button("Simulate Interaction"):
|
566 |
if clicked_points:
|
|
|
567 |
touch_x, touch_y = clicked_points[-1]
|
568 |
|
569 |
# Retrieve the sensation values at the clicked location
|
@@ -588,11 +589,11 @@ if uploaded_file is not None:
|
|
588 |
|
589 |
# Calculate overall sensations with interaction modifiers
|
590 |
pain_level = pain * measured_pressure * touch_pressure
|
591 |
-
pleasure_level = pleasure * (measured_temp - 37) / 10
|
592 |
-
tickle_level = tickle_sens * (1 - np.exp(-touch_duration / 0.5))
|
593 |
-
itch_level = itch_sens * (1 - np.exp(-touch_duration / 1.5))
|
594 |
|
595 |
-
# Proprioception (sense of body position)
|
596 |
proprioception = proprioception_sens * np.linalg.norm([touch_x - image_width / 2, touch_y - image_height / 2]) / (image_width / 2)
|
597 |
|
598 |
# Synesthesia (mixing of senses) handling based on user selection
|
@@ -614,7 +615,7 @@ if uploaded_file is not None:
|
|
614 |
if show_heatmap:
|
615 |
heatmap = create_heatmap(sensation_map, sensation_types.index("Pain")) # Example for "Pain"
|
616 |
st.image(heatmap, use_column_width=True)
|
617 |
-
|
618 |
# Optionally, calculate and display the average pressure value in the image
|
619 |
average_pressure = np.mean(sensation_map[:, :, 2]) # Pressure channel
|
620 |
st.write(f"Average Pressure across the image: {average_pressure:.2f}")
|
|
|
564 |
|
565 |
if st.button("Simulate Interaction"):
|
566 |
if clicked_points:
|
567 |
+
# Ensure valid clicked points exist before accessing them
|
568 |
touch_x, touch_y = clicked_points[-1]
|
569 |
|
570 |
# Retrieve the sensation values at the clicked location
|
|
|
589 |
|
590 |
# Calculate overall sensations with interaction modifiers
|
591 |
pain_level = pain * measured_pressure * touch_pressure
|
592 |
+
pleasure_level = pleasure * (measured_temp - 37) / 10 # Adjusted for average body temp
|
593 |
+
tickle_level = tickle_sens * (1 - np.exp(-touch_duration / 0.5)) # Exponential decay
|
594 |
+
itch_level = itch_sens * (1 - np.exp(-touch_duration / 1.5)) # Exponential decay
|
595 |
|
596 |
+
# Proprioception (sense of body position) based on distance from the center
|
597 |
proprioception = proprioception_sens * np.linalg.norm([touch_x - image_width / 2, touch_y - image_height / 2]) / (image_width / 2)
|
598 |
|
599 |
# Synesthesia (mixing of senses) handling based on user selection
|
|
|
615 |
if show_heatmap:
|
616 |
heatmap = create_heatmap(sensation_map, sensation_types.index("Pain")) # Example for "Pain"
|
617 |
st.image(heatmap, use_column_width=True)
|
618 |
+
|
619 |
# Optionally, calculate and display the average pressure value in the image
|
620 |
average_pressure = np.mean(sensation_map[:, :, 2]) # Pressure channel
|
621 |
st.write(f"Average Pressure across the image: {average_pressure:.2f}")
|