Upload domainnet/lower_train.py with huggingface_hub
Browse files- domainnet/lower_train.py +16 -0
domainnet/lower_train.py
ADDED
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import random
|
2 |
+
import ipdb
|
3 |
+
|
4 |
+
domains = ["clipart", "infograph", "painting", "quickdraw", "real", "sketch"]
|
5 |
+
random.seed(42)
|
6 |
+
data = []
|
7 |
+
for index, domain in enumerate(domains):
|
8 |
+
with open(domain + '_train_fold.txt', 'r') as f:
|
9 |
+
domain_data = f.readlines()
|
10 |
+
domain_data = [x.strip() + ' ' + str(index) + '\n' for x in domain_data]
|
11 |
+
data.extend(domain_data)
|
12 |
+
|
13 |
+
random.shuffle(data)
|
14 |
+
data = data[:30000]
|
15 |
+
with open('Domainnet_train_30k.txt', 'w') as f:
|
16 |
+
f.write("".join(data))
|