Sephfox commited on
Commit
6a06b12
1 Parent(s): 5e09290

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -6
app.py CHANGED
@@ -578,13 +578,16 @@ def create_avatar():
578
 
579
  return img
580
 
581
- # Adjust alpha channel of heatmap
582
- data = np.array(heatmap_img)
583
- data[:, :, 3] = data[:, :, 3] * 0.5 # Reduce opacity to 50%
584
- heatmap_img = Image.fromarray(data)
 
 
585
 
586
- combined_img = Image.alpha_composite(avatar_img.convert('RGBA'), heatmap_img)
587
- return combined_img
 
588
 
589
  # Create and display avatar with heatmap
590
  st.subheader("Avatar with Sensation Heatmap")
 
578
 
579
  return img
580
 
581
+ # Adjust alpha channel of heatmap
582
+ data = np.array(heatmap_img)
583
+ if data.shape[2] == 3: # If RGB, add an alpha channel
584
+ data = np.concatenate([data, np.full((data.shape[0], data.shape[1], 1), 255, dtype=np.uint8)], axis=2)
585
+ data[:, :, 3] = data[:, :, 3] * 0.5 # Reduce opacity to 50%
586
+ heatmap_img = Image.fromarray(data)
587
 
588
+ combined_img = Image.alpha_composite(avatar_img.convert('RGBA'), heatmap_img)
589
+ return combined_img
590
+
591
 
592
  # Create and display avatar with heatmap
593
  st.subheader("Avatar with Sensation Heatmap")