23 lines
526 B
Python
23 lines
526 B
Python
import torch
|
|
|
|
|
|
def compress(
|
|
input_file: str | None = None
|
|
):
|
|
if input_file:
|
|
with open(input_file, "rb") as file:
|
|
byte_data = file.read()
|
|
else:
|
|
# Read from stdin
|
|
text = input()
|
|
byte_data = text.encode('utf-8', errors='replace')
|
|
|
|
tensor = torch.tensor(list(byte_data), dtype=torch.long)
|
|
print(tensor)
|
|
|
|
# TODO Feed to model for compression, store result
|
|
return
|
|
|
|
|
|
def decompress():
|
|
return NotImplementedError("Decompression is not implemented yet")
|