ianluo commited on
Commit
ca3731f
1 Parent(s): 336e074
Files changed (3) hide show
  1. main.py +6 -6
  2. static/index.html +0 -1
  3. static/script.js +1 -1
main.py CHANGED
@@ -5,15 +5,15 @@ from transformers import pipeline
5
 
6
  app = FastAPI()
7
 
8
- pipe_flan = pipeline("text2text-generation", model="google/flan-t5-small")
9
-
10
- @app.get("/infer_t5")
11
- def t5(input):
12
- output = pipe_flan(input)
13
- return {"output": output[0]["generated_text"]}
14
 
15
  app.mount("/", StaticFiles(directory="static", html=True), name="static")
16
 
17
  @app.get("/")
18
  def index() -> FileResponse:
19
  return FileResponse(path="/app/static/index.html", media_type="text/html")
 
 
 
 
 
 
5
 
6
  app = FastAPI()
7
 
8
+ pipe_ocr = pipeline("text2text-generation", model="naver-clova-ocr/bros-base-uncased")
 
 
 
 
 
9
 
10
  app.mount("/", StaticFiles(directory="static", html=True), name="static")
11
 
12
  @app.get("/")
13
  def index() -> FileResponse:
14
  return FileResponse(path="/app/static/index.html", media_type="text/html")
15
+
16
+ @app.get("/ocr")
17
+ def ocr(input):
18
+ result = pipe_ocr(input)
19
+ print(result)
static/index.html CHANGED
@@ -25,7 +25,6 @@
25
  <input
26
  id="text-gen-input"
27
  type="text"
28
- value="English: Translate There are many ducks. German:"
29
  />
30
  <button id="text-gen-submit">Submit</button>
31
  <p class="text-gen-output"></p>
 
25
  <input
26
  id="text-gen-input"
27
  type="text"
 
28
  />
29
  <button id="text-gen-submit">Submit</button>
30
  <p class="text-gen-output"></p>
static/script.js CHANGED
@@ -1,7 +1,7 @@
1
  const textGenForm = document.querySelector('.text-gen-form');
2
 
3
  const translateText = async (text) => {
4
- const inferResponse = await fetch(`infer_t5?input=${text}`);
5
  const inferJson = await inferResponse.json();
6
 
7
  return inferJson.output;
 
1
  const textGenForm = document.querySelector('.text-gen-form');
2
 
3
  const translateText = async (text) => {
4
+ const inferResponse = await fetch(`ocr?input=${text}`);
5
  const inferJson = await inferResponse.json();
6
 
7
  return inferJson.output;