Spaces:
Running
on
Zero
Running
on
Zero
claude2.7
Browse files
app.py
CHANGED
|
@@ -3,6 +3,7 @@ import spaces
|
|
| 3 |
|
| 4 |
import os
|
| 5 |
import shutil
|
|
|
|
| 6 |
os.environ['TOKENIZERS_PARALLELISM'] = 'true'
|
| 7 |
os.environ['SPCONV_ALGO'] = 'native'
|
| 8 |
from typing import *
|
|
@@ -18,6 +19,14 @@ import traceback
|
|
| 18 |
import sys
|
| 19 |
|
| 20 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
MAX_SEED = np.iinfo(np.int32).max
|
| 22 |
TMP_DIR = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'tmp')
|
| 23 |
os.makedirs(TMP_DIR, exist_ok=True)
|
|
@@ -123,9 +132,14 @@ def text_to_3d(
|
|
| 123 |
video = [np.concatenate([video[i], video_geo[i]], axis=1) for i in range(len(video))]
|
| 124 |
video_path = os.path.join(user_dir, 'sample.mp4')
|
| 125 |
imageio.mimsave(video_path, video, fps=15)
|
|
|
|
|
|
|
| 126 |
state = pack_state(outputs['gaussian'][0], outputs['mesh'][0])
|
|
|
|
|
|
|
|
|
|
| 127 |
torch.cuda.empty_cache()
|
| 128 |
-
return
|
| 129 |
|
| 130 |
|
| 131 |
@spaces.GPU(duration=90)
|
|
|
|
| 3 |
|
| 4 |
import os
|
| 5 |
import shutil
|
| 6 |
+
import json
|
| 7 |
os.environ['TOKENIZERS_PARALLELISM'] = 'true'
|
| 8 |
os.environ['SPCONV_ALGO'] = 'native'
|
| 9 |
from typing import *
|
|
|
|
| 19 |
import sys
|
| 20 |
|
| 21 |
|
| 22 |
+
# Add JSON encoder for NumPy arrays
|
| 23 |
+
class NumpyEncoder(json.JSONEncoder):
|
| 24 |
+
def default(self, obj):
|
| 25 |
+
if isinstance(obj, np.ndarray):
|
| 26 |
+
return obj.tolist()
|
| 27 |
+
return json.JSONEncoder.default(self, obj)
|
| 28 |
+
|
| 29 |
+
|
| 30 |
MAX_SEED = np.iinfo(np.int32).max
|
| 31 |
TMP_DIR = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'tmp')
|
| 32 |
os.makedirs(TMP_DIR, exist_ok=True)
|
|
|
|
| 132 |
video = [np.concatenate([video[i], video_geo[i]], axis=1) for i in range(len(video))]
|
| 133 |
video_path = os.path.join(user_dir, 'sample.mp4')
|
| 134 |
imageio.mimsave(video_path, video, fps=15)
|
| 135 |
+
|
| 136 |
+
# Create the state object and ensure it's JSON serializable for API calls
|
| 137 |
state = pack_state(outputs['gaussian'][0], outputs['mesh'][0])
|
| 138 |
+
# Convert to serializable format
|
| 139 |
+
serializable_state = json.loads(json.dumps(state, cls=NumpyEncoder))
|
| 140 |
+
|
| 141 |
torch.cuda.empty_cache()
|
| 142 |
+
return serializable_state, video_path
|
| 143 |
|
| 144 |
|
| 145 |
@spaces.GPU(duration=90)
|