Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,7 +1,50 @@
|
|
1 |
#!/usr/bin/env python
|
2 |
# coding: utf-8
|
3 |
|
4 |
-
# In[
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
|
6 |
|
7 |
import gradio as gr
|
@@ -19,7 +62,7 @@ def ocr_image(image):
|
|
19 |
# Ensure the image is in RGB mode
|
20 |
image = image.convert('RGB')
|
21 |
# Perform OCR with Tesseract (supports both English and Hindi)
|
22 |
-
text = pytesseract.image_to_string(image, lang='eng')
|
23 |
return text
|
24 |
except Exception as e:
|
25 |
return f"OCR Error: {str(e)}"
|
|
|
1 |
#!/usr/bin/env python
|
2 |
# coding: utf-8
|
3 |
|
4 |
+
# In[ ]:
|
5 |
+
|
6 |
+
|
7 |
+
pip install tesseract pytesseract pillow
|
8 |
+
|
9 |
+
|
10 |
+
# In[ ]:
|
11 |
+
|
12 |
+
|
13 |
+
pip install transformers
|
14 |
+
|
15 |
+
|
16 |
+
# In[ ]:
|
17 |
+
|
18 |
+
|
19 |
+
pip install torch
|
20 |
+
|
21 |
+
|
22 |
+
# In[ ]:
|
23 |
+
|
24 |
+
|
25 |
+
pip install gradio
|
26 |
+
|
27 |
+
|
28 |
+
# In[ ]:
|
29 |
+
|
30 |
+
|
31 |
+
pip install streamlit
|
32 |
+
|
33 |
+
|
34 |
+
# In[ ]:
|
35 |
+
|
36 |
+
|
37 |
+
pip install pillow
|
38 |
+
|
39 |
+
|
40 |
+
# In[10]:
|
41 |
+
|
42 |
+
|
43 |
+
import pytesseract
|
44 |
+
pytesseract.pytesseract.tesseract_cmd = r'C:\Program Files\Tesseract-OCR\tesseract.exe'
|
45 |
+
|
46 |
+
|
47 |
+
# In[11]:
|
48 |
|
49 |
|
50 |
import gradio as gr
|
|
|
62 |
# Ensure the image is in RGB mode
|
63 |
image = image.convert('RGB')
|
64 |
# Perform OCR with Tesseract (supports both English and Hindi)
|
65 |
+
text = pytesseract.image_to_string(image, lang='eng+hin')
|
66 |
return text
|
67 |
except Exception as e:
|
68 |
return f"OCR Error: {str(e)}"
|