dfdfdsfgs commited on
Commit
550af36
·
1 Parent(s): 4588d9f

Fix model download issue: Make Manim/Kokoro dependencies optional for HF Spaces

Browse files
huggingface_spaces_app.py CHANGED
@@ -41,10 +41,20 @@ def initialize_video_generator():
41
 
42
  try:
43
  if DEMO_MODE:
44
- return "✅ Demo mode enabled"
45
 
46
- from generate_video import VideoGenerator
47
- from mllm_tools.litellm import LiteLLMWrapper
 
 
 
 
 
 
 
 
 
 
48
 
49
  planner_model = LiteLLMWrapper(
50
  model_name="gemini/gemini-2.0-flash",
@@ -65,11 +75,12 @@ def initialize_video_generator():
65
  verbose=False
66
  )
67
 
68
- return "✅ Video generator initialized"
69
 
70
  except Exception as e:
71
  CAN_IMPORT_DEPENDENCIES = False
72
- return f"⚠️ Running in demo mode: {str(e)}"
 
73
 
74
  def simulate_video_generation(topic: str, context: str, max_scenes: int, progress_callback=None):
75
  """Simulate video generation."""
@@ -206,12 +217,15 @@ def create_interface():
206
  if DEMO_MODE:
207
  gr.HTML("""
208
  <div style="background: #fff3cd; padding: 15px; border-radius: 5px; margin: 10px 0;">
209
- <h3>⚠️ Demo Mode</h3>
 
210
  <p>To enable full functionality:</p>
211
  <ul>
212
  <li>Set <code>GEMINI_API_KEY</code> (supports comma-separated keys)</li>
213
  <li>Set <code>DEMO_MODE=false</code></li>
 
214
  </ul>
 
215
  </div>
216
  """)
217
 
 
41
 
42
  try:
43
  if DEMO_MODE:
44
+ return "✅ Demo mode enabled - No heavy dependencies loaded"
45
 
46
+ # Check if we have API keys before importing heavy dependencies
47
+ gemini_keys = os.getenv("GEMINI_API_KEY", "")
48
+ if not gemini_keys:
49
+ return "⚠️ No API keys found - running in demo mode (prevents model downloads)"
50
+
51
+ # Try to import but handle missing dependencies gracefully
52
+ try:
53
+ from generate_video import VideoGenerator
54
+ from mllm_tools.litellm import LiteLLMWrapper
55
+ except ImportError as import_err:
56
+ print(f"Heavy dependencies not available: {import_err}")
57
+ return "⚠️ Heavy dependencies not installed - using demo mode to prevent downloads"
58
 
59
  planner_model = LiteLLMWrapper(
60
  model_name="gemini/gemini-2.0-flash",
 
75
  verbose=False
76
  )
77
 
78
+ return "✅ Video generator initialized with full dependencies"
79
 
80
  except Exception as e:
81
  CAN_IMPORT_DEPENDENCIES = False
82
+ print(f"Initialization error: {e}")
83
+ return f"⚠️ Running in demo mode to prevent model downloads: {str(e)[:100]}..."
84
 
85
  def simulate_video_generation(topic: str, context: str, max_scenes: int, progress_callback=None):
86
  """Simulate video generation."""
 
217
  if DEMO_MODE:
218
  gr.HTML("""
219
  <div style="background: #fff3cd; padding: 15px; border-radius: 5px; margin: 10px 0;">
220
+ <h3>⚠️ Demo Mode - Preventing Model Downloads</h3>
221
+ <p>This prevents automatic downloading of Kokoro and other heavy models.</p>
222
  <p>To enable full functionality:</p>
223
  <ul>
224
  <li>Set <code>GEMINI_API_KEY</code> (supports comma-separated keys)</li>
225
  <li>Set <code>DEMO_MODE=false</code></li>
226
+ <li>Install full dependencies (manim, manim-voiceover, etc.)</li>
227
  </ul>
228
+ <p><strong>Note:</strong> Full mode requires ~2GB of model downloads.</p>
229
  </div>
230
  """)
231
 
requirements_hf.txt CHANGED
@@ -17,9 +17,10 @@ elevenlabs>=1.0.0
17
  # Utility libraries
18
  tqdm>=4.62.0
19
 
20
- # Optional dependencies for full functionality
21
- # These will be installed if available, but the app will work without them
22
- manim; python_version>="3.8"
23
- pydub>=0.25.0; python_version>="3.8"
24
- moviepy>=1.0.3; python_version>="3.8"
25
- soundfile>=0.12.0; python_version>="3.8"
 
 
17
  # Utility libraries
18
  tqdm>=4.62.0
19
 
20
+ # Video processing dependencies (only install when needed)
21
+ # Comment out these lines to prevent heavy downloads on Hugging Face Spaces
22
+ # manim; python_version>="3.8"
23
+ # manim-voiceover; python_version>="3.8"
24
+ # pydub>=0.25.0; python_version>="3.8"
25
+ # moviepy>=1.0.3; python_version>="3.8"
26
+ # soundfile>=0.12.0; python_version>="3.8"
requirements_hf_minimal.txt ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Minimal dependencies for Hugging Face Spaces demo
2
+ gradio==4.44.0
3
+ python-dotenv>=0.19.0
4
+ requests>=2.25.0
5
+ numpy>=1.21.0
6
+
7
+ # AI/ML dependencies (lightweight)
8
+ litellm>=1.0.0
9
+ google-generativeai>=0.8.0
10
+
11
+ # Basic image processing
12
+ pillow>=8.3.0
13
+
14
+ # Utility libraries
15
+ tqdm>=4.62.0
16
+
17
+ # Optional TTS (only if ELEVENLABS_API_KEY is set)
18
+ elevenlabs>=1.0.0