vivekchakraverty's picture
download
raw
560 Bytes
import os
import uuid
import torch
from gradio.utils import get_upload_folder
def save_tensor_to_file(tensor, prefix="tensor"):
upload_dir = get_upload_folder()
os.makedirs(upload_dir, exist_ok=True)
path = os.path.join(upload_dir, f"{prefix}_{uuid.uuid4().hex}.pt")
torch.save(tensor, path)
return path
def load_tensor_from_file(path, map_location=None):
# Use weights_only=True for security and to suppress FutureWarning (only tensors are loaded in this app)
return torch.load(path, map_location=map_location, weights_only=True)

Xet Storage Details

Size:
560 Bytes
·
Xet hash:
6ca5e63e18080b2fd8596d18d9f87d6b9616fe2ad6b6539d0b0730f8f847727c

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.