File size: 1,211 Bytes
7cf86f8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import numpy as np
from PIL import Image
import gradio as gr

from main import predict

def process_image(image):
	if image is not None:
		if not isinstance(image, np.ndarray):
			image = np.array(Image.open(image))
			print(image)

		translated_image = predict(image)
		return translated_image
	return None


with gr.Blocks() as demo:
	gr.Markdown(
		"""
		<div style="display: flex; align-items: center; flex-direction: row; justify-content: center; margin-bottom: 20px; text-align: center;">
			<a href="https://github.com/Detopall/manga-translator" target="_blank" rel="noopener noreferrer" style="text-decoration: none;">
				<h1 style="display: inline; margin-left: 10px; text-decoration: underline;">Manga Translator</h1>
			</a>
		</div>
		"""
	)

	with gr.Row():
		with gr.Column(scale=1):
			image_input = gr.Image()
			submit_button = gr.Button("Translate")
		with gr.Column(scale=1):
			image_output = gr.Image()

	submit_button.click(process_image, inputs=image_input, outputs=image_output)

	examples = gr.Examples(examples=[
		["./examples/ex1.jpg"],
		["./examples/ex2.jpg"],
		["./examples/ex3.jpg"],
		["./examples/ex4.jpg"],
	], inputs=image_input)

if __name__ == "__main__":
	demo.launch()