sparshmehta commited on
Commit
e36dab5
·
verified ·
1 Parent(s): 671b31d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +111 -30
app.py CHANGED
@@ -1556,7 +1556,6 @@ def main():
1556
  box-shadow: 0 10px 20px rgba(0,0,0,0.1);
1557
  margin: 1rem 0;
1558
  animation: fadeIn 0.5s ease-out;
1559
- transition: transform 0.3s ease;
1560
  }
1561
 
1562
  .card:hover {
@@ -1674,6 +1673,43 @@ def main():
1674
  <strong>Maximum file size:</strong> 500MB</p>
1675
  </div>
1676
  """, unsafe_allow_html=True)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1677
 
1678
  if uploaded_file:
1679
  # Add a modern processing animation
@@ -1683,35 +1719,80 @@ def main():
1683
  <p>Please wait while we analyze your teaching demo...</p>
1684
  </div>
1685
  """, unsafe_allow_html=True)
1686
-
1687
- # Display results using stored evaluation
1688
- st.markdown("""
1689
- <div class="status-complete">
1690
- <h3>✅ Analysis Complete!</h3>
1691
- <p>Review your detailed evaluation below</p>
1692
- </div>
1693
- """, unsafe_allow_html=True)
1694
-
1695
- # Wrap the evaluation display in a card
1696
- st.markdown('<div class="card">', unsafe_allow_html=True)
1697
- display_evaluation(st.session_state.evaluation_results)
1698
- st.markdown('</div>', unsafe_allow_html=True)
1699
-
1700
- # Modern download button
1701
- st.markdown("""
1702
- <div class="card" style="text-align: center;">
1703
- <h3 style='color: #2c3e50;'>📥 Download Your Report</h3>
1704
- </div>
1705
- """, unsafe_allow_html=True)
1706
-
1707
- if st.download_button(
1708
- "Download Full Report",
1709
- json.dumps(st.session_state.evaluation_results, indent=2),
1710
- "evaluation_report.json",
1711
- "application/json",
1712
- help="Download the complete evaluation report in JSON format"
1713
- ):
1714
- st.success("Report downloaded successfully!")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1715
 
1716
  except Exception as e:
1717
  st.error(f"Application error: {str(e)}")
 
1556
  box-shadow: 0 10px 20px rgba(0,0,0,0.1);
1557
  margin: 1rem 0;
1558
  animation: fadeIn 0.5s ease-out;
 
1559
  }
1560
 
1561
  .card:hover {
 
1673
  <strong>Maximum file size:</strong> 500MB</p>
1674
  </div>
1675
  """, unsafe_allow_html=True)
1676
+
1677
+ # Check dependencies with progress
1678
+ with st.status("Checking system requirements...") as status:
1679
+ progress_bar = st.progress(0)
1680
+
1681
+ status.update(label="Checking FFmpeg installation...")
1682
+ progress_bar.progress(0.3)
1683
+ missing_deps = check_dependencies()
1684
+
1685
+ progress_bar.progress(0.6)
1686
+ if missing_deps:
1687
+ status.update(label="Missing dependencies detected!", state="error")
1688
+ st.error(f"Missing required dependencies: {', '.join(missing_deps)}")
1689
+ st.markdown("""
1690
+ Please install the missing dependencies:
1691
+ ```bash
1692
+ sudo apt-get update
1693
+ sudo apt-get install ffmpeg
1694
+ ```
1695
+ """)
1696
+ return
1697
+
1698
+ progress_bar.progress(1.0)
1699
+ status.update(label="System requirements satisfied!", state="complete")
1700
+
1701
+ # File uploader with modern styling
1702
+ st.markdown("""
1703
+ <div class="card">
1704
+ <h3 style='color: #2c3e50; text-align: center;'>📤 Upload Your Teaching Video</h3>
1705
+ </div>
1706
+ """, unsafe_allow_html=True)
1707
+
1708
+ uploaded_file = st.file_uploader(
1709
+ "Choose a video file",
1710
+ type=['mp4', 'avi', 'mov'],
1711
+ help="Upload your teaching video in MP4, AVI, or MOV format"
1712
+ )
1713
 
1714
  if uploaded_file:
1715
  # Add a modern processing animation
 
1719
  <p>Please wait while we analyze your teaching demo...</p>
1720
  </div>
1721
  """, unsafe_allow_html=True)
1722
+
1723
+ # Create temp directory for processing
1724
+ temp_dir = tempfile.mkdtemp()
1725
+ video_path = os.path.join(temp_dir, uploaded_file.name)
1726
+
1727
+ try:
1728
+ # Save uploaded file with progress
1729
+ with st.status("Saving uploaded file...") as status:
1730
+ progress_bar = st.progress(0)
1731
+
1732
+ # Save in chunks to show progress
1733
+ chunk_size = 1024 * 1024 # 1MB chunks
1734
+ file_size = len(uploaded_file.getbuffer())
1735
+ chunks = file_size // chunk_size + 1
1736
+
1737
+ with open(video_path, 'wb') as f:
1738
+ for i in range(chunks):
1739
+ start = i * chunk_size
1740
+ end = min(start + chunk_size, file_size)
1741
+ f.write(uploaded_file.getbuffer()[start:end])
1742
+ progress = (i + 1) / chunks
1743
+ status.update(label=f"Saving file: {progress:.1%}")
1744
+ progress_bar.progress(progress)
1745
+
1746
+ status.update(label="File saved successfully!", state="complete")
1747
+
1748
+ # Validate file size
1749
+ file_size = os.path.getsize(video_path) / (1024 * 1024) # Size in MB
1750
+ if file_size > 500: # 500MB limit
1751
+ st.error("File size exceeds 500MB limit. Please upload a smaller file.")
1752
+ return
1753
+
1754
+ # Process video and store results
1755
+ if 'evaluation_results' not in st.session_state:
1756
+ with st.spinner("Processing video"):
1757
+ evaluator = MentorEvaluator()
1758
+ st.session_state.evaluation_results = evaluator.evaluate_video(video_path)
1759
+
1760
+ # Display completion status
1761
+ st.markdown("""
1762
+ <div class="status-complete">
1763
+ <h3>✅ Analysis Complete!</h3>
1764
+ <p>Review your detailed evaluation below</p>
1765
+ </div>
1766
+ """, unsafe_allow_html=True)
1767
+
1768
+ # Display evaluation in a card
1769
+ st.markdown('<div class="card">', unsafe_allow_html=True)
1770
+ display_evaluation(st.session_state.evaluation_results)
1771
+ st.markdown('</div>', unsafe_allow_html=True)
1772
+
1773
+ # Download section
1774
+ st.markdown("""
1775
+ <div class="card" style="text-align: center;">
1776
+ <h3 style='color: #2c3e50;'>📥 Download Your Report</h3>
1777
+ </div>
1778
+ """, unsafe_allow_html=True)
1779
+
1780
+ if st.download_button(
1781
+ "Download Full Report",
1782
+ json.dumps(st.session_state.evaluation_results, indent=2),
1783
+ "evaluation_report.json",
1784
+ "application/json",
1785
+ help="Download the complete evaluation report in JSON format"
1786
+ ):
1787
+ st.success("Report downloaded successfully!")
1788
+
1789
+ except Exception as e:
1790
+ st.error(f"Error during evaluation: {str(e)}")
1791
+
1792
+ finally:
1793
+ # Clean up temp files
1794
+ if 'temp_dir' in locals():
1795
+ shutil.rmtree(temp_dir)
1796
 
1797
  except Exception as e:
1798
  st.error(f"Application error: {str(e)}")