Pisethan commited on
Commit
9779991
·
verified ·
1 Parent(s): 1c6b557

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -3
app.py CHANGED
@@ -7,8 +7,8 @@ processor = TrOCRProcessor.from_pretrained("Pisethan/sangapac_ocr")
7
  model = VisionEncoderDecoderModel.from_pretrained("Pisethan/sangapac_ocr")
8
 
9
  # Define the prediction function
10
- def recognize_text(image):
11
- image = Image.open(image).convert("RGB")
12
  inputs = processor(images=image, return_tensors="pt").pixel_values
13
  outputs = model.generate(inputs)
14
  predicted_text = processor.tokenizer.decode(outputs[0], skip_special_tokens=True)
@@ -17,7 +17,7 @@ def recognize_text(image):
17
  # Gradio Interface
18
  interface = gr.Interface(
19
  fn=recognize_text,
20
- inputs=gr.Image(type="file", label="Upload an Image"),
21
  outputs=gr.Textbox(label="Recognized Text"),
22
  title="OCR Model Demo",
23
  description="Upload an image containing text to test the OCR model.",
 
7
  model = VisionEncoderDecoderModel.from_pretrained("Pisethan/sangapac_ocr")
8
 
9
  # Define the prediction function
10
+ def recognize_text(image_path):
11
+ image = Image.open(image_path).convert("RGB")
12
  inputs = processor(images=image, return_tensors="pt").pixel_values
13
  outputs = model.generate(inputs)
14
  predicted_text = processor.tokenizer.decode(outputs[0], skip_special_tokens=True)
 
17
  # Gradio Interface
18
  interface = gr.Interface(
19
  fn=recognize_text,
20
+ inputs=gr.Image(type="filepath", label="Upload an Image"),
21
  outputs=gr.Textbox(label="Recognized Text"),
22
  title="OCR Model Demo",
23
  description="Upload an image containing text to test the OCR model.",