Feature Extraction
Transformers
Safetensors
vision-encoder-decoder
custom_code
anicolson commited on
Commit
9a55fa3
1 Parent(s): 4b5c071

Upload model

Browse files
Files changed (2) hide show
  1. config.json +4 -0
  2. modelling_cxrrg.py +4 -6
config.json CHANGED
@@ -21,6 +21,10 @@
21
  "do_sample": false,
22
  "early_stopping": false,
23
  "encoder_no_repeat_ngram_size": 0,
 
 
 
 
24
  "eos_token_id": 2,
25
  "exponential_decay_length_penalty": null,
26
  "finetuning_task": null,
 
21
  "do_sample": false,
22
  "early_stopping": false,
23
  "encoder_no_repeat_ngram_size": 0,
24
+ "end_of_section_token_ids": [
25
+ 3,
26
+ 2
27
+ ],
28
  "eos_token_id": 2,
29
  "exponential_decay_length_penalty": null,
30
  "finetuning_task": null,
modelling_cxrrg.py CHANGED
@@ -1,13 +1,11 @@
1
- import functools
2
- import os
3
  from typing import Optional, Tuple, Union
4
 
5
  import torch
6
  import transformers
7
- from torch.nn import CrossEntropyLoss, Linear
8
  from transformers import PreTrainedTokenizerFast, VisionEncoderDecoderModel
9
  from transformers.configuration_utils import PretrainedConfig
10
- from transformers.modeling_outputs import BaseModelOutput, Seq2SeqLMOutput
11
  from transformers.modeling_utils import PreTrainedModel
12
  from transformers.models.vision_encoder_decoder.configuration_vision_encoder_decoder import (
13
  VisionEncoderDecoderConfig,
@@ -457,13 +455,13 @@ class CXRRGModel(VisionEncoderDecoderModel):
457
  _, seq_len = token_ids.shape
458
 
459
  # The number of sections is the same as the number of separator_token_ids:
460
- num_sections = len(self.config.decoder.separator_token_ids)
461
 
462
  sections = {k: [] for k in range(num_sections)}
463
 
464
  for i in token_ids:
465
  prev_col = 0
466
- for j, k in enumerate(self.config.decoder.separator_token_ids):
467
 
468
  # The maximum sequence length was exceeded, thus no more tokens:
469
  if prev_col >= seq_len:
 
 
 
1
  from typing import Optional, Tuple, Union
2
 
3
  import torch
4
  import transformers
5
+ from torch.nn import CrossEntropyLoss
6
  from transformers import PreTrainedTokenizerFast, VisionEncoderDecoderModel
7
  from transformers.configuration_utils import PretrainedConfig
8
+ from transformers.modeling_outputs import Seq2SeqLMOutput
9
  from transformers.modeling_utils import PreTrainedModel
10
  from transformers.models.vision_encoder_decoder.configuration_vision_encoder_decoder import (
11
  VisionEncoderDecoderConfig,
 
455
  _, seq_len = token_ids.shape
456
 
457
  # The number of sections is the same as the number of separator_token_ids:
458
+ num_sections = len(self.config.decoder.end_of_section_token_ids)
459
 
460
  sections = {k: [] for k in range(num_sections)}
461
 
462
  for i in token_ids:
463
  prev_col = 0
464
+ for j, k in enumerate(self.config.decoder.end_of_section_token_ids):
465
 
466
  # The maximum sequence length was exceeded, thus no more tokens:
467
  if prev_col >= seq_len: