CoolFace
Apppublic

ek-developers/ocr-frontend

sourceHugging Faceupdated 7mo agoView on Hugging Face
0likes
App README

๐Ÿ–ผ๏ธ DeepSeek OCR โ€” Frontend

A clean, professional Gradio frontend for the DeepSeek OCR API. Upload any image, write a custom prompt, and extract text in seconds โ€” no setup required.

This Space is a frontend only. All OCR processing is handled by the backend API Space powered by DeepSeek-OCR via Ollama.

๐Ÿ”— Related Spaces

SpaceRoleURL
This SpaceGradio UI frontendek-developers/ocr-frontend
Backend APIFastAPI + DeepSeek-OCRek-developers/my-ocr-api

โœจ Features

  • โ€”Image upload โ€” drag and drop, click to browse, or paste from clipboard
  • โ€”Custom prompts โ€” guide the model with natural language instructions
  • โ€”Auto-run on upload โ€” OCR triggers automatically when an image is dropped in
  • โ€”Copy to clipboard โ€” one-click copy of extracted text with confirmation feedback
  • โ€”Example prompts โ€” pre-built prompts for common use cases
  • โ€”Live API status โ€” shows backend connection and endpoint URL
  • โ€”Responsive layout โ€” two-column design with input on the left, output on the right

๐Ÿ–ฅ๏ธ Interface Overview

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚              DeepSeek OCR                           โ”‚
โ”‚      Powered by DeepSeek ยท Ollama                   โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚  01 ยท INPUT        โ”‚  02 ยท EXTRACTED TEXT           โ”‚
โ”‚                    โ”‚                                 โ”‚
โ”‚  [ Image Upload ]  โ”‚  โ— API CONNECTED               โ”‚
โ”‚                    โ”‚                                 โ”‚
โ”‚  [ Prompt Input ]  โ”‚  [ Result Textbox         ]    โ”‚
โ”‚                    โ”‚                                 โ”‚
โ”‚  [โ–ถ RUN] [โœ• CLEAR] โ”‚  [ โŽ˜ COPY TEXT ]               โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚  Example Prompts                                    โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

๐Ÿš€ Usage

Step 1 โ€” Upload an image

Drag and drop an image onto the upload panel, click to browse your files, or paste directly from clipboard. Supported formats: JPG, PNG, WEBP, and other common image types.

Step 2 โ€” Set your prompt

The default prompt is Free OCR. which extracts all visible text. You can customize it to get more targeted results:

PromptWhat it does
Free OCR.Extract all visible text
Extract all menu items and prices.Structured menu extraction
Extract only the grand total.Receipt total only
List all ingredients on the label.Product label parsing
Read the text on this sign.Signage and banners
Extract the table contents.Tabular data

Step 3 โ€” Run OCR

Click โ–ถ RUN OCR or simply upload an image โ€” OCR runs automatically on upload.

Step 4 โ€” Copy the result

Click โŽ˜ COPY TEXT to copy the extracted text to your clipboard. A green confirmation message appears for 2 seconds.


โš™๏ธ Configuration

Changing the backend API URL

By default the frontend points to:

https://ek-developers-my-ocr-api.hf.space/ocr

To point it at a different backend, set the OCR_API_URL environment variable in your Space settings:

  1. 1.Go to your Space โ†’ Settings โ†’ Variables and secrets
  2. 2.Add a new variable:
  3. 3.Name: OCR_API_URL
  4. 4.Value: https://your-backend-space.hf.space/ocr

๐Ÿ“ Project Structure

โ”œโ”€โ”€ app.py           # Gradio UI and API call logic
โ”œโ”€โ”€ requirements.txt # Python dependencies
โ””โ”€โ”€ README.md        # Documentation

app.py โ€” key sections

SectionDescription
API_URLBackend endpoint, overridable via env var
run_ocr()Sends image + prompt to the FastAPI backend, handles errors
cssCustom styling โ€” IBM Plex fonts, blue accent palette
gr.Blocks(...)UI layout โ€” two-column input/output panels
copy_btn.click(...)JavaScript clipboard handler
image_input.upload(...)Auto-triggers OCR when image is uploaded

๐Ÿ› ๏ธ Local Development

Prerequisites

  • โ€”Python 3.10+
  • โ€”The backend API running (locally or on HF)

Setup

bash
# Clone the Space
git clone https://huggingface.co/spaces/YOUR_USERNAME/ocr-frontend
cd ocr-frontend

# Install dependencies
pip install -r requirements.txt

# Optional: point at a local backend
export OCR_API_URL=http://localhost:7860/ocr

# Run
python app.py

The app will be available at http://localhost:7860.


๐Ÿ“ฆ Dependencies

gradio>=6.6.0
requests

โš ๏ธ Notes

Cold starts โ€” the backend Space sleeps after ~15 minutes of inactivity on the free tier. The first request after inactivity may take 1โ€“2 minutes while the model reloads. The frontend will show a timeout message โ€” simply wait 30 seconds and try again.

Image quality โ€” OCR accuracy depends on image clarity. For best results:

  • โ€”Use high-resolution images (300 DPI or above for documents)
  • โ€”Ensure text is not skewed or heavily shadowed
  • โ€”Avoid images with very low contrast between text and background

Clipboard permissions โ€” the copy button uses the browser's native clipboard API. If it does not work, ensure your browser has clipboard permissions enabled for the page.


๐Ÿ“„ License

MIT License โ€” free to use, modify, and deploy.