Spaces:
Sleeping
Sleeping
Deploy handwriting synthesis API
Browse files- Dockerfile +10 -0
- app/main.py +28 -0
- requirements.txt +4 -0
Dockerfile
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
FROM python:3.9-slim
|
2 |
+
|
3 |
+
WORKDIR /app
|
4 |
+
|
5 |
+
COPY requirements.txt .
|
6 |
+
RUN pip install --no-cache-dir -r requirements.txt
|
7 |
+
|
8 |
+
COPY . .
|
9 |
+
|
10 |
+
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "7860"]
|
app/main.py
ADDED
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from fastapi import FastAPI
|
2 |
+
from fastapi.middleware.cors import CORSMiddleware
|
3 |
+
from pydantic import BaseModel
|
4 |
+
import numpy as np
|
5 |
+
import tensorflow as tf
|
6 |
+
|
7 |
+
app = FastAPI()
|
8 |
+
|
9 |
+
app.add_middleware(
|
10 |
+
CORSMiddleware,
|
11 |
+
allow_origins=["*"],
|
12 |
+
allow_methods=["*"],
|
13 |
+
allow_headers=["*"],
|
14 |
+
)
|
15 |
+
|
16 |
+
class TextInput(BaseModel):
|
17 |
+
text: str
|
18 |
+
style: int = 0
|
19 |
+
|
20 |
+
@app.post("/generate")
|
21 |
+
async def generate_handwriting(input: TextInput):
|
22 |
+
# Load model and generate handwriting
|
23 |
+
# Placeholder implementation
|
24 |
+
return {"status": "success", "message": "Handwriting generation endpoint"}
|
25 |
+
|
26 |
+
if __name__ == "__main__":
|
27 |
+
import uvicorn
|
28 |
+
uvicorn.run(app, host="0.0.0.0", port=7860)
|
requirements.txt
ADDED
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
fastapi==0.109.2
|
2 |
+
uvicorn==0.27.0
|
3 |
+
numpy==1.26.4
|
4 |
+
tensorflow==2.15.0
|