Spaces:
Runtime error
Runtime error
Upload 7 files
Browse files
.DS_Store
ADDED
|
Binary file (6.15 kB). View file
|
|
|
README.md
CHANGED
|
@@ -1,10 +1,10 @@
|
|
| 1 |
---
|
| 2 |
-
title:
|
| 3 |
-
emoji:
|
| 4 |
-
colorFrom:
|
| 5 |
-
colorTo:
|
| 6 |
sdk: gradio
|
| 7 |
-
sdk_version: 4.
|
| 8 |
app_file: app.py
|
| 9 |
pinned: false
|
| 10 |
---
|
|
|
|
| 1 |
---
|
| 2 |
+
title: P9OcrAiV2BridSpace
|
| 3 |
+
emoji: 馃憗
|
| 4 |
+
colorFrom: blue
|
| 5 |
+
colorTo: red
|
| 6 |
sdk: gradio
|
| 7 |
+
sdk_version: 4.23.0
|
| 8 |
app_file: app.py
|
| 9 |
pinned: false
|
| 10 |
---
|
app.py
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
import torch
|
| 3 |
+
from PIL import Image
|
| 4 |
+
|
| 5 |
+
from donut import DonutModel
|
| 6 |
+
|
| 7 |
+
def demo_process(input_img):
|
| 8 |
+
global pretrained_model, task_prompt, task_name
|
| 9 |
+
# input_img = Image.fromarray(input_img)
|
| 10 |
+
output = pretrained_model.inference(image=input_img, prompt=task_prompt)["predictions"][0]
|
| 11 |
+
return output
|
| 12 |
+
task_name = "preparedFinetuneData_Bird"
|
| 13 |
+
# task_name = "cord-v2"
|
| 14 |
+
task_prompt = f"<s_{task_name}>"
|
| 15 |
+
|
| 16 |
+
image = Image.open("inv87.jpg")
|
| 17 |
+
image.save("inv87.jpg")
|
| 18 |
+
image = Image.open("inv17.jpg")
|
| 19 |
+
image.save("inv17.jpg")
|
| 20 |
+
|
| 21 |
+
PATH = 'epochs30_base_on_donut_base/'
|
| 22 |
+
pretrained_model = DonutModel.from_pretrained("Goodarc/TomTestModel2024043001",
|
| 23 |
+
ignore_mismatched_sizes=True)
|
| 24 |
+
pretrained_model.eval()
|
| 25 |
+
|
| 26 |
+
demo = gr.Interface(
|
| 27 |
+
fn=demo_process,
|
| 28 |
+
inputs= gr.Image(type="pil"),
|
| 29 |
+
outputs="json",
|
| 30 |
+
title=f"Goodarc p9 for `{task_name}` task, epochs30",
|
| 31 |
+
description="""Goodarc p9 v2 瑷撶反.
|
| 32 |
+
""",
|
| 33 |
+
examples=[["inv87.jpg"], ["inv17.jpg"]],
|
| 34 |
+
cache_examples=False,
|
| 35 |
+
)
|
| 36 |
+
demo.launch()
|
inv17.jpg
ADDED
|
inv87.jpg
ADDED
|
requirements.txt
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
torch
|
| 2 |
+
donut-python
|
| 3 |
+
gradio
|
| 4 |
+
transformers==4.25.1
|
| 5 |
+
timm==0.5.4
|
| 6 |
+
pytorch-lightning==1.6.4
|