Jangai commited on
Commit
443e319
·
verified ·
1 Parent(s): e02beda

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -2
app.py CHANGED
@@ -9,6 +9,9 @@ import json
9
  processor = TrOCRProcessor.from_pretrained('microsoft/trocr-base-handwritten')
10
  model = VisionEncoderDecoderModel.from_pretrained('microsoft/trocr-base-handwritten')
11
 
 
 
 
12
  # Load feedback data
13
  feedback_data_path = "feedback_data.json"
14
  if os.path.exists(feedback_data_path):
@@ -48,14 +51,14 @@ with gr.Blocks() as demo:
48
 
49
  with gr.Tabs():
50
  with gr.TabItem("Recognize Handwriting"):
51
- image_input = gr.Image(source="upload", tool="sketch", type="numpy", label="Draw or Upload an Image")
52
  recognize_button = gr.Button("Recognize Handwriting")
53
  output_text = gr.Textbox(label="Recognized Text")
54
 
55
  recognize_button.click(recognize_handwriting, inputs=image_input, outputs=output_text)
56
 
57
  with gr.TabItem("Provide Feedback"):
58
- feedback_image_input = gr.Image(source="upload", tool="sketch", type="numpy", label="Draw or Upload an Image")
59
  corrected_text_input = gr.Textbox(label="Corrected Text")
60
  feedback_button = gr.Button("Submit Feedback")
61
  feedback_output = gr.Textbox(label="Feedback Status")
 
9
  processor = TrOCRProcessor.from_pretrained('microsoft/trocr-base-handwritten')
10
  model = VisionEncoderDecoderModel.from_pretrained('microsoft/trocr-base-handwritten')
11
 
12
+ # Handle model initialization warnings
13
+ model.eval()
14
+
15
  # Load feedback data
16
  feedback_data_path = "feedback_data.json"
17
  if os.path.exists(feedback_data_path):
 
51
 
52
  with gr.Tabs():
53
  with gr.TabItem("Recognize Handwriting"):
54
+ image_input = gr.Image(source="upload", tool="editor", type="numpy", label="Draw or Upload an Image")
55
  recognize_button = gr.Button("Recognize Handwriting")
56
  output_text = gr.Textbox(label="Recognized Text")
57
 
58
  recognize_button.click(recognize_handwriting, inputs=image_input, outputs=output_text)
59
 
60
  with gr.TabItem("Provide Feedback"):
61
+ feedback_image_input = gr.Image(source="upload", tool="editor", type="numpy", label="Draw or Upload an Image")
62
  corrected_text_input = gr.Textbox(label="Corrected Text")
63
  feedback_button = gr.Button("Submit Feedback")
64
  feedback_output = gr.Textbox(label="Feedback Status")