prithivMLmods commited on
Commit
c56a94b
·
verified ·
1 Parent(s): 1dddfea

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -1
app.py CHANGED
@@ -78,6 +78,26 @@ model_i = Qwen2_5_VLForConditionalGeneration.from_pretrained(
78
  MODEL_ID_I, trust_remote_code=True, torch_dtype=torch.float16
79
  ).to(device).eval()
80
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
81
  # --- Utility Functions ---
82
  def layoutjson2md(layout_data: List[Dict]) -> str:
83
  """Converts the structured JSON from Layout Analysis into formatted Markdown."""
@@ -148,7 +168,9 @@ def process_document_stream(model_name: str, task_choice: str, image: Image.Imag
148
  buffer += new_text
149
  buffer = buffer.replace("<|im_end|>", "")
150
  time.sleep(0.01)
151
- yield buffer, "⏳ Processing...", {"status": "streaming"}
 
 
152
 
153
  # 5. Post-process the final buffer based on the selected task
154
  if task_choice == "Content Extraction":
 
78
  MODEL_ID_I, trust_remote_code=True, torch_dtype=torch.float16
79
  ).to(device).eval()
80
 
81
+ def progress_bar_html(label: str) -> str:
82
+ """
83
+ Returns an HTML snippet for a thin progress bar with a label.
84
+ The progress bar is styled as a dark red animated bar.
85
+ """
86
+ return f'''
87
+ <div style="display: flex; align-items: center;">
88
+ <span style="margin-right: 10px; font-size: 14px;">{label}</span>
89
+ <div style="width: 110px; height: 5px; background-color: #AFEEEE; border-radius: 2px; overflow: hidden;">
90
+ <div style="width: 100%; height: 100%; background-color: #00FFFF; animation: loading 1.5s linear infinite;"></div>
91
+ </div>
92
+ </div>
93
+ <style>
94
+ @keyframes loading {{
95
+ 0% {{ transform: translateX(-100%); }}
96
+ 100% {{ transform: translateX(100%); }}
97
+ }}
98
+ </style>
99
+ '''
100
+
101
  # --- Utility Functions ---
102
  def layoutjson2md(layout_data: List[Dict]) -> str:
103
  """Converts the structured JSON from Layout Analysis into formatted Markdown."""
 
168
  buffer += new_text
169
  buffer = buffer.replace("<|im_end|>", "")
170
  time.sleep(0.01)
171
+ yield buffer
172
+ yield progress_bar_html("streaming markdown") # Show progress bar first
173
+ #yield buffer , "⏳ Processing...", {"status": "streaming"}
174
 
175
  # 5. Post-process the final buffer based on the selected task
176
  if task_choice == "Content Extraction":