Spaces:
Runtime error
Runtime error
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from fastapi import FastAPI
|
2 |
+
from transformers import pipeline
|
3 |
+
from pydantic import BaseModel
|
4 |
+
|
5 |
+
app = FastAPI()
|
6 |
+
|
7 |
+
class TransliterationRequest(BaseModel):
|
8 |
+
text: str
|
9 |
+
|
10 |
+
# Load model
|
11 |
+
model_name = "your-username/banglish-bengali-transliteration"
|
12 |
+
transliterator = pipeline("text2text-generation", model=model_name)
|
13 |
+
|
14 |
+
@app.post("/transliterate")
|
15 |
+
async def transliterate(request: TransliterationRequest):
|
16 |
+
result = transliterator(request.text, max_length=128, num_beams=5)
|
17 |
+
return {"bengali_text": result[0]["generated_text"]}
|