Spaces:
Sleeping
Sleeping
Upload app.py
Browse files
app.py
CHANGED
|
@@ -199,11 +199,10 @@ def stream_ocr(image):
|
|
| 199 |
inputs,
|
| 200 |
streamer=streamer,
|
| 201 |
max_new_tokens=2048,
|
| 202 |
-
repetition_penalty=1.
|
| 203 |
-
|
| 204 |
-
|
| 205 |
-
|
| 206 |
-
top_p=0.95,
|
| 207 |
use_cache=True
|
| 208 |
)
|
| 209 |
|
|
@@ -236,8 +235,8 @@ example_images = []
|
|
| 236 |
data_dir = os.path.join(os.path.dirname(__file__), 'data')
|
| 237 |
if os.path.exists(data_dir):
|
| 238 |
valid_exts = {".jpg", ".jpeg", ".png", ".bmp", ".webp"}
|
| 239 |
-
#
|
| 240 |
-
example_images = [[os.path.join(
|
| 241 |
if os.path.splitext(f)[1].lower() in valid_exts]
|
| 242 |
|
| 243 |
# --- Aesthetic Custom CSS ---
|
|
|
|
| 199 |
inputs,
|
| 200 |
streamer=streamer,
|
| 201 |
max_new_tokens=2048,
|
| 202 |
+
repetition_penalty=1.1, # Reduced from 1.2 to slightly speed up
|
| 203 |
+
do_sample=False, # GREEDY DECODING: Much faster than sampling on CPU
|
| 204 |
+
# temperature=0.2, # Not used in greedy
|
| 205 |
+
# top_p=0.95, # Not used in greedy
|
|
|
|
| 206 |
use_cache=True
|
| 207 |
)
|
| 208 |
|
|
|
|
| 235 |
data_dir = os.path.join(os.path.dirname(__file__), 'data')
|
| 236 |
if os.path.exists(data_dir):
|
| 237 |
valid_exts = {".jpg", ".jpeg", ".png", ".bmp", ".webp"}
|
| 238 |
+
# Use Relative Paths for Gradio compatibility
|
| 239 |
+
example_images = [[os.path.join("data", f)] for f in os.listdir(data_dir)
|
| 240 |
if os.path.splitext(f)[1].lower() in valid_exts]
|
| 241 |
|
| 242 |
# --- Aesthetic Custom CSS ---
|