Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -339,7 +339,29 @@ st.markdown(custom_css, unsafe_allow_html=True)
|
|
339 |
|
340 |
# Constants
|
341 |
AVATAR_WIDTH, AVATAR_HEIGHT = 600, 800
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
342 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
343 |
# Your Streamlit app code goes here
|
344 |
st.title("NeuraSense AI - Cyberpunk Edition")
|
345 |
|
@@ -490,21 +512,7 @@ def create_avatar():
|
|
490 |
draw.line([start, end], fill=(0, 255, 255, 50), width=1)
|
491 |
|
492 |
return img
|
493 |
-
|
494 |
-
# New function to create heatmap
|
495 |
-
def create_heatmap(sensation_map):
|
496 |
-
overall_sensitivity = np.mean(sensation_map, axis=2)
|
497 |
-
fig, ax = plt.subplots(figsize=(10, 15))
|
498 |
-
sns.heatmap(overall_sensitivity, cmap='YlOrRd', alpha=0.7, cbar=False, ax=ax)
|
499 |
-
ax.set_axis_off()
|
500 |
-
buf = BytesIO()
|
501 |
-
plt.savefig(buf, format='png', bbox_inches='tight', pad_inches=0)
|
502 |
-
buf.seek(0)
|
503 |
-
heatmap_img = Image.open(buf)
|
504 |
-
plt.close(fig)
|
505 |
-
return heatmap_img
|
506 |
-
|
507 |
-
|
508 |
def create_avatar_with_heatmap():
|
509 |
avatar_img = create_avatar()
|
510 |
heatmap_img = create_heatmap(avatar_sensation_map)
|
@@ -512,6 +520,9 @@ def create_avatar_with_heatmap():
|
|
512 |
combined_img = Image.alpha_composite(avatar_img.convert('RGBA'), heatmap_img.convert('RGBA'))
|
513 |
return combined_img
|
514 |
|
|
|
|
|
|
|
515 |
|
516 |
|
517 |
# Streamlit app
|
|
|
339 |
|
340 |
# Constants
|
341 |
AVATAR_WIDTH, AVATAR_HEIGHT = 600, 800
|
342 |
+
# Create heatmap function
|
343 |
+
def create_heatmap(sensation_map):
|
344 |
+
overall_sensitivity = np.mean(sensation_map, axis=2)
|
345 |
+
fig, ax = plt.subplots(figsize=(10, 15))
|
346 |
+
sns.heatmap(overall_sensitivity, cmap='YlOrRd', alpha=0.7, cbar=False, ax=ax)
|
347 |
+
ax.set_axis_off()
|
348 |
+
buf = BytesIO()
|
349 |
+
plt.savefig(buf, format='png', bbox_inches='tight', pad_inches=0)
|
350 |
+
buf.seek(0)
|
351 |
+
heatmap_img = Image.open(buf)
|
352 |
+
plt.close(fig)
|
353 |
+
return heatmap_img
|
354 |
|
355 |
+
# Create avatar with heatmap function
|
356 |
+
def create_avatar_with_heatmap():
|
357 |
+
avatar_img = create_avatar()
|
358 |
+
heatmap_img = create_heatmap(avatar_sensation_map)
|
359 |
+
heatmap_img = heatmap_img.resize((AVATAR_WIDTH, AVATAR_HEIGHT))
|
360 |
+
combined_img = Image.alpha_composite(avatar_img.convert('RGBA'), heatmap_img.convert('RGBA'))
|
361 |
+
return combined_img
|
362 |
+
|
363 |
+
# Create the avatar with heatmap
|
364 |
+
avatar_with_heatmap = create_avatar_with_heatmap()
|
365 |
# Your Streamlit app code goes here
|
366 |
st.title("NeuraSense AI - Cyberpunk Edition")
|
367 |
|
|
|
512 |
draw.line([start, end], fill=(0, 255, 255, 50), width=1)
|
513 |
|
514 |
return img
|
515 |
+
# Create avatar with heatmap function
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
516 |
def create_avatar_with_heatmap():
|
517 |
avatar_img = create_avatar()
|
518 |
heatmap_img = create_heatmap(avatar_sensation_map)
|
|
|
520 |
combined_img = Image.alpha_composite(avatar_img.convert('RGBA'), heatmap_img.convert('RGBA'))
|
521 |
return combined_img
|
522 |
|
523 |
+
# Create the avatar with heatmap
|
524 |
+
avatar_with_heatmap = create_avatar_with_heatmap()
|
525 |
+
|
526 |
|
527 |
|
528 |
# Streamlit app
|