Update app.py
Browse files
app.py
CHANGED
@@ -12,6 +12,7 @@ from pathlib import Path
|
|
12 |
import spaces
|
13 |
import gc
|
14 |
from huggingface_hub import hf_hub_download
|
|
|
15 |
|
16 |
# Latest and best open-source models
|
17 |
from transformers import AutoTokenizer, AutoModelForCausalLM, pipeline
|
@@ -38,6 +39,9 @@ except ImportError:
|
|
38 |
TRITON_AVAILABLE = False
|
39 |
print("⚠️ Triton not available - using standard operations")
|
40 |
|
|
|
|
|
|
|
41 |
class ProfessionalCartoonFilmGenerator:
|
42 |
def __init__(self):
|
43 |
self.device = "cuda" if torch.cuda.is_available() else "cpu"
|
@@ -1237,7 +1241,21 @@ def create_professional_cartoon_film(script):
|
|
1237 |
}
|
1238 |
return None, empty_response, "❌ Please enter a script", [], []
|
1239 |
|
1240 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1241 |
|
1242 |
# Professional Gradio Interface
|
1243 |
with gr.Blocks(
|
@@ -1287,6 +1305,19 @@ with gr.Blocks(
|
|
1287 |
- Filmmakers prototyping animated concepts
|
1288 |
- Educators creating engaging educational content
|
1289 |
- Anyone wanting Disney-quality cartoon films
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1290 |
""")
|
1291 |
|
1292 |
with gr.Row():
|
@@ -1321,6 +1352,14 @@ The more details you provide about characters, setting, and emotion, the better
|
|
1321 |
""")
|
1322 |
|
1323 |
with gr.Column(scale=1):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1324 |
video_output = gr.Video(
|
1325 |
label="🎬 Professional Cartoon Film",
|
1326 |
height=500
|
|
|
12 |
import spaces
|
13 |
import gc
|
14 |
from huggingface_hub import hf_hub_download
|
15 |
+
import threading
|
16 |
|
17 |
# Latest and best open-source models
|
18 |
from transformers import AutoTokenizer, AutoModelForCausalLM, pipeline
|
|
|
39 |
TRITON_AVAILABLE = False
|
40 |
print("⚠️ Triton not available - using standard operations")
|
41 |
|
42 |
+
# Global lock to prevent concurrent generations
|
43 |
+
generation_lock = threading.Lock()
|
44 |
+
|
45 |
class ProfessionalCartoonFilmGenerator:
|
46 |
def __init__(self):
|
47 |
self.device = "cuda" if torch.cuda.is_available() else "cpu"
|
|
|
1241 |
}
|
1242 |
return None, empty_response, "❌ Please enter a script", [], []
|
1243 |
|
1244 |
+
# Check if another generation is in progress
|
1245 |
+
if not generation_lock.acquire(blocking=False):
|
1246 |
+
busy_response = {
|
1247 |
+
"error": True,
|
1248 |
+
"message": "Generation already in progress",
|
1249 |
+
"characters": [],
|
1250 |
+
"scenes": [],
|
1251 |
+
"style": "Please wait for current generation to complete"
|
1252 |
+
}
|
1253 |
+
return None, busy_response, "⏳ Another generation is in progress. Please wait and try again.", [], []
|
1254 |
+
|
1255 |
+
try:
|
1256 |
+
return generator.generate_professional_cartoon_film(script)
|
1257 |
+
finally:
|
1258 |
+
generation_lock.release()
|
1259 |
|
1260 |
# Professional Gradio Interface
|
1261 |
with gr.Blocks(
|
|
|
1305 |
- Filmmakers prototyping animated concepts
|
1306 |
- Educators creating engaging educational content
|
1307 |
- Anyone wanting Disney-quality cartoon films
|
1308 |
+
|
1309 |
+
---
|
1310 |
+
|
1311 |
+
**⚠️ Current Status:**
|
1312 |
+
- ✅ **Storage System:** Fixed for Hugging Face Spaces
|
1313 |
+
- ⚠️ **FLUX Models:** Require authentication token (using Stable Diffusion fallback)
|
1314 |
+
- ⚠️ **Open-Sora:** Using static video fallback for stability
|
1315 |
+
- ✅ **File Downloads:** Available through Gradio galleries below
|
1316 |
+
|
1317 |
+
**💡 To unlock full FLUX quality:**
|
1318 |
+
1. Get token from [Hugging Face Settings](https://huggingface.co/settings/tokens)
|
1319 |
+
2. Accept [FLUX License](https://huggingface.co/black-forest-labs/FLUX.1-dev)
|
1320 |
+
3. Add token as Space secret: `HF_TOKEN`
|
1321 |
""")
|
1322 |
|
1323 |
with gr.Row():
|
|
|
1352 |
""")
|
1353 |
|
1354 |
with gr.Column(scale=1):
|
1355 |
+
gr.Markdown("""
|
1356 |
+
**⚠️ Important Notes:**
|
1357 |
+
- Only **ONE generation at a time** - multiple clicks will be queued
|
1358 |
+
- **Processing takes 8-12 minutes** - please be patient
|
1359 |
+
- **Files auto-download** through galleries below
|
1360 |
+
- **Storage fixed** for Hugging Face Spaces compatibility
|
1361 |
+
""")
|
1362 |
+
|
1363 |
video_output = gr.Video(
|
1364 |
label="🎬 Professional Cartoon Film",
|
1365 |
height=500
|