Spaces:
Running
on
Zero
Running
on
Zero
fixing
Browse files
app.py
CHANGED
@@ -2,7 +2,7 @@ import os
|
|
2 |
import warnings
|
3 |
import torch
|
4 |
import gc
|
5 |
-
from transformers import pipeline
|
6 |
from PIL import Image
|
7 |
import gradio as gr
|
8 |
from huggingface_hub import login
|
@@ -31,11 +31,7 @@ def load_pipeline():
|
|
31 |
"image-to-text",
|
32 |
model=hub_model_path,
|
33 |
device="cuda" if torch.cuda.is_available() else "cpu",
|
34 |
-
|
35 |
-
"torch_dtype": torch.bfloat16,
|
36 |
-
"load_in_4bit": True,
|
37 |
-
"trust_remote_code": True,
|
38 |
-
},
|
39 |
token=os.environ.get('HUGGING_FACE_HUB_TOKEN')
|
40 |
)
|
41 |
|
@@ -81,7 +77,6 @@ Only return the transcription in Thai language.""",
|
|
81 |
# Initialize application
|
82 |
print("กำลังเริ่มต้นแอปพลิเคชัน...")
|
83 |
if load_pipeline():
|
84 |
-
# Create Gradio interface
|
85 |
demo = gr.Interface(
|
86 |
fn=process_handwriting,
|
87 |
inputs=gr.Image(type="pil", label="อัพโหลดรูปลายมือเขียนภาษาไทย"),
|
|
|
2 |
import warnings
|
3 |
import torch
|
4 |
import gc
|
5 |
+
from transformers import pipeline
|
6 |
from PIL import Image
|
7 |
import gradio as gr
|
8 |
from huggingface_hub import login
|
|
|
31 |
"image-to-text",
|
32 |
model=hub_model_path,
|
33 |
device="cuda" if torch.cuda.is_available() else "cpu",
|
34 |
+
trust_remote_code=True,
|
|
|
|
|
|
|
|
|
35 |
token=os.environ.get('HUGGING_FACE_HUB_TOKEN')
|
36 |
)
|
37 |
|
|
|
77 |
# Initialize application
|
78 |
print("กำลังเริ่มต้นแอปพลิเคชัน...")
|
79 |
if load_pipeline():
|
|
|
80 |
demo = gr.Interface(
|
81 |
fn=process_handwriting,
|
82 |
inputs=gr.Image(type="pil", label="อัพโหลดรูปลายมือเขียนภาษาไทย"),
|