This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # RunPod Full Setup - OCR Server (8765) + NSFW Server (8877) | |
| # Usage: curl -sSL <gist_url>/raw | bash | |
| # Saves to /workspace for persistence across restarts | |
| set -e | |
| cd /workspace | |
| echo "============================================" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| """ | |
| GPU OCR Server - FastAPI + EasyOCR | |
| Run on a GPU server (RTX 3090, 4090, etc.) to provide fast OCR processing. | |
| Usage: | |
| pip install fastapi uvicorn easyocr pillow python-multipart | |
| python server.py | |
| The server will listen on port 8765 by default. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import io, time | |
| from typing import Optional | |
| import easyocr, numpy as np | |
| from PIL import Image | |
| from fastapi import FastAPI, File, UploadFile, HTTPException | |
| from fastapi.middleware.cors import CORSMiddleware | |
| import uvicorn | |
| app = FastAPI(title="GPU OCR Server") | |
| app.add_middleware(CORSMiddleware, allow_origins=["*"], allow_credentials=True, allow_methods=["*"], allow_headers=["*"]) | |
| ocr_reader: Optional[easyocr.Reader] = None |