musadac commited on
Commit
5ead04d
1 Parent(s): 997c58a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -3
app.py CHANGED
@@ -87,7 +87,7 @@ templates = Jinja2Templates(directory="templates")
87
  import os
88
  huggingface_token = os.environ.get("HUGGINGFACE_TOKEN")
89
  # Download and load the model
90
- model2 = VisionEncoderDecoderModel.from_pretrained("musadac/vilanocr-single-urdu",use_auth_token=huggingface_token).to(device)
91
 
92
 
93
  @app.get("/", response_class=HTMLResponse)
@@ -98,13 +98,13 @@ async def root():
98
  async def upload_image(image: UploadFile = File(...)):
99
  # Preprocess image
100
  img = Image.open(image.file).convert("RGB")
101
- pixel_values = processortext(img.convert("RGB"), return_tensors="pt").pixel_values
102
 
103
  # Run the model
104
  with torch.no_grad():
105
  generated_ids = model2.generate(img_tensor)
106
 
107
  # Extract OCR result
108
- result = processortext.batch_decode(generated_ids, skip_special_tokens=True)[0]
109
 
110
  return {"result": result}
 
87
  import os
88
  huggingface_token = os.environ.get("HUGGINGFACE_TOKEN")
89
  # Download and load the model
90
+ model2 = VisionEncoderDecoderModel.from_pretrained("musadac/vilanocr-single-urdu",use_auth_token=huggingface_token)
91
 
92
 
93
  @app.get("/", response_class=HTMLResponse)
 
98
  async def upload_image(image: UploadFile = File(...)):
99
  # Preprocess image
100
  img = Image.open(image.file).convert("RGB")
101
+ pixel_values = processortext2(img.convert("RGB"), return_tensors="pt").pixel_values
102
 
103
  # Run the model
104
  with torch.no_grad():
105
  generated_ids = model2.generate(img_tensor)
106
 
107
  # Extract OCR result
108
+ result = processortext2.batch_decode(generated_ids, skip_special_tokens=True)[0]
109
 
110
  return {"result": result}