Spaces:
Running
Running
added device config for ViT
Browse files
IndicPhotoOCR/ocr.py
CHANGED
@@ -109,7 +109,7 @@ class OCR:
|
|
109 |
# Predict script language, here we assume "hindi" as the model name
|
110 |
if self.verbose:
|
111 |
print("Identifying script for the cropped area...")
|
112 |
-
script_lang = self.identifier.identify(cropped_path, "hindi") # Use "hindi" as the model name
|
113 |
# print(script_lang)
|
114 |
|
115 |
# Clean up temporary file
|
|
|
109 |
# Predict script language, here we assume "hindi" as the model name
|
110 |
if self.verbose:
|
111 |
print("Identifying script for the cropped area...")
|
112 |
+
script_lang = self.identifier.identify(cropped_path, "hindi", self.device) # Use "hindi" as the model name
|
113 |
# print(script_lang)
|
114 |
|
115 |
# Clean up temporary file
|
IndicPhotoOCR/script_identification/vit/vit_infer.py
CHANGED
@@ -135,11 +135,11 @@ class VIT_identifier:
|
|
135 |
|
136 |
|
137 |
|
138 |
-
def identify(self, image_path,model_name):
|
139 |
model_path = self.ensure_model(model_name)
|
140 |
|
141 |
vit = ViTForImageClassification.from_pretrained(model_path)
|
142 |
-
model= pipeline('image-classification', model=vit, feature_extractor=processor,device=
|
143 |
|
144 |
if image_path.endswith((".png", ".jpg", ".jpeg")):
|
145 |
|
|
|
135 |
|
136 |
|
137 |
|
138 |
+
def identify(self, image_path,model_name, device):
|
139 |
model_path = self.ensure_model(model_name)
|
140 |
|
141 |
vit = ViTForImageClassification.from_pretrained(model_path)
|
142 |
+
model= pipeline('image-classification', model=vit, feature_extractor=processor,device=device)
|
143 |
|
144 |
if image_path.endswith((".png", ".jpg", ".jpeg")):
|
145 |
|