crash10155 commited on
Commit
5852a6e
Β·
verified Β·
1 Parent(s): 896d5aa

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -1
app.py CHANGED
@@ -31,7 +31,26 @@ os.environ["TF_FORCE_GPU_ALLOW_GROWTH"] = "TRUE"
31
  import gradio as gr
32
  import torch
33
  import onnxruntime as ort
34
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
35
  # Optional imports with graceful degradation
36
  try:
37
  from moviepy.editor import VideoFileClip
 
31
  import gradio as gr
32
  import torch
33
  import onnxruntime as ort
34
+ try:
35
+ from SwitcherAI.utilities import set_temp_directory, get_temp_directory_info
36
+
37
+ # Set up proper temp directory for HuggingFace Spaces
38
+ temp_base_dir = BASE_DIR / "temp_switcher"
39
+ temp_base_dir.mkdir(exist_ok=True)
40
+ set_temp_directory(str(temp_base_dir))
41
+
42
+ # Print temp directory info for debugging
43
+ temp_info = get_temp_directory_info()
44
+ print("πŸ”§ SwitcherAI Temp Directory Setup:")
45
+ print(f" πŸ“ Base temp: {temp_info['base_temp']}")
46
+ print(f" πŸ“ Platform: {temp_info['platform']}")
47
+ print(f" πŸ“ HF Spaces: {temp_info['is_hf_spaces']}")
48
+ print(f" πŸ“ Exists: {temp_info['temp_exists']}")
49
+ print(f" πŸ“ Writable: {temp_info['temp_writable']}")
50
+
51
+ except ImportError as e:
52
+ print(f"⚠️ Could not import SwitcherAI utilities: {e}")
53
+ print("πŸ”„ Using default temp directory behavior")
54
  # Optional imports with graceful degradation
55
  try:
56
  from moviepy.editor import VideoFileClip