Tonic commited on
Commit
8c1d821
β€’
1 Parent(s): a103a7f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -1
app.py CHANGED
@@ -7,13 +7,16 @@ model_name = "PleIAs/OCRonos-Vintage"
7
  model = GPT2LMHeadModel.from_pretrained(model_name)
8
  tokenizer = GPT2Tokenizer.from_pretrained(model_name)
9
 
 
 
 
10
  # Set the device to GPU if available, otherwise use CPU
11
  device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
12
  model.to(device)
13
 
14
  def historical_generation(prompt, max_new_tokens=600):
15
  prompt = f"### Text ###\n{prompt}"
16
- inputs = tokenizer(prompt, return_tensors="pt", padding=True, truncation=True)
17
  input_ids = inputs["input_ids"].to(device)
18
  attention_mask = inputs["attention_mask"].to(device)
19
 
 
7
  model = GPT2LMHeadModel.from_pretrained(model_name)
8
  tokenizer = GPT2Tokenizer.from_pretrained(model_name)
9
 
10
+ # Set the pad token to be the same as the eos token
11
+ tokenizer.pad_token = tokenizer.eos_token
12
+
13
  # Set the device to GPU if available, otherwise use CPU
14
  device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
15
  model.to(device)
16
 
17
  def historical_generation(prompt, max_new_tokens=600):
18
  prompt = f"### Text ###\n{prompt}"
19
+ inputs = tokenizer(prompt, return_tensors="pt", padding=True, truncation=True, max_length=1024)
20
  input_ids = inputs["input_ids"].to(device)
21
  attention_mask = inputs["attention_mask"].to(device)
22