raviix46 commited on
Commit
33007e5
·
verified ·
1 Parent(s): 8c9a298

Update tabs/image_ocr_llm.py

Browse files
Files changed (1) hide show
  1. tabs/image_ocr_llm.py +1 -21
tabs/image_ocr_llm.py CHANGED
@@ -1,25 +1,5 @@
1
  import gradio as gr
2
- import requests
3
- import io
4
-
5
- def extract_text_from_space(image):
6
- api_url = "https://huggingface.co/spaces/Hammedalmodel/handwritten_to_text/api/predict"
7
-
8
- image_bytes = io.BytesIO()
9
- image.save(image_bytes, format="PNG")
10
- image_bytes.seek(0)
11
-
12
- files = {
13
- "data": ("image.png", image_bytes, "image/png")
14
- }
15
-
16
- try:
17
- response = requests.post(api_url, files=files)
18
- response.raise_for_status()
19
- result = response.json()
20
- return result["data"][0] if "data" in result else "❌ Unexpected response format."
21
- except Exception as e:
22
- return f"❌ Error: {str(e)}"
23
 
24
  def image_ocr_llm_tab():
25
  with gr.Tab("📸 OCR (LLM)"):
 
1
  import gradio as gr
2
+ from components.llm_ocr_api import extract_text_from_space # 👈 Import from components
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
 
4
  def image_ocr_llm_tab():
5
  with gr.Tab("📸 OCR (LLM)"):