Spaces:
Runtime error
Runtime error
File size: 887 Bytes
8bb8404 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
import numpy as np
import random
import string
from torch.utils.data import Dataset, Subset
class DummyData(Dataset):
def __init__(self, length, size):
self.length = length
self.size = size
def __len__(self):
return self.length
def __getitem__(self, i):
x = np.random.randn(*self.size)
letters = string.ascii_lowercase
y = ''.join(random.choice(string.ascii_lowercase) for i in range(10))
return {"jpg": x, "txt": y}
class DummyDataWithEmbeddings(Dataset):
def __init__(self, length, size, emb_size):
self.length = length
self.size = size
self.emb_size = emb_size
def __len__(self):
return self.length
def __getitem__(self, i):
x = np.random.randn(*self.size)
y = np.random.randn(*self.emb_size).astype(np.float32)
return {"jpg": x, "txt": y}
|