Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -193,48 +193,48 @@ class ManimAnimationGenerator:
|
|
| 193 |
|
| 194 |
code = extract_manim_code(code)
|
| 195 |
|
| 196 |
-
# try:
|
| 197 |
-
# is_valid, message = self.validate_manim_code(code)
|
| 198 |
-
# if not is_valid:
|
| 199 |
-
# return None, f"❌ Validation Error: {message}", ""
|
| 200 |
-
|
| 201 |
-
# temp_dir = self.setup_directories()
|
| 202 |
-
# python_file = os.path.join(temp_dir, "animation.py")
|
| 203 |
-
# with open(python_file, "w") as f:
|
| 204 |
-
# f.write(code)
|
| 205 |
-
|
| 206 |
try:
|
| 207 |
is_valid, message = self.validate_manim_code(code)
|
| 208 |
if not is_valid:
|
| 209 |
return None, f"❌ Validation Error: {message}", ""
|
| 210 |
|
| 211 |
-
# Dynamically inject portrait (9:16) config
|
| 212 |
-
portrait_config = (
|
| 213 |
-
"from manim import config\n"
|
| 214 |
-
"# Maintain chosen quality while forcing 9:16 aspect ratio\n"
|
| 215 |
-
"if config.pixel_height == 480:\n"
|
| 216 |
-
" config.pixel_height = 854 # low\n"
|
| 217 |
-
" config.pixel_width = 480\n"
|
| 218 |
-
"elif config.pixel_height == 720:\n"
|
| 219 |
-
" config.pixel_height = 1280 # medium\n"
|
| 220 |
-
" config.pixel_width = 720\n"
|
| 221 |
-
"elif config.pixel_height == 1080:\n"
|
| 222 |
-
" config.pixel_height = 1920 # high\n"
|
| 223 |
-
" config.pixel_width = 1080\n"
|
| 224 |
-
"else:\n"
|
| 225 |
-
" config.pixel_height = 854\n"
|
| 226 |
-
" config.pixel_width = 480\n"
|
| 227 |
-
"config.frame_height = 16\n"
|
| 228 |
-
"config.frame_width = 9\n"
|
| 229 |
-
)
|
| 230 |
-
|
| 231 |
-
|
| 232 |
-
code = portrait_config + "\n" + code
|
| 233 |
-
|
| 234 |
temp_dir = self.setup_directories()
|
| 235 |
python_file = os.path.join(temp_dir, "animation.py")
|
| 236 |
with open(python_file, "w") as f:
|
| 237 |
f.write(code)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 238 |
#end
|
| 239 |
|
| 240 |
class_name = self.extract_class_name(code)
|
|
|
|
| 193 |
|
| 194 |
code = extract_manim_code(code)
|
| 195 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 196 |
try:
|
| 197 |
is_valid, message = self.validate_manim_code(code)
|
| 198 |
if not is_valid:
|
| 199 |
return None, f"❌ Validation Error: {message}", ""
|
| 200 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 201 |
temp_dir = self.setup_directories()
|
| 202 |
python_file = os.path.join(temp_dir, "animation.py")
|
| 203 |
with open(python_file, "w") as f:
|
| 204 |
f.write(code)
|
| 205 |
+
|
| 206 |
+
# try:
|
| 207 |
+
# is_valid, message = self.validate_manim_code(code)
|
| 208 |
+
# if not is_valid:
|
| 209 |
+
# return None, f"❌ Validation Error: {message}", ""
|
| 210 |
+
|
| 211 |
+
# # Dynamically inject portrait (9:16) config
|
| 212 |
+
# portrait_config = (
|
| 213 |
+
# "from manim import config\n"
|
| 214 |
+
# "# Maintain chosen quality while forcing 9:16 aspect ratio\n"
|
| 215 |
+
# "if config.pixel_height == 480:\n"
|
| 216 |
+
# " config.pixel_height = 854 # low\n"
|
| 217 |
+
# " config.pixel_width = 480\n"
|
| 218 |
+
# "elif config.pixel_height == 720:\n"
|
| 219 |
+
# " config.pixel_height = 1280 # medium\n"
|
| 220 |
+
# " config.pixel_width = 720\n"
|
| 221 |
+
# "elif config.pixel_height == 1080:\n"
|
| 222 |
+
# " config.pixel_height = 1920 # high\n"
|
| 223 |
+
# " config.pixel_width = 1080\n"
|
| 224 |
+
# "else:\n"
|
| 225 |
+
# " config.pixel_height = 854\n"
|
| 226 |
+
# " config.pixel_width = 480\n"
|
| 227 |
+
# "config.frame_height = 16\n"
|
| 228 |
+
# "config.frame_width = 9\n"
|
| 229 |
+
# )
|
| 230 |
+
|
| 231 |
+
|
| 232 |
+
# code = portrait_config + "\n" + code
|
| 233 |
+
|
| 234 |
+
# temp_dir = self.setup_directories()
|
| 235 |
+
# python_file = os.path.join(temp_dir, "animation.py")
|
| 236 |
+
# with open(python_file, "w") as f:
|
| 237 |
+
# f.write(code)
|
| 238 |
#end
|
| 239 |
|
| 240 |
class_name = self.extract_class_name(code)
|