credent007 commited on
Commit
b3dbdfe
·
verified ·
1 Parent(s): 6ae1160

Update inference.py

Browse files
Files changed (1) hide show
  1. inference.py +5 -3
inference.py CHANGED
@@ -28,14 +28,14 @@ def process_document(image):
28
  tokenize=False, # so that this can return string output
29
  add_generation_prompt=True # if true it will add extra on start and end
30
  )
31
- print(f"The text of inference is {text}")
32
 
33
  inputs = processor(
34
  text=[text],
35
  images=[image],
36
  return_tensors="pt"
37
  ).to(device)
38
- print(f"The inputs of inference is {inputs}")
39
 
40
  output = model.generate(
41
  **inputs,
@@ -43,10 +43,11 @@ def process_document(image):
43
  do_sample=False, # if it is true there will be extra text with output
44
  # temperature=0.1 # temp is not required
45
  )
46
- print(f"The output of inference is {output}")
47
 
48
 
49
  generated_ids = output[0][inputs.input_ids.shape[-1]:]
 
50
 
51
  # response = processor.decode( # past code
52
  # generated_ids,
@@ -61,6 +62,7 @@ def process_document(image):
61
  generated_ids,
62
  skip_special_tokens=True
63
  ).strip()
 
64
 
65
  # 🔥 FORCE JSON CLEANING
66
  start = response.find("{")
 
28
  tokenize=False, # so that this can return string output
29
  add_generation_prompt=True # if true it will add extra on start and end
30
  )
31
+ # print(f"The text of inference is {text}")
32
 
33
  inputs = processor(
34
  text=[text],
35
  images=[image],
36
  return_tensors="pt"
37
  ).to(device)
38
+ # print(f"The inputs of inference is {inputs}")
39
 
40
  output = model.generate(
41
  **inputs,
 
43
  do_sample=False, # if it is true there will be extra text with output
44
  # temperature=0.1 # temp is not required
45
  )
46
+ # print(f"The output of inference is {output}")
47
 
48
 
49
  generated_ids = output[0][inputs.input_ids.shape[-1]:]
50
+ print(f"The generated_ids of inference is {generated_ids}")
51
 
52
  # response = processor.decode( # past code
53
  # generated_ids,
 
62
  generated_ids,
63
  skip_special_tokens=True
64
  ).strip()
65
+ print(f"The response of inference is {response}")
66
 
67
  # 🔥 FORCE JSON CLEANING
68
  start = response.find("{")