torr20 commited on
Commit
9f772ef
1 Parent(s): 92c97b4

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -0
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"]}