Spaces:
Running on Zero
Running on Zero
AndrianBalanescu commited on
Commit ·
fa8a377
1
Parent(s): 7b248b7
fix(zerogpu-video): convert float32 numpy frames to uint8 before PIL save
Browse files
app.py
CHANGED
|
@@ -1310,7 +1310,13 @@ def generate_zerogpu_video(
|
|
| 1310 |
with tempfile.TemporaryDirectory() as tmpdir:
|
| 1311 |
for idx, frame in enumerate(video_frames):
|
| 1312 |
if isinstance(frame, np.ndarray):
|
| 1313 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1314 |
else:
|
| 1315 |
img = frame
|
| 1316 |
img.save(os.path.join(tmpdir, f"frame_{idx:05d}.png"))
|
|
|
|
| 1310 |
with tempfile.TemporaryDirectory() as tmpdir:
|
| 1311 |
for idx, frame in enumerate(video_frames):
|
| 1312 |
if isinstance(frame, np.ndarray):
|
| 1313 |
+
f_arr = frame
|
| 1314 |
+
if f_arr.dtype in (np.float32, np.float64, np.float16):
|
| 1315 |
+
if f_arr.max() <= 1.0:
|
| 1316 |
+
f_arr = (f_arr * 255.0).clip(0, 255).astype(np.uint8)
|
| 1317 |
+
else:
|
| 1318 |
+
f_arr = f_arr.clip(0, 255).astype(np.uint8)
|
| 1319 |
+
img = Image.fromarray(f_arr)
|
| 1320 |
else:
|
| 1321 |
img = frame
|
| 1322 |
img.save(os.path.join(tmpdir, f"frame_{idx:05d}.png"))
|