Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -495,6 +495,8 @@ def generate_ai_response(keypoints, sensation_map):
|
|
| 495 |
|
| 496 |
uploaded_file = st.file_uploader("Choose an image...", type=["jpg", "jpeg", "png"])
|
| 497 |
|
|
|
|
|
|
|
| 498 |
if uploaded_file is not None:
|
| 499 |
# Read the image
|
| 500 |
image_path = 'temp.jpg'
|
|
@@ -507,14 +509,43 @@ if uploaded_file is not None:
|
|
| 507 |
# Apply touch points to the image
|
| 508 |
processed_image = apply_touch_points(image_path, keypoints)
|
| 509 |
|
| 510 |
-
# Display the processed image
|
| 511 |
-
st.image(processed_image, caption='Processed Image with Touch Points', use_column_width=True)
|
| 512 |
-
|
| 513 |
# Create sensation map
|
| 514 |
image = cv2.imread(image_path)
|
| 515 |
image_height, image_width, _ = image.shape
|
| 516 |
sensation_map = create_sensation_map(image_width, image_height, keypoints)
|
| 517 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 518 |
# Display heatmaps for different sensations
|
| 519 |
sensation_types = ["Pain", "Pleasure", "Pressure", "Temperature", "Texture", "EM Field",
|
| 520 |
"Tickle", "Itch", "Quantum", "Neural", "Proprioception", "Synesthesia"]
|
|
|
|
| 495 |
|
| 496 |
uploaded_file = st.file_uploader("Choose an image...", type=["jpg", "jpeg", "png"])
|
| 497 |
|
| 498 |
+
# ... (rest of your code)
|
| 499 |
+
|
| 500 |
if uploaded_file is not None:
|
| 501 |
# Read the image
|
| 502 |
image_path = 'temp.jpg'
|
|
|
|
| 509 |
# Apply touch points to the image
|
| 510 |
processed_image = apply_touch_points(image_path, keypoints)
|
| 511 |
|
|
|
|
|
|
|
|
|
|
| 512 |
# Create sensation map
|
| 513 |
image = cv2.imread(image_path)
|
| 514 |
image_height, image_width, _ = image.shape
|
| 515 |
sensation_map = create_sensation_map(image_width, image_height, keypoints)
|
| 516 |
|
| 517 |
+
# Display the processed image
|
| 518 |
+
fig, ax = plt.subplots()
|
| 519 |
+
ax.imshow(processed_image)
|
| 520 |
+
|
| 521 |
+
# Create a list to store the clicked points
|
| 522 |
+
clicked_points = []
|
| 523 |
+
|
| 524 |
+
def onclick(event):
|
| 525 |
+
if event.xdata is not None and event.ydata is not None:
|
| 526 |
+
clicked_points.append((int(event.xdata), int(event.ydata)))
|
| 527 |
+
st.write(f"Clicked point: ({int(event.xdata)}, {int(event.ydata)})")
|
| 528 |
+
|
| 529 |
+
# Update sensation values based on the clicked point
|
| 530 |
+
sensation = sensation_map[int(event.ydata), int(event.xdata)]
|
| 531 |
+
(
|
| 532 |
+
pain, pleasure, pressure_sens, temp_sens, texture_sens,
|
| 533 |
+
em_sens, tickle_sens, itch_sens, quantum_sens, neural_sens,
|
| 534 |
+
proprioception_sens, synesthesia_sens
|
| 535 |
+
) = sensation
|
| 536 |
+
|
| 537 |
+
st.write("### Sensory Data Analysis")
|
| 538 |
+
st.write(f"Interaction Point: ({int(event.xdata):.1f}, {int(event.ydata):.1f})")
|
| 539 |
+
st.write(f"Pain: {pain:.2f} | Pleasure: {pleasure:.2f} | Pressure: {pressure_sens:.2f}")
|
| 540 |
+
st.write(f"Temperature: {temp_sens:.2f} | Texture: {texture_sens:.2f} | EM Field: {em_sens:.2f}")
|
| 541 |
+
st.write(f"Tickle: {tickle_sens:.2f} | Itch: {itch_sens:.2f} | Quantum: {quantum_sens:.2f}")
|
| 542 |
+
st.write(f"Neural: {neural_sens:.2f} | Proprioception: {proprioception_sens:.2f} | Synesthesia: {synesthesia_sens:.2f}")
|
| 543 |
+
|
| 544 |
+
fig.canvas.mpl_connect('button_press_event', onclick)
|
| 545 |
+
|
| 546 |
+
# Display the plot
|
| 547 |
+
st.pyplot(fig)
|
| 548 |
+
|
| 549 |
# Display heatmaps for different sensations
|
| 550 |
sensation_types = ["Pain", "Pleasure", "Pressure", "Temperature", "Texture", "EM Field",
|
| 551 |
"Tickle", "Itch", "Quantum", "Neural", "Proprioception", "Synesthesia"]
|