Spaces:
Runtime error
Runtime error
TomatoFT
commited on
Commit
•
47f08a4
1
Parent(s):
899f25a
Fix: Debuging in the app code
Browse files
app.py
CHANGED
@@ -1,48 +1,24 @@
|
|
1 |
import gradio as gr
|
2 |
-
import
|
3 |
-
import numpy as np
|
4 |
-
from PIL import Image, ImageDraw, ImageFont
|
5 |
-
from translate import Translator
|
6 |
|
7 |
-
def translate_text(text, src_lang='en', dest_lang='vi'):
|
8 |
-
translator = Translator(to_lang=dest_lang, from_lang=src_lang)
|
9 |
-
translation = translator.translate(text)
|
10 |
-
return translation
|
11 |
|
12 |
-
def
|
13 |
-
|
14 |
-
image = Image.open(image).convert('RGB')
|
15 |
-
image.save('temp.jpg')
|
16 |
|
17 |
-
# Sample code to perform OCR and draw translated text (replace with your logic)
|
18 |
-
# Simulated results for demonstration purposes
|
19 |
-
result = [
|
20 |
-
([(100, 100), (200, 100), (200, 200), (100, 200)], ("Hello, how are you?", 0.95))
|
21 |
-
]
|
22 |
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
# Save the processed image
|
35 |
-
processed_image_path = 'processed_image.jpg'
|
36 |
-
image.save(processed_image_path)
|
37 |
-
return processed_image_path
|
38 |
-
|
39 |
-
iface = gr.Interface(
|
40 |
-
fn=process_image,
|
41 |
-
inputs=gr.Image(type="filepath", label="Upload Image"),
|
42 |
-
outputs="image",
|
43 |
-
title="OCR Translation App",
|
44 |
-
description="Upload an image and see the processed image with translated text."
|
45 |
)
|
46 |
|
47 |
if __name__ == "__main__":
|
48 |
-
|
|
|
|
1 |
import gradio as gr
|
2 |
+
import os
|
|
|
|
|
|
|
3 |
|
|
|
|
|
|
|
|
|
4 |
|
5 |
+
def image_mod(image):
|
6 |
+
return image.rotate(45)
|
|
|
|
|
7 |
|
|
|
|
|
|
|
|
|
|
|
8 |
|
9 |
+
demo = gr.Interface(
|
10 |
+
image_mod,
|
11 |
+
gr.Image(type="pil"),
|
12 |
+
"image",
|
13 |
+
flagging_options=["blurry", "incorrect", "other"],
|
14 |
+
examples=[
|
15 |
+
os.path.join(os.path.dirname(__file__), "images/cheetah1.jpg"),
|
16 |
+
os.path.join(os.path.dirname(__file__), "images/lion.jpg"),
|
17 |
+
os.path.join(os.path.dirname(__file__), "images/logo.png"),
|
18 |
+
os.path.join(os.path.dirname(__file__), "images/tower.jpg"),
|
19 |
+
],
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
20 |
)
|
21 |
|
22 |
if __name__ == "__main__":
|
23 |
+
demo.launch()
|
24 |
+
|