Upload app.py
Browse files
app.py
CHANGED
|
@@ -89,12 +89,20 @@ try:
|
|
| 89 |
'good': 5, 'bad': 6, 'yes': 7, 'no': 8, 'water': 9,
|
| 90 |
'food': 10, 'home': 11, 'work': 12, 'school': 13, 'family': 14
|
| 91 |
}
|
|
|
|
| 92 |
|
| 93 |
st.success("β
Core dependencies loaded successfully!")
|
| 94 |
except ImportError as e:
|
| 95 |
st.error(f"β Critical import error: {e}")
|
| 96 |
st.error("Running in fallback mode with limited functionality.")
|
| 97 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 98 |
# System information will be shown in About section
|
| 99 |
|
| 100 |
|
|
@@ -727,28 +735,34 @@ elif app_mode == 'Test Video Translation':
|
|
| 727 |
|
| 728 |
if len(frame_buffer) < window_size:
|
| 729 |
# Initial frames - build up buffer
|
| 730 |
-
|
| 731 |
-
|
| 732 |
-
|
| 733 |
-
|
| 734 |
-
|
| 735 |
-
|
| 736 |
-
|
|
|
|
|
|
|
|
|
|
| 737 |
|
| 738 |
# Add prediction plots
|
| 739 |
-
|
| 740 |
-
|
| 741 |
-
|
| 742 |
-
|
| 743 |
-
|
| 744 |
-
|
| 745 |
-
canvas_with_predictions
|
| 746 |
-
|
| 747 |
-
|
| 748 |
-
|
| 749 |
-
|
| 750 |
-
canvas_with_predictions
|
| 751 |
-
|
|
|
|
|
|
|
|
|
|
| 752 |
|
| 753 |
# Initialize video writer
|
| 754 |
if video_writer is None:
|
|
@@ -821,28 +835,34 @@ elif app_mode == 'Test Video Translation':
|
|
| 821 |
)
|
| 822 |
|
| 823 |
# Create visualization
|
| 824 |
-
|
| 825 |
-
|
| 826 |
-
|
| 827 |
-
|
| 828 |
-
|
| 829 |
-
|
| 830 |
-
|
|
|
|
|
|
|
|
|
|
| 831 |
|
| 832 |
# Add prediction visualizations
|
| 833 |
-
|
| 834 |
-
|
| 835 |
-
|
| 836 |
-
|
| 837 |
-
|
| 838 |
-
|
| 839 |
-
canvas_with_predictions
|
| 840 |
-
|
| 841 |
-
|
| 842 |
-
|
| 843 |
-
|
| 844 |
-
canvas_with_predictions
|
| 845 |
-
|
|
|
|
|
|
|
|
|
|
| 846 |
|
| 847 |
video_writer.write_frame(canvas_with_predictions)
|
| 848 |
|
|
|
|
| 89 |
'good': 5, 'bad': 6, 'yes': 7, 'no': 8, 'water': 9,
|
| 90 |
'food': 10, 'home': 11, 'work': 12, 'school': 13, 'family': 14
|
| 91 |
}
|
| 92 |
+
utils = None # Set utils to None if import fails
|
| 93 |
|
| 94 |
st.success("β
Core dependencies loaded successfully!")
|
| 95 |
except ImportError as e:
|
| 96 |
st.error(f"β Critical import error: {e}")
|
| 97 |
st.error("Running in fallback mode with limited functionality.")
|
| 98 |
|
| 99 |
+
# Import pose_utils separately to ensure it's always available
|
| 100 |
+
try:
|
| 101 |
+
import pose_utils as utils
|
| 102 |
+
except ImportError as utils_error:
|
| 103 |
+
st.error(f"β Failed to import pose_utils: {utils_error}")
|
| 104 |
+
utils = None
|
| 105 |
+
|
| 106 |
# System information will be shown in About section
|
| 107 |
|
| 108 |
|
|
|
|
| 735 |
|
| 736 |
if len(frame_buffer) < window_size:
|
| 737 |
# Initial frames - build up buffer
|
| 738 |
+
if utils is not None:
|
| 739 |
+
visualization_canvas = utils.render_stick_model(
|
| 740 |
+
frame,
|
| 741 |
+
eval(frame_data['bodypose_circles']),
|
| 742 |
+
eval(frame_data['bodypose_sticks']),
|
| 743 |
+
eval(frame_data['handpose_edges']),
|
| 744 |
+
eval(frame_data['handpose_peaks'])
|
| 745 |
+
)
|
| 746 |
+
else:
|
| 747 |
+
visualization_canvas = frame # Use original frame if utils not available
|
| 748 |
|
| 749 |
# Add prediction plots
|
| 750 |
+
if utils is not None:
|
| 751 |
+
canvas_with_predictions = utils.create_bar_plot_visualization(
|
| 752 |
+
visualization_canvas, {},
|
| 753 |
+
f'Building Buffer - Frame {frame_idx + 1} [No Predictions Yet]',
|
| 754 |
+
visualization_canvas
|
| 755 |
+
)
|
| 756 |
+
canvas_with_predictions = utils.create_bar_plot_visualization(
|
| 757 |
+
canvas_with_predictions, weighted_predictions,
|
| 758 |
+
f'Weighted Average - Frame {frame_idx + 1} [No Predictions Yet]',
|
| 759 |
+
visualization_canvas
|
| 760 |
+
)
|
| 761 |
+
canvas_with_predictions = utils.add_bottom_padding(
|
| 762 |
+
canvas_with_predictions, (255, 255, 255), 100
|
| 763 |
+
)
|
| 764 |
+
else:
|
| 765 |
+
canvas_with_predictions = visualization_canvas # Use base canvas if utils not available
|
| 766 |
|
| 767 |
# Initialize video writer
|
| 768 |
if video_writer is None:
|
|
|
|
| 835 |
)
|
| 836 |
|
| 837 |
# Create visualization
|
| 838 |
+
if utils is not None:
|
| 839 |
+
visualization_canvas = utils.render_stick_model(
|
| 840 |
+
frame,
|
| 841 |
+
eval(frame_data['bodypose_circles']),
|
| 842 |
+
eval(frame_data['bodypose_sticks']),
|
| 843 |
+
eval(frame_data['handpose_edges']),
|
| 844 |
+
eval(frame_data['handpose_peaks'])
|
| 845 |
+
)
|
| 846 |
+
else:
|
| 847 |
+
visualization_canvas = frame # Use original frame if utils not available
|
| 848 |
|
| 849 |
# Add prediction visualizations
|
| 850 |
+
if utils is not None:
|
| 851 |
+
canvas_with_predictions = utils.create_bar_plot_visualization(
|
| 852 |
+
visualization_canvas, current_predictions,
|
| 853 |
+
f'Current Window Prediction (Frames {sequence_idx + 1}-{frame_idx + 1})',
|
| 854 |
+
visualization_canvas
|
| 855 |
+
)
|
| 856 |
+
canvas_with_predictions = utils.create_bar_plot_visualization(
|
| 857 |
+
canvas_with_predictions, weighted_predictions,
|
| 858 |
+
f'Cumulative Weighted Average - Frame {frame_idx + 1}',
|
| 859 |
+
visualization_canvas
|
| 860 |
+
)
|
| 861 |
+
canvas_with_predictions = utils.add_bottom_padding(
|
| 862 |
+
canvas_with_predictions, (255, 255, 255), 100
|
| 863 |
+
)
|
| 864 |
+
else:
|
| 865 |
+
canvas_with_predictions = visualization_canvas # Use base canvas if utils not available
|
| 866 |
|
| 867 |
video_writer.write_frame(canvas_with_predictions)
|
| 868 |
|