Spaces:
Running
on
Zero
Running
on
Zero
Upload app.py
Browse files
app.py
CHANGED
@@ -35,6 +35,8 @@ MAX_INPUT_TOKEN_LENGTH = int(os.getenv("MAX_INPUT_TOKEN_LENGTH", "4096"))
|
|
35 |
|
36 |
device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
|
37 |
|
|
|
|
|
38 |
# Load Adun/typhoon_ocr-7B-v1.4
|
39 |
MODEL_ID_M = "Adun/typhoon_ocr-7B-v1.4"
|
40 |
processor_m = AutoProcessor.from_pretrained(MODEL_ID_M, trust_remote_code=True)
|
@@ -103,14 +105,14 @@ def downsample_video(video_path):
|
|
103 |
|
104 |
@spaces.GPU
|
105 |
def generate_image(model_name: str, text: str, image: Image.Image,
|
106 |
-
max_new_tokens: int =
|
107 |
-
temperature: float = 0.
|
108 |
top_p: float = 0.9,
|
109 |
top_k: int = 50,
|
110 |
repetition_penalty: float = 1.2):
|
111 |
"""Generate responses for image input using the selected model."""
|
112 |
# Model selection
|
113 |
-
if model_name == "
|
114 |
processor = processor_m
|
115 |
model = model_m
|
116 |
# elif model_name == "MonkeyOCR-Recognition":
|
@@ -196,8 +198,9 @@ def generate_video(model_name: str, text: str, video_path: str,
|
|
196 |
top_k: int = 50,
|
197 |
repetition_penalty: float = 1.2):
|
198 |
"""Generate responses for video input using the selected model."""
|
|
|
199 |
# Model selection
|
200 |
-
if model_name == "
|
201 |
processor = processor_m
|
202 |
model = model_m
|
203 |
# elif model_name == "MonkeyOCR-Recognition":
|
@@ -333,9 +336,9 @@ with gr.Blocks(css=css, theme="bethecloud/storj_theme") as demo:
|
|
333 |
with gr.Column():
|
334 |
output = gr.Textbox(label="Output", interactive=False, lines=3, scale=2)
|
335 |
model_choice = gr.Radio(
|
336 |
-
choices=["
|
337 |
label="Select Model",
|
338 |
-
value="
|
339 |
)
|
340 |
|
341 |
gr.Markdown("**Model Info 💻** | [Report Bug](https://huggingface.co/spaces/Adun/typhoon-ocr-finetuned-v1.x/discussions)")
|
|
|
35 |
|
36 |
device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
|
37 |
|
38 |
+
model_name = "typhoon_ocr-7B-v1.4(finetuned)"
|
39 |
+
|
40 |
# Load Adun/typhoon_ocr-7B-v1.4
|
41 |
MODEL_ID_M = "Adun/typhoon_ocr-7B-v1.4"
|
42 |
processor_m = AutoProcessor.from_pretrained(MODEL_ID_M, trust_remote_code=True)
|
|
|
105 |
|
106 |
@spaces.GPU
|
107 |
def generate_image(model_name: str, text: str, image: Image.Image,
|
108 |
+
max_new_tokens: int = 2048,
|
109 |
+
temperature: float = 0.1,
|
110 |
top_p: float = 0.9,
|
111 |
top_k: int = 50,
|
112 |
repetition_penalty: float = 1.2):
|
113 |
"""Generate responses for image input using the selected model."""
|
114 |
# Model selection
|
115 |
+
if model_name == "typhoon_ocr-7B-v1.4(finetuned)":
|
116 |
processor = processor_m
|
117 |
model = model_m
|
118 |
# elif model_name == "MonkeyOCR-Recognition":
|
|
|
198 |
top_k: int = 50,
|
199 |
repetition_penalty: float = 1.2):
|
200 |
"""Generate responses for video input using the selected model."""
|
201 |
+
|
202 |
# Model selection
|
203 |
+
if model_name == "typhoon_ocr-7B-v1.4(finetuned)":
|
204 |
processor = processor_m
|
205 |
model = model_m
|
206 |
# elif model_name == "MonkeyOCR-Recognition":
|
|
|
336 |
with gr.Column():
|
337 |
output = gr.Textbox(label="Output", interactive=False, lines=3, scale=2)
|
338 |
model_choice = gr.Radio(
|
339 |
+
choices=["typhoon_ocr-7B-v1.4(finetuned)", "Typhoon-OCR-7B"],
|
340 |
label="Select Model",
|
341 |
+
value="typhoon_ocr-7B-v1.4(finetuned)"
|
342 |
)
|
343 |
|
344 |
gr.Markdown("**Model Info 💻** | [Report Bug](https://huggingface.co/spaces/Adun/typhoon-ocr-finetuned-v1.x/discussions)")
|