liudongqing commited on
Commit
19f284d
1 Parent(s): 35ec859

Fixed the output

Browse files
Files changed (1) hide show
  1. app.py +6 -4
app.py CHANGED
@@ -36,12 +36,14 @@ def ocr(input_img):
36
  inputs = processor(image, prompt, return_tensors="pt").to(model.device)
37
 
38
  output = model.generate(**inputs, max_new_tokens=200)
39
- return processor.decode(output[0])
 
40
 
41
 
42
- prompt = '''Review the following essay and score it. Output the score and the reasoning.The output format is:
43
  Score: *<score>*
44
- Reasoning: 1... 2... 3... 4... 5...
 
45
  '''
46
 
47
  def score_with_gpt(text):
@@ -73,7 +75,7 @@ def score_it(input_img):
73
 
74
  demo = gr.Interface(fn=score_it, title="Upload your English script and get the score",
75
  inputs=[gr.Image()],
76
- outputs=[gr.Textbox(label="Text", lines=10), gr.Textbox(
77
  label="Score", lines=10)],
78
  stop_btn="Stop Generation",
79
  )
 
36
  inputs = processor(image, prompt, return_tensors="pt").to(model.device)
37
 
38
  output = model.generate(**inputs, max_new_tokens=200)
39
+ res = processor.decode(output[0])
40
+ return res[len(prompt):res.find("<ORC>") - 5]
41
 
42
 
43
+ prompt = '''Review the following essay and score it. The output format is:
44
  Score: *<score>*
45
+ Reason: ...
46
+ Suggestions: ...
47
  '''
48
 
49
  def score_with_gpt(text):
 
75
 
76
  demo = gr.Interface(fn=score_it, title="Upload your English script and get the score",
77
  inputs=[gr.Image()],
78
+ outputs=[gr.Textbox(label="Text", lines=10), gr.Markdown(
79
  label="Score", lines=10)],
80
  stop_btn="Stop Generation",
81
  )