Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -85,14 +85,14 @@ Generate OCR
|
|
| 85 |
def process(input_type, gr_img, lang):
|
| 86 |
|
| 87 |
if isinstance(gr_img, np.ndarray):
|
| 88 |
-
|
| 89 |
-
|
| 90 |
-
|
| 91 |
-
|
| 92 |
-
|
| 93 |
|
| 94 |
image = Image.open(temp_path)
|
| 95 |
-
image = file
|
| 96 |
extracted_text = ocr(image, lang)
|
| 97 |
return extracted_text
|
| 98 |
|
|
|
|
| 85 |
def process(input_type, gr_img, lang):
|
| 86 |
|
| 87 |
if isinstance(gr_img, np.ndarray):
|
| 88 |
+
# Create a temporary file to save the image
|
| 89 |
+
with tempfile.NamedTemporaryFile(suffix=".png", delete=False) as temp_file:
|
| 90 |
+
temp_path = temp_file.name
|
| 91 |
+
# Save the NumPy array as an image file
|
| 92 |
+
Image.fromarray(gr_img).save(temp_path)
|
| 93 |
|
| 94 |
image = Image.open(temp_path)
|
| 95 |
+
# image = file
|
| 96 |
extracted_text = ocr(image, lang)
|
| 97 |
return extracted_text
|
| 98 |
|