th0mascat commited on
Commit
3dfa0b7
1 Parent(s): 17b60f9

Add application file

Browse files
Files changed (1) hide show
  1. app.py +5 -5
app.py CHANGED
@@ -18,7 +18,7 @@ from happytransformer import HappyTextToText, TTSettings
18
 
19
  configs = BaseModelConfigs.load("./configs.yaml")
20
 
21
- happy_tt = HappyTextToText("T5", "vennify/t5-base-grammar-correction")
22
 
23
  beam_settings = TTSettings(num_beams=5, min_length=1, max_length=100)
24
 
@@ -67,9 +67,9 @@ async def predict_text(image: UploadFile):
67
 
68
  # Make a prediction
69
  extracted_text = model.predict(img)
70
- corrected_text = happy_tt.generate_text(extracted_text, beam_settings)
71
 
72
- return {"text": extracted_text, "corrected_text": corrected_text}
73
 
74
 
75
  @app.post("/extract_text/")
@@ -83,9 +83,9 @@ async def extract_text_from_image(image: UploadFile):
83
 
84
  # Perform OCR on the image
85
  extracted_text = pytesseract.image_to_string(img)
86
- corrected_text = happy_tt.generate_text(extracted_text, beam_settings)
87
 
88
- return {"text": extracted_text, "corrected_text": corrected_text}
89
  else:
90
  return {"error": "Invalid file format. Please upload an image."}
91
 
 
18
 
19
  configs = BaseModelConfigs.load("./configs.yaml")
20
 
21
+ #happy_tt = HappyTextToText("T5", "vennify/t5-base-grammar-correction")
22
 
23
  beam_settings = TTSettings(num_beams=5, min_length=1, max_length=100)
24
 
 
67
 
68
  # Make a prediction
69
  extracted_text = model.predict(img)
70
+ #corrected_text = happy_tt.generate_text(extracted_text, beam_settings)
71
 
72
+ return {"text": extracted_text}
73
 
74
 
75
  @app.post("/extract_text/")
 
83
 
84
  # Perform OCR on the image
85
  extracted_text = pytesseract.image_to_string(img)
86
+ #corrected_text = happy_tt.generate_text(extracted_text, beam_settings)
87
 
88
+ return {"text": extracted_text}
89
  else:
90
  return {"error": "Invalid file format. Please upload an image."}
91