NeeravS commited on
Commit
f4cafbc
·
verified ·
1 Parent(s): 3c79350

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +39 -16
app.py CHANGED
@@ -15,29 +15,52 @@ if not os.path.exists(local_dir):
15
  st.write("Cloning the repository...")
16
  Repo.clone_from(repo_url, local_dir)
17
  st.success("Repository cloned successfully!")
 
 
 
18
  except Exception as e:
19
  st.error(f"Error cloning repository: {e}")
20
 
21
- # Add the repo directory to the system path
22
- sys.path.insert(0, local_dir)
23
-
24
- # Import the necessary module from the cloned repository
25
  try:
26
- from your_video_processing_module import process_video # Replace with your actual module name
27
- except ImportError as e:
28
- st.error(f"Error importing module: {e}")
29
- st.stop() # Stop the app if the module cannot be imported
 
 
 
 
 
 
 
 
 
 
30
 
31
  # Video Summarization Interface
32
  st.title("AI Based Video Summary Tool")
33
 
 
 
34
 
35
- uploaded_video = st.file_uploader("Upload a video", type=["mp4", "avi", "mov"])
36
-
37
- if uploaded_video is not None:
38
- st.video(uploaded_video)
39
 
40
- # Process the uploaded video
41
- summary = process_video(uploaded_video)
42
- st.write("Video Summary:")
43
- st.write(summary)
 
 
 
 
 
 
 
 
 
 
 
 
15
  st.write("Cloning the repository...")
16
  Repo.clone_from(repo_url, local_dir)
17
  st.success("Repository cloned successfully!")
18
+
19
+ # Add the repo directory to the system path
20
+ sys.path.insert(0, local_dir)
21
  except Exception as e:
22
  st.error(f"Error cloning repository: {e}")
23
 
24
+ # Dynamically import the functions after cloning
 
 
 
25
  try:
26
+ import importlib.util
27
+ spec = importlib.util.spec_from_file_location("module.name", os.path.join(local_dir, "app.py"))
28
+ module = importlib.util.module_from_spec(spec)
29
+ spec.loader.exec_module(module)
30
+
31
+ # Now, functions from the cloned repo's app.py can be used
32
+ extract_frames_and_describe = module.extract_frames_and_describe
33
+ generate_summary = module.generate_summary
34
+ save_uploaded_file = module.save_uploaded_file
35
+ generate_captcha = module.generate_captcha
36
+
37
+ except Exception as e:
38
+ st.error(f"Error importing functions from cloned repo: {e}")
39
+ st.stop() # Stop the app if functions cannot be imported
40
 
41
  # Video Summarization Interface
42
  st.title("AI Based Video Summary Tool")
43
 
44
+ # Step 1: File upload
45
+ uploaded_file = st.file_uploader("Choose a video file...", type=["mp4", "avi", "mov", "mkv"])
46
 
47
+ if uploaded_file is not None:
48
+ saved_file_path = save_uploaded_file(uploaded_file)
49
+ if saved_file_path:
50
+ st.success("File uploaded and saved successfully!")
51
 
52
+ if st.button("Process Video"):
53
+ try:
54
+ descriptions = extract_frames_and_describe(saved_file_path)
55
+ video_summary = generate_summary(descriptions)
56
+ st.success("Video processed successfully!")
57
+ st.write(video_summary)
58
+ except Exception as e:
59
+ st.error(f"Failed to process video: {e}")
60
+ finally:
61
+ if os.path.exists(saved_file_path):
62
+ os.remove(saved_file_path)
63
+ else:
64
+ st.error("Failed to save uploaded file.")
65
+ else:
66
+ st.error("Please upload a video file.")