Spaces:
Sleeping
Sleeping
Commit
·
6d1eec9
1
Parent(s):
c376da9
Update app.py
Browse files
app.py
CHANGED
@@ -1,5 +1,7 @@
|
|
1 |
import streamlit as st
|
2 |
from PIL import Image
|
|
|
|
|
3 |
|
4 |
|
5 |
# Create a file uploader widget
|
@@ -10,6 +12,10 @@ if file is not None:
|
|
10 |
|
11 |
# Read the image data
|
12 |
image = Image.open(file)
|
|
|
|
|
|
|
|
|
13 |
|
14 |
# Display the image
|
15 |
st.image(image, caption='Uploaded Image', use_column_width=True)
|
|
|
1 |
import streamlit as st
|
2 |
from PIL import Image
|
3 |
+
from transformers import TrOCRProcessor, VisionEncoderDecoderModel
|
4 |
+
|
5 |
|
6 |
|
7 |
# Create a file uploader widget
|
|
|
12 |
|
13 |
# Read the image data
|
14 |
image = Image.open(file)
|
15 |
+
|
16 |
+
processor = TrOCRProcessor.from_pretrained('microsoft/trocr-small-handwritten')
|
17 |
+
model = VisionEncoderDecoderModel.from_pretrained('microsoft/trocr-small-handwritten')
|
18 |
+
pixel_values = processor(images=image, return_tensors="pt").pixel_values
|
19 |
|
20 |
# Display the image
|
21 |
st.image(image, caption='Uploaded Image', use_column_width=True)
|