Upadated with random example
Browse files
app.py
CHANGED
@@ -1,14 +1,14 @@
|
|
1 |
import re
|
2 |
import gradio as gr
|
3 |
|
4 |
-
|
5 |
from transformers import DonutProcessor, VisionEncoderDecoderModel
|
6 |
|
7 |
processor = DonutProcessor.from_pretrained("Travad98/donut-finetuned-sogc-trademarks-1883-2001")
|
8 |
model = VisionEncoderDecoderModel.from_pretrained("Travad98/donut-finetuned-sogc-trademarks-1883-2001")
|
9 |
|
10 |
-
|
11 |
-
|
12 |
|
13 |
def process_document(image):
|
14 |
# prepare encoder inputs
|
@@ -50,7 +50,7 @@ demo = gr.Interface(
|
|
50 |
description=description,
|
51 |
article=article,
|
52 |
enable_queue=True,
|
53 |
-
examples=[["
|
54 |
cache_examples=False)
|
55 |
|
56 |
demo.launch()
|
|
|
1 |
import re
|
2 |
import gradio as gr
|
3 |
|
4 |
+
import torch
|
5 |
from transformers import DonutProcessor, VisionEncoderDecoderModel
|
6 |
|
7 |
processor = DonutProcessor.from_pretrained("Travad98/donut-finetuned-sogc-trademarks-1883-2001")
|
8 |
model = VisionEncoderDecoderModel.from_pretrained("Travad98/donut-finetuned-sogc-trademarks-1883-2001")
|
9 |
|
10 |
+
device = "cuda" if torch.cuda.is_available() else "cpu"
|
11 |
+
model.to(device)
|
12 |
|
13 |
def process_document(image):
|
14 |
# prepare encoder inputs
|
|
|
50 |
description=description,
|
51 |
article=article,
|
52 |
enable_queue=True,
|
53 |
+
examples=[["sha-001_1883_1__21_d-0-6.jpg"]],
|
54 |
cache_examples=False)
|
55 |
|
56 |
demo.launch()
|