da03 commited on
Commit
837289b
·
1 Parent(s): f2aec00
Files changed (3) hide show
  1. config_rnn_measure_latency.yaml +108 -0
  2. main.py +1 -1
  3. utils.py +7 -7
config_rnn_measure_latency.yaml ADDED
@@ -0,0 +1,108 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ save_path: saved_standard_challenging_context32_nocond_cont_cont_all_cont_eval
2
+
3
+ model:
4
+ base_learning_rate: 8.0e-05
5
+ target: ldm.models.diffusion.ddpm.LatentDiffusion
6
+ params:
7
+ linear_start: 0.0015
8
+ linear_end: 0.0195
9
+ num_timesteps_cond: 1
10
+ log_every_t: 200
11
+ timesteps: 1000
12
+ first_stage_key: image
13
+ cond_stage_key: action_
14
+ scheduler_sampling_rate: 0.0
15
+ hybrid_key: c_concat
16
+ image_size: [64, 48]
17
+ channels: 3
18
+ cond_stage_trainable: false
19
+ conditioning_key: hybrid
20
+ monitor: val/loss_simple_ema
21
+
22
+ unet_config:
23
+ target: ldm.modules.diffusionmodules.openaimodel.UNetModel
24
+ params:
25
+ image_size: [64, 48]
26
+ in_channels: 8
27
+ out_channels: 4
28
+ model_channels: 192
29
+ attention_resolutions:
30
+ - 8
31
+ - 4
32
+ - 2
33
+ num_res_blocks: 2
34
+ channel_mult:
35
+ - 1
36
+ - 2
37
+ - 3
38
+ num_head_channels: 32
39
+ use_spatial_transformer: false
40
+ transformer_depth: 1
41
+
42
+ temporal_encoder_config:
43
+ target: ldm.modules.encoders.temporal_encoder.TemporalEncoder
44
+ params:
45
+ input_channels: 6
46
+ hidden_size: 1024
47
+ num_layers: 1
48
+ dropout: 0.1
49
+ output_channels: 4
50
+ output_height: 48
51
+ output_width: 64
52
+
53
+ first_stage_config:
54
+ target: ldm.models.autoencoder.AutoencoderKL
55
+ params:
56
+ embed_dim: 4
57
+ monitor: val/rec_loss
58
+ ddconfig:
59
+ double_z: true
60
+ z_channels: 4
61
+ resolution: 256
62
+ in_channels: 3
63
+ out_ch: 3
64
+ ch: 128
65
+ ch_mult:
66
+ - 1
67
+ - 2
68
+ - 4
69
+ - 4
70
+ num_res_blocks: 2
71
+ attn_resolutions: []
72
+ dropout: 0.0
73
+ lossconfig:
74
+ target: torch.nn.Identity
75
+
76
+ cond_stage_config: __is_unconditional__
77
+
78
+ data:
79
+ target: data.data_processing.datasets.DataModule
80
+ params:
81
+ batch_size: 8
82
+ num_workers: 1
83
+ wrap: false
84
+ shuffle: True
85
+ drop_last: True
86
+ pin_memory: True
87
+ prefetch_factor: 2
88
+ persistent_workers: True
89
+ train:
90
+ target: data.data_processing.datasets.ActionsData
91
+ params:
92
+ data_csv_path: desktop_sequences_filtered_with_desktop_1.5k.challenging.train.target_frames.csv
93
+ normalization: standard
94
+ context_length: 32
95
+ #validation:
96
+ # target: data.data_processing.datasets.ActionsData
97
+ # params:
98
+
99
+ lightning:
100
+ trainer:
101
+ benchmark: False
102
+ max_epochs: 6400
103
+ limit_val_batches: 0
104
+ accelerator: gpu
105
+ gpus: 1
106
+ accumulate_grad_batches: 999999
107
+ gradient_clip_val: 1
108
+ checkpoint_callback: True
main.py CHANGED
@@ -27,7 +27,7 @@ LATENT_DIMS = (4, SCREEN_HEIGHT // 8, SCREEN_WIDTH // 8)
27
  device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
28
  # Initialize the model at the start of your application
29
  #model = initialize_model("config_csllm.yaml", "yuntian-deng/computer-model")
30
- model = initialize_model("config_rnn.yaml", "yuntian-deng/computer-model")
31
 
32
  device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
33
  model = model.to(device)
 
27
  device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
28
  # Initialize the model at the start of your application
29
  #model = initialize_model("config_csllm.yaml", "yuntian-deng/computer-model")
30
+ model = initialize_model("config_rnn_measure_latency.yaml", "yuntian-deng/computer-model")
31
 
32
  device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
33
  model = model.to(device)
utils.py CHANGED
@@ -10,7 +10,7 @@ import os
10
  import time
11
  DEBUG = False
12
 
13
- def load_model_from_config(config_path, model_name, device='cuda'):
14
  # Load the config file
15
  config = OmegaConf.load(config_path)
16
 
@@ -18,12 +18,12 @@ def load_model_from_config(config_path, model_name, device='cuda'):
18
  model = instantiate_from_config(config.model)
19
 
20
  # Download the model file from Hugging Face
21
- model_file = hf_hub_download(repo_id=model_name, filename="model.safetensors", token=os.getenv('HF_TOKEN'))
22
-
23
- print(f"Loading model from {model_name}")
24
- # Load the state dict
25
- state_dict = torch.load(model_file, map_location='cpu')
26
- model.load_state_dict(state_dict, strict=True)
27
 
28
  model.to(device)
29
  model.eval()
 
10
  import time
11
  DEBUG = False
12
 
13
+ def load_model_from_config(config_path, model_name, device='cuda', load=False):
14
  # Load the config file
15
  config = OmegaConf.load(config_path)
16
 
 
18
  model = instantiate_from_config(config.model)
19
 
20
  # Download the model file from Hugging Face
21
+ if load:
22
+ model_file = hf_hub_download(repo_id=model_name, filename="model.safetensors", token=os.getenv('HF_TOKEN'))
23
+ print(f"Loading model from {model_name}")
24
+ # Load the state dict
25
+ state_dict = torch.load(model_file, map_location='cpu')
26
+ model.load_state_dict(state_dict, strict=True)
27
 
28
  model.to(device)
29
  model.eval()