Update
Browse files
app.py
CHANGED
@@ -5,6 +5,7 @@ from paddleocr import PaddleOCR, draw_ocr
|
|
5 |
from PIL import Image
|
6 |
import gradio as gr
|
7 |
import torch
|
|
|
8 |
|
9 |
torch.hub.download_url_to_file('https://i.imgur.com/aqMBT0i.jpg', 'example.jpg')
|
10 |
|
@@ -15,7 +16,7 @@ EMPTY = ' ' # Better than '.' for printing
|
|
15 |
|
16 |
|
17 |
|
18 |
-
def solve(data
|
19 |
cycle = 0
|
20 |
sprite = 1 # middle position, we have pixels at 0 and 2
|
21 |
total = 0
|
@@ -51,9 +52,6 @@ def solve(data, part_2 = False):
|
|
51 |
|
52 |
# Bonus: make an image and then use OCR
|
53 |
# to extract the text.
|
54 |
-
from PIL import Image
|
55 |
-
import numpy as np
|
56 |
-
import matplotlib.pylab as plt
|
57 |
img = np.array(crt)
|
58 |
|
59 |
plt.imshow(img, cmap="binary")
|
@@ -72,21 +70,19 @@ def solve(data, part_2 = False):
|
|
72 |
font_path='simfang.ttf')
|
73 |
im_show = Image.fromarray(im_show)
|
74 |
im_show.save('result.jpg')
|
75 |
-
return 'result.jpg'
|
76 |
|
77 |
title = 'PaddleOCR'
|
78 |
-
description = '
|
79 |
-
article = "<p style='text-align: center'
|
80 |
-
|
81 |
-
css = ".output_image, .input_image {height: 40rem !important; width: 100% !important;}"
|
82 |
gr.Interface(
|
83 |
solve,
|
84 |
-
[gr.File(file_types='text', label='Input'),
|
85 |
-
gr.outputs.Image(type='file', label='Output')
|
86 |
title=title,
|
87 |
description=description,
|
88 |
article=article,
|
89 |
-
examples=examples,
|
90 |
css=css,
|
91 |
enable_queue=True
|
92 |
).launch(debug=True)
|
|
|
5 |
from PIL import Image
|
6 |
import gradio as gr
|
7 |
import torch
|
8 |
+
import matplotlib.pylab as plt
|
9 |
|
10 |
torch.hub.download_url_to_file('https://i.imgur.com/aqMBT0i.jpg', 'example.jpg')
|
11 |
|
|
|
16 |
|
17 |
|
18 |
|
19 |
+
def solve(data):
|
20 |
cycle = 0
|
21 |
sprite = 1 # middle position, we have pixels at 0 and 2
|
22 |
total = 0
|
|
|
52 |
|
53 |
# Bonus: make an image and then use OCR
|
54 |
# to extract the text.
|
|
|
|
|
|
|
55 |
img = np.array(crt)
|
56 |
|
57 |
plt.imshow(img, cmap="binary")
|
|
|
70 |
font_path='simfang.ttf')
|
71 |
im_show = Image.fromarray(im_show)
|
72 |
im_show.save('result.jpg')
|
73 |
+
return 'result.jpg'
|
74 |
|
75 |
title = 'PaddleOCR'
|
76 |
+
description = 'Day 10 2022 AoC using OCR!!!'
|
77 |
+
article = "<p style='text-align: center'>Day 10 2022 AoC using OCR!!!</p>"
|
78 |
+
css = ".output_image {height: 40rem !important; width: 100% !important;}"
|
|
|
79 |
gr.Interface(
|
80 |
solve,
|
81 |
+
[gr.File(file_types='text', label='Input')],
|
82 |
+
gr.outputs.Image(type='file', label='Output'),
|
83 |
title=title,
|
84 |
description=description,
|
85 |
article=article,
|
|
|
86 |
css=css,
|
87 |
enable_queue=True
|
88 |
).launch(debug=True)
|