Spaces:
Runtime error
Runtime error
CaesarCloudSync commited on
Commit ·
4915e38
1
Parent(s): c9e80bb
CaesarAI Handwriting
Browse files- CaesarHandwriting/caesarhandwriting.py +1 -1
- main.py +4 -3
CaesarHandwriting/caesarhandwriting.py
CHANGED
|
@@ -7,7 +7,7 @@ class CaesarHandWriting:
|
|
| 7 |
def __init__(self) -> None:
|
| 8 |
self.processor = TrOCRProcessor.from_pretrained('microsoft/trocr-large-handwritten')
|
| 9 |
self.model = VisionEncoderDecoderModel.from_pretrained('microsoft/trocr-large-handwritten')
|
| 10 |
-
def translate(self,url
|
| 11 |
image = Image.open(requests.get(url, stream=True).raw).convert("RGB")
|
| 12 |
pixel_values = self.processor(images=image, return_tensors="pt").pixel_values
|
| 13 |
generated_ids = self.model.generate(pixel_values)
|
|
|
|
| 7 |
def __init__(self) -> None:
|
| 8 |
self.processor = TrOCRProcessor.from_pretrained('microsoft/trocr-large-handwritten')
|
| 9 |
self.model = VisionEncoderDecoderModel.from_pretrained('microsoft/trocr-large-handwritten')
|
| 10 |
+
def translate(self,url):
|
| 11 |
image = Image.open(requests.get(url, stream=True).raw).convert("RGB")
|
| 12 |
pixel_values = self.processor(images=image, return_tensors="pt").pixel_values
|
| 13 |
generated_ids = self.model.generate(pixel_values)
|
main.py
CHANGED
|
@@ -57,9 +57,10 @@ def caesaraihome():
|
|
| 57 |
def caesarailogo():
|
| 58 |
return FileResponse(f"{CURRENT_DIR}/CaesarAILogo.png")
|
| 59 |
|
| 60 |
-
@app.
|
| 61 |
-
def caesaraihandwriting(
|
| 62 |
-
|
|
|
|
| 63 |
return {"message":text}
|
| 64 |
|
| 65 |
|
|
|
|
| 57 |
def caesarailogo():
|
| 58 |
return FileResponse(f"{CURRENT_DIR}/CaesarAILogo.png")
|
| 59 |
|
| 60 |
+
@app.post("/caesarhandwriting")
|
| 61 |
+
def caesaraihandwriting(urljson : CaesarAIHandwritingModel):
|
| 62 |
+
urljson = dict(urljson)
|
| 63 |
+
text = caesarhandwriting.translate(urljson["url"])
|
| 64 |
return {"message":text}
|
| 65 |
|
| 66 |
|