Sephfox commited on
Commit
95b1167
·
verified ·
1 Parent(s): 1b009d6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +51 -49
app.py CHANGED
@@ -495,8 +495,6 @@ def generate_ai_response(keypoints, sensation_map):
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'
@@ -558,8 +556,7 @@ if uploaded_file is not None:
558
  if st.button("Generate AI Response"):
559
  response = generate_ai_response(keypoints, sensation_map)
560
  st.write("AI Response:", response)
561
-
562
-
563
  # Touch controls and output
564
  st.subheader("Neural Interface Controls")
565
 
@@ -574,54 +571,59 @@ if uploaded_file is not None:
574
 
575
  # Toggle synesthesia
576
  use_synesthesia = st.checkbox("Enable Synesthesia", value=False)
 
577
  # Add this with your other UI elements
578
  show_heatmap = st.checkbox("Show Sensation Heatmap", value=True)
579
 
580
- if canvas_result.json_data is not None:
581
- objects = canvas_result.json_data["objects"]
582
- if len(objects) > 0:
583
- last_touch = objects[-1]
584
- touch_x, touch_y = last_touch["left"], last_touch["top"]
585
-
586
- sensation = avatar_sensation_map[int(touch_y), int(touch_x)]
587
- (
588
- pain, pleasure, pressure_sens, temp_sens, texture_sens,
589
- em_sens, tickle_sens, itch_sens, quantum_sens, neural_sens,
590
- proprioception_sens, synesthesia_sens
591
- ) = sensation
592
-
593
- measured_pressure = QuantumSensor.measure(touch_x, touch_y, pressure_sens) * touch_pressure
594
- measured_temp = NanoThermalSensor.measure(37, touch_pressure, touch_duration)
595
- measured_texture = AdaptiveTextureSensor.measure(touch_x, touch_y)
596
- measured_em = EMFieldSensor.measure(touch_x, touch_y, em_sens)
597
-
598
- if use_quantum:
599
- quantum_state = QuantumSensor.measure(touch_x, touch_y, quantum_sens)
600
- else:
601
- quantum_state = "N/A"
602
-
603
- # Calculate overall sensations
604
- pain_level = pain * measured_pressure * touch_pressure
605
- pleasure_level = pleasure * (measured_temp - 37) / 10
606
- tickle_level = tickle_sens * (1 - np.exp(-touch_duration / 0.5))
607
- itch_level = itch_sens * (1 - np.exp(-touch_duration / 1.5))
608
-
609
- # Proprioception (sense of body position)
610
- proprioception = proprioception_sens * np.linalg.norm([touch_x - AVATAR_WIDTH/2, touch_y - AVATAR_HEIGHT/2]) / (AVATAR_WIDTH/2)
611
-
612
- # Synesthesia (mixing of senses)
613
- if use_synesthesia:
614
- synesthesia = synesthesia_sens * (measured_pressure + measured_temp + measured_em) / 3
615
- else:
616
- synesthesia = "N/A"
617
-
618
- # Neural network simulation
619
- neural_inputs = [pain_level, pleasure_level, measured_pressure, measured_temp, measured_em, tickle_level, itch_level, proprioception]
620
- neural_response = NeuralNetworkSimulator.process(neural_inputs)
621
-
622
- st.write("### Sensory Data Analysis")
623
- st.write(f"Interaction Point: ({touch_x:.1f}, {touch_y:.1f})")
624
- st.write(f"Duration: {touch_duration:.1f} s | Intensity: {touch_pressure:.2f}")
 
 
 
 
625
 
626
  # Create a futuristic data display
627
  data_display = (
 
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'
 
556
  if st.button("Generate AI Response"):
557
  response = generate_ai_response(keypoints, sensation_map)
558
  st.write("AI Response:", response)
559
+
 
560
  # Touch controls and output
561
  st.subheader("Neural Interface Controls")
562
 
 
571
 
572
  # Toggle synesthesia
573
  use_synesthesia = st.checkbox("Enable Synesthesia", value=False)
574
+
575
  # Add this with your other UI elements
576
  show_heatmap = st.checkbox("Show Sensation Heatmap", value=True)
577
 
578
+ if st.button("Simulate Interaction"):
579
+ # Simulate interaction at the clicked point
580
+ if clicked_points:
581
+ touch_x, touch_y = clicked_points[-1]
582
+
583
+ sensation = sensation_map[touch_y, touch_x]
584
+ (
585
+ pain, pleasure, pressure_sens, temp_sens, texture_sens,
586
+ em_sens, tickle_sens, itch_sens, quantum_sens, neural_sens,
587
+ proprioception_sens, synesthesia_sens
588
+ ) = sensation
589
+
590
+ measured_pressure = pressure_sens * touch_pressure
591
+ measured_temp = temp_sens # Assuming temperature doesn't change
592
+ measured_texture = texture_sens # Assuming texture doesn't change
593
+ measured_em = em_sens # Assuming EM field doesn't change
594
+
595
+ if use_quantum:
596
+ quantum_state = quantum_sens
597
+ else:
598
+ quantum_state = "N/A"
599
+
600
+ # Calculate overall sensations
601
+ pain_level = pain * measured_pressure * touch_pressure
602
+ pleasure_level = pleasure * (measured_temp - 37) / 10
603
+ tickle_level = tickle_sens * (1 - np.exp(-touch_duration / 0.5))
604
+ itch_level = itch_sens * (1 - np.exp(-touch_duration / 1.5))
605
+
606
+ # Proprioception (sense of body position)
607
+ proprioception = proprioception_sens * np.linalg.norm([touch_x - image_width/2, touch_y - image_height/2]) / (image_width/2)
608
+
609
+ # Synesthesia (mixing of senses)
610
+ if use_synesthesia:
611
+ synesthesia = synesthesia_sens * (measured_pressure + measured_temp + measured_em) / 3
612
+ else:
613
+ synesthesia = "N/A"
614
+
615
+ st.write("### Simulated Interaction Results")
616
+ st.write(f"Interaction Point: ({touch_x:.1f}, {touch_y:.1f})")
617
+ st.write(f"Duration: {touch_duration:.1f} s | Intensity: {touch_pressure:.2f}")
618
+ st.write(f"Pain: {pain_level:.2f} | Pleasure: {pleasure_level:.2f} | Pressure: {measured_pressure:.2f}")
619
+ st.write(f"Temperature: {measured_temp:.2f} | Texture: {measured_texture:.2f} | EM Field: {measured_em:.2f}")
620
+ st.write(f"Tickle: {tickle_level:.2f} | Itch: {itch_level:.2f} | Quantum: {quantum_state}")
621
+ st.write(f"Neural: {neural_sens:.2f} | Proprioception: {proprioception:.2f} | Synesthesia: {synesthesia}")
622
+
623
+ # Display a heatmap of the sensations
624
+ if show_heatmap:
625
+ heatmap = create_heatmap(sensation_map, sensation_types.index("Pain"))
626
+ st.image(heatmap, use_column_width=True)
627
 
628
  # Create a futuristic data display
629
  data_display = (