Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -44,15 +44,15 @@ css = '''
|
|
| 44 |
h4 {
|
| 45 |
font-size: 1.5em;
|
| 46 |
}
|
| 47 |
-
|
| 48 |
code {
|
| 49 |
color: rgb(202 253 255);
|
| 50 |
}
|
| 51 |
-
|
| 52 |
code1{
|
| 53 |
color: #00b9c2;
|
| 54 |
}
|
| 55 |
-
|
| 56 |
/* Text Emphasis */
|
| 57 |
p, li {
|
| 58 |
text-align: justify;
|
|
@@ -100,7 +100,11 @@ css = '''
|
|
| 100 |
margin: 1.5em 0;
|
| 101 |
}
|
| 102 |
|
| 103 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 104 |
'''
|
| 105 |
|
| 106 |
|
|
@@ -117,46 +121,73 @@ with gr.Blocks(theme=gr.themes.Ocean(font=[gr.themes.GoogleFont("Noto Sans")]),
|
|
| 117 |
# gr.HTML(md.activity_diagram.format(activity_img_encoded))
|
| 118 |
# gr.HTML(md.component_diagram.format(component_img_encoded))
|
| 119 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 120 |
with gr.TabItem("⭐Translator"):
|
| 121 |
with gr.Row():
|
| 122 |
-
with gr.Column():
|
| 123 |
with gr.Row():
|
| 124 |
image_input = gr.Image(label="Upload Image")
|
| 125 |
|
| 126 |
with gr.Row():
|
| 127 |
clear_btn = gr.ClearButton()
|
| 128 |
-
submit_btn = gr.Button("Submit")
|
| 129 |
with gr.Column():
|
| 130 |
with gr.Row():
|
| 131 |
output_text = gr.Text(label="Output")
|
| 132 |
audio_out = gr.Audio(label="Streamed Audio")
|
| 133 |
lang_drop = gr.Dropdown(langs_dict, label="language", interactive=True)
|
| 134 |
-
translate_btn = gr.Button("Translate")
|
| 135 |
with gr.Row():
|
| 136 |
translated_txt = gr.Text(label="translated text")
|
| 137 |
translated_out = gr.Audio(label="Streamed Audio")
|
| 138 |
|
| 139 |
submit_btn.click(fn=ObjCharRec.ocr_with_paddle, inputs=image_input, outputs=[output_text, audio_out])
|
| 140 |
-
translate_btn.click(fn=translate_speak.translate_txt, inputs=[lang_drop, output_text],
|
| 141 |
-
outputs=[translated_txt, translated_out])
|
| 142 |
clear_btn.click(lambda: [None] * 5, outputs=[image_input, output_text, translated_txt, translated_out, audio_out])
|
| 143 |
|
| 144 |
-
with gr.TabItem("
|
| 145 |
-
gr.Markdown("Paddle OCR")
|
| 146 |
with gr.Row():
|
| 147 |
-
with gr.
|
| 148 |
-
|
| 149 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 150 |
clear_btn = gr.ClearButton()
|
| 151 |
-
|
| 152 |
-
|
|
|
|
|
|
|
|
|
|
| 153 |
|
| 154 |
-
|
| 155 |
-
|
|
|
|
| 156 |
|
| 157 |
gr.HTML(md.footer.format(github_logo_encoded, linkedin_logo_encoded, website_logo_encoded))
|
| 158 |
-
# gr.Markdown(md.footer.format(github_logo_encoded, linkedin_logo_encoded, website_logo_encoded))
|
| 159 |
|
| 160 |
|
| 161 |
if __name__ == "__main__":
|
| 162 |
-
main_interface.launch()
|
|
|
|
| 44 |
h4 {
|
| 45 |
font-size: 1.5em;
|
| 46 |
}
|
| 47 |
+
|
| 48 |
code {
|
| 49 |
color: rgb(202 253 255);
|
| 50 |
}
|
| 51 |
+
|
| 52 |
code1{
|
| 53 |
color: #00b9c2;
|
| 54 |
}
|
| 55 |
+
|
| 56 |
/* Text Emphasis */
|
| 57 |
p, li {
|
| 58 |
text-align: justify;
|
|
|
|
| 100 |
margin: 1.5em 0;
|
| 101 |
}
|
| 102 |
|
| 103 |
+
#component-34.column.svelte-vt1mxs.gap{
|
| 104 |
+
min-width: min(200px, 100%);
|
| 105 |
+
]
|
| 106 |
+
|
| 107 |
+
footer {visibility: hidden}
|
| 108 |
'''
|
| 109 |
|
| 110 |
|
|
|
|
| 121 |
# gr.HTML(md.activity_diagram.format(activity_img_encoded))
|
| 122 |
# gr.HTML(md.component_diagram.format(component_img_encoded))
|
| 123 |
|
| 124 |
+
with gr.TabItem("Simple OCR"):
|
| 125 |
+
gr.Markdown("Paddle OCR")
|
| 126 |
+
with gr.Row():
|
| 127 |
+
with gr.Column(scale=0.75, min_width=300):
|
| 128 |
+
image_input = gr.Image(label="Upload Image")
|
| 129 |
+
with gr.Row():
|
| 130 |
+
clear_btn = gr.ClearButton()
|
| 131 |
+
submit_btn = gr.Button("Submit", variant='primary')
|
| 132 |
+
output_text = gr.Text(label="Output")
|
| 133 |
+
|
| 134 |
+
gr.Examples()
|
| 135 |
+
|
| 136 |
+
submit_btn.click(fn=lambda img: ObjCharRec.ocr_with_paddle(img)[0], inputs=image_input, outputs=output_text)
|
| 137 |
+
clear_btn.click(lambda :[None]*2, outputs=[image_input, output_text])
|
| 138 |
+
|
| 139 |
with gr.TabItem("⭐Translator"):
|
| 140 |
with gr.Row():
|
| 141 |
+
with gr.Column(scale=0.75, min_width=300):
|
| 142 |
with gr.Row():
|
| 143 |
image_input = gr.Image(label="Upload Image")
|
| 144 |
|
| 145 |
with gr.Row():
|
| 146 |
clear_btn = gr.ClearButton()
|
| 147 |
+
submit_btn = gr.Button("Submit", variant='primary')
|
| 148 |
with gr.Column():
|
| 149 |
with gr.Row():
|
| 150 |
output_text = gr.Text(label="Output")
|
| 151 |
audio_out = gr.Audio(label="Streamed Audio")
|
| 152 |
lang_drop = gr.Dropdown(langs_dict, label="language", interactive=True)
|
| 153 |
+
translate_btn = gr.Button("Translate", variant='primary')
|
| 154 |
with gr.Row():
|
| 155 |
translated_txt = gr.Text(label="translated text")
|
| 156 |
translated_out = gr.Audio(label="Streamed Audio")
|
| 157 |
|
| 158 |
submit_btn.click(fn=ObjCharRec.ocr_with_paddle, inputs=image_input, outputs=[output_text, audio_out])
|
| 159 |
+
translate_btn.click(fn=translate_speak.translate_txt, inputs=[lang_drop, output_text], outputs=[translated_txt, translated_out])
|
|
|
|
| 160 |
clear_btn.click(lambda: [None] * 5, outputs=[image_input, output_text, translated_txt, translated_out, audio_out])
|
| 161 |
|
| 162 |
+
with gr.TabItem("🔜OCR Lens"):
|
|
|
|
| 163 |
with gr.Row():
|
| 164 |
+
with gr.Row():
|
| 165 |
+
with gr.Column(scale=2):
|
| 166 |
+
image_input = gr.Image(label="Upload Image")
|
| 167 |
+
input_output_text = gr.Text()
|
| 168 |
+
input_audio_out = gr.Audio()
|
| 169 |
+
with gr.Row():
|
| 170 |
+
with gr.Column(scale=1):
|
| 171 |
+
lang_abbr = {'english': 'en', 'telugu' : 'te', 'hindi': 'hi', 'kannada': 'ka', 'tamil': 'ta', 'arabic': 'ar', 'french': 'fr', 'german': 'german', 'korean': 'korean', 'Japanese': 'japan'}
|
| 172 |
+
ocr_lang = gr.Dropdown(list(lang_abbr.keys()), label="Image-language", interactive=True)
|
| 173 |
+
submit_btn = gr.Button("Submit", variant='primary')
|
| 174 |
+
|
| 175 |
+
lang_drop = gr.Dropdown(langs_dict, label="language", interactive=True)
|
| 176 |
+
translate_btn = gr.Button("Translate", variant='primary')
|
| 177 |
+
|
| 178 |
clear_btn = gr.ClearButton()
|
| 179 |
+
with gr.Row():
|
| 180 |
+
with gr.Column(scale=2):
|
| 181 |
+
image_output = gr.Image(label="Upload Image")
|
| 182 |
+
output_output_text = gr.Text()
|
| 183 |
+
output_audio_out = gr.Audio()
|
| 184 |
|
| 185 |
+
clear_btn.click(lambda: [None] * 6,outputs=[image_input, input_output_text, input_audio_out, image_output, output_output_text, output_audio_out])
|
| 186 |
+
submit_btn.click(fn=None, inputs=[image_input, ocr_lang], outputs=[image_input, input_output_text, input_audio_out])
|
| 187 |
+
translate_btn.click(fn=None, inputs=[])
|
| 188 |
|
| 189 |
gr.HTML(md.footer.format(github_logo_encoded, linkedin_logo_encoded, website_logo_encoded))
|
|
|
|
| 190 |
|
| 191 |
|
| 192 |
if __name__ == "__main__":
|
| 193 |
+
main_interface.launch()
|