ianluo commited on
Commit
3e805bb
1 Parent(s): 5a9777a
Files changed (1) hide show
  1. main.py +9 -2
main.py CHANGED
@@ -5,8 +5,15 @@ from transformers import pipeline
5
 
6
  app = FastAPI()
7
 
8
- pipe_ocr = pipeline("text0recognition", model="naver-clova-ocr/bros-base-uncased")
9
 
 
 
 
 
 
 
 
 
10
  app.mount("/", StaticFiles(directory="static", html=True), name="static")
11
 
12
  @app.get("/")
@@ -15,5 +22,5 @@ def index() -> FileResponse:
15
 
16
  @app.get("/ocr")
17
  def ocr(input):
18
- result = pipe_ocr(input)
19
  print(result)
 
5
 
6
  app = FastAPI()
7
 
 
8
 
9
+ from transformers import pipeline
10
+
11
+ image_to_text = pipeline("image-to-text", model="nlpconnect/vit-gpt2-image-captioning")
12
+
13
+
14
+ # [{'generated_text': 'a soccer game with a player jumping to catch the ball '}]
15
+
16
+ model = AutoModelForSeq2SeqLM.from_pretrained("google/pix2struct-ocrvqa-large")
17
  app.mount("/", StaticFiles(directory="static", html=True), name="static")
18
 
19
  @app.get("/")
 
22
 
23
  @app.get("/ocr")
24
  def ocr(input):
25
+ result = image_to_text(input)
26
  print(result)