Spaces:
Sleeping
Sleeping
Commit
·
492e4c6
1
Parent(s):
75d87b5
Update app.py
Browse files
app.py
CHANGED
|
@@ -16,10 +16,12 @@ if file is not None:
|
|
| 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)
|
| 22 |
|
| 23 |
# Print the shape of the image
|
| 24 |
-
st.write(f"
|
| 25 |
|
|
|
|
| 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 |
+
generated_ids = model.generate(pixel_values)
|
| 20 |
+
generated_text = processor.batch_decode(generated_ids, skip_special_tokens=True)[0]
|
| 21 |
|
| 22 |
# Display the image
|
| 23 |
st.image(image, caption='Uploaded Image', use_column_width=True)
|
| 24 |
|
| 25 |
# Print the shape of the image
|
| 26 |
+
st.write(f"Text: {generated_text}")
|
| 27 |
|