Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -444,6 +444,8 @@ model = SimpleCNN()
|
|
| 444 |
# keypoints = test_actual_plot # Replace with your 33 key points
|
| 445 |
# plot_human_pose(keypoints)
|
| 446 |
|
|
|
|
|
|
|
| 447 |
def plot_human_pose(keypoints):
|
| 448 |
# Create a figure and axis
|
| 449 |
fig, ax = plt.subplots()
|
|
@@ -477,7 +479,15 @@ def plot_human_pose(keypoints):
|
|
| 477 |
ax.set_aspect('equal', adjustable='datalim')
|
| 478 |
plt.title('Predicted Pose')
|
| 479 |
plt.axis('off')
|
| 480 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 481 |
|
| 482 |
# Example usage:
|
| 483 |
# keypoints = test_predict_plot.detach().numpy() # Replace with your 33 key points
|
|
@@ -512,7 +522,7 @@ def predict_pose(image):
|
|
| 512 |
|
| 513 |
# predict_pose(test_image)
|
| 514 |
|
| 515 |
-
pose_detector = gr.Interface(
|
| 516 |
|
| 517 |
pose_detector.launch()
|
| 518 |
|
|
|
|
| 444 |
# keypoints = test_actual_plot # Replace with your 33 key points
|
| 445 |
# plot_human_pose(keypoints)
|
| 446 |
|
| 447 |
+
from io import BytesIO
|
| 448 |
+
|
| 449 |
def plot_human_pose(keypoints):
|
| 450 |
# Create a figure and axis
|
| 451 |
fig, ax = plt.subplots()
|
|
|
|
| 479 |
ax.set_aspect('equal', adjustable='datalim')
|
| 480 |
plt.title('Predicted Pose')
|
| 481 |
plt.axis('off')
|
| 482 |
+
|
| 483 |
+
buffer = BytesIO()
|
| 484 |
+
plt.savefig(buffer, format="png")
|
| 485 |
+
buffer.seek(0) # Reset the buffer position to the beginning
|
| 486 |
+
|
| 487 |
+
# Close the plot to release resources
|
| 488 |
+
plt.close()
|
| 489 |
+
|
| 490 |
+
return buffer
|
| 491 |
|
| 492 |
# Example usage:
|
| 493 |
# keypoints = test_predict_plot.detach().numpy() # Replace with your 33 key points
|
|
|
|
| 522 |
|
| 523 |
# predict_pose(test_image)
|
| 524 |
|
| 525 |
+
pose_detector = gr.Interface(predict_pose, gr.Image(type = 'pil') , "image")
|
| 526 |
|
| 527 |
pose_detector.launch()
|
| 528 |
|