Spaces:
Running
Running
File size: 3,597 Bytes
4ab551f 919660f 4ab551f 919660f 4ab551f |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 |
import shutil
import tempfile
from pathlib import Path
import streamlit as st
from sorawm.core import SoraWM
def main():
st.set_page_config(
page_title="Sora Watermark Cleaner", page_icon="🎬", layout="centered"
)
st.title("🎬 Sora Watermark Cleaner")
st.markdown("Remove watermarks from Sora-generated videos with ease")
# Initialize SoraWM
if "sora_wm" not in st.session_state:
with st.spinner("Loading AI models..."):
st.session_state.sora_wm = SoraWM()
st.markdown("---")
# File uploader
uploaded_file = st.file_uploader(
"Upload your video",
type=["mp4", "avi", "mov", "mkv"],
help="Select a video file to remove watermarks",
)
if uploaded_file is not None:
# Display video info
st.success(f"✅ Uploaded: {uploaded_file.name}")
st.video(uploaded_file)
# Process button
if st.button("🚀 Remove Watermark", type="primary", use_container_width=True):
with tempfile.TemporaryDirectory() as tmp_dir:
tmp_path = Path(tmp_dir)
# Save uploaded file
input_path = tmp_path / uploaded_file.name
with open(input_path, "wb") as f:
f.write(uploaded_file.read())
# Process video
output_path = tmp_path / f"cleaned_{uploaded_file.name}"
try:
# Create progress bar and status text
progress_bar = st.progress(0)
status_text = st.empty()
def update_progress(progress: int):
progress_bar.progress(progress / 100)
if progress < 50:
status_text.text(f"🔍 Detecting watermarks... {progress}%")
elif progress < 95:
status_text.text(f"🧹 Removing watermarks... {progress}%")
else:
status_text.text(f"🎵 Merging audio... {progress}%")
# Run the watermark removal with progress callback
st.session_state.sora_wm.run(
input_path, output_path, progress_callback=update_progress
)
# Complete the progress bar
progress_bar.progress(100)
status_text.text("✅ Processing complete!")
st.success("✅ Watermark removed successfully!")
# Display result
st.markdown("### Result")
st.video(str(output_path))
# Download button
with open(output_path, "rb") as f:
st.download_button(
label="⬇️ Download Cleaned Video",
data=f,
file_name=f"cleaned_{uploaded_file.name}",
mime="video/mp4",
use_container_width=True,
)
except Exception as e:
st.error(f"❌ Error processing video: {str(e)}")
# Footer
st.markdown("---")
st.markdown(
"""
<div style='text-align: center'>
<p>Built with ❤️ using Streamlit and AI</p>
<p><a href='https://github.com/linkedlist771/SoraWatermarkCleaner'>GitHub Repository</a></p>
</div>
""",
unsafe_allow_html=True,
)
if __name__ == "__main__":
main()
|