File size: 2,850 Bytes
9f1542c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "acb05338-490d-44c8-9923-7fb70d3465a2",
   "metadata": {},
   "outputs": [],
   "source": [
    "import torch\n",
    "import json\n",
    "class Config:pass"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "7dcd2d48-0ad7-4cde-99f7-d8c719026a85",
   "metadata": {},
   "outputs": [],
   "source": [
    "walloc_20x = torch.load(\"Stereo_Li_27c_test2.pth\",map_location='cpu', weights_only=False)\n",
    "config = walloc_20x['config']\n",
    "with open('stereo_20x.json', 'w') as f:\n",
    "    json.dump(config.__dict__, f, indent=4)\n",
    "del walloc_20x['config']\n",
    "torch.save(walloc_20x, 'stereo_20x.pth')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "0b5ddce5-8f83-484b-9a86-b6e3b799904c",
   "metadata": {},
   "outputs": [],
   "source": [
    "walloc_5x = torch.load(\"Stereo_Li_108c_test2.pth\",map_location='cpu', weights_only=False)\n",
    "config = walloc_5x['config']\n",
    "with open('stereo_5x.json', 'w') as f:\n",
    "    json.dump(config.__dict__, f, indent=4)\n",
    "del walloc_5x['config']\n",
    "torch.save(walloc_20x, 'stereo_5x.pth')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "0de59093-db74-4b08-ac45-f1b832529dcb",
   "metadata": {},
   "outputs": [],
   "source": [
    "walloc_16x = torch.load(\"RGB_Li_12c_J3_nf8_v1.0.2.pth\",map_location='cpu', weights_only=False)\n",
    "config = walloc_16x['config']\n",
    "with open('RGB_16x.json', 'w') as f:\n",
    "    json.dump(config.__dict__, f, indent=4)\n",
    "del walloc_16x['config']\n",
    "del walloc_16x['i_epoch']\n",
    "del walloc_16x['learning_rates']\n",
    "del walloc_16x['dist_losses']\n",
    "torch.save(walloc_16x, 'RGB_16x.pth')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "235117df-ddf4-4f72-a5a8-8395412f8eff",
   "metadata": {},
   "outputs": [],
   "source": [
    "walloc_4x = torch.load(\"RGB_Li_48c_J3_nf8_v1.0.2.pth\",map_location='cpu', weights_only=False)\n",
    "config = walloc_4x['config']\n",
    "with open('RGB_4x.json', 'w') as f:\n",
    "    json.dump(config.__dict__, f, indent=4)\n",
    "del walloc_4x['config']\n",
    "del walloc_4x['i_epoch']\n",
    "del walloc_4x['learning_rates']\n",
    "del walloc_4x['dist_losses']\n",
    "torch.save(walloc_4x, 'RGB_4x.pth')"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.12.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}