rafaldembski commited on
Commit
3479302
verified
1 Parent(s): f914a7f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +87 -14
app.py CHANGED
@@ -125,17 +125,90 @@ def inference(image):
125
 
126
  return [im_rgba, pil_mask]
127
 
128
- title = "Image Segmentation"
129
- description = ""
130
- article = ""
131
-
132
- interface = gr.Interface(
133
- fn=inference,
134
- inputs=gr.Image(type='filepath'),
135
- outputs=["image", "image"],
136
- title=title,
137
- description=description,
138
- article=article,
139
- allow_flagging='never',
140
- cache_examples=False,
141
- ).queue().launch(show_error=True)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
125
 
126
  return [im_rgba, pil_mask]
127
 
128
+ # Translations for multi-language support
129
+ translations = {
130
+ "pl": {
131
+ "title": "Zaawansowane Segmentowanie Obraz贸w",
132
+ "description": """
133
+ # Zaawansowane Segmentowanie Obraz贸w
134
+
135
+ **Zaawansowane Segmentowanie Obraz贸w** to zaawansowane narz臋dzie oparte na sztucznej inteligencji, zaprojektowane do precyzyjnego segmentowania obraz贸w. Aplikacja ta wykorzystuje najnowsze technologie g艂臋bokiego uczenia, aby generowa膰 dok艂adne maski dla r贸偶nych typ贸w obraz贸w. Stworzona przez ekspert贸w, oferuje u偶ytkownikom intuicyjny interfejs do przetwarzania obraz贸w. Niezale偶nie od tego, czy jest u偶ywana do cel贸w zawodowych, czy do projekt贸w osobistych, to narz臋dzie zapewnia najwy偶sz膮 jako艣膰 i niezawodno艣膰 w zadaniach segmentacji obraz贸w.
136
+ """,
137
+ "article": """
138
+ ## Technologie
139
+
140
+ - **Model**: ISNetDIS
141
+ - **Stworzony przez**: Rafa艂 Dembski
142
+ - **Technologie**: PyTorch, Gradio, OpenCV
143
+ """
144
+ },
145
+ "en": {
146
+ "title": "Advanced Image Segmentation",
147
+ "description": """
148
+ # Advanced Image Segmentation
149
+
150
+ **Advanced Image Segmentation** is a cutting-edge AI-powered tool developed to provide highly accurate image segmentation. This application utilizes state-of-the-art deep learning techniques to generate precise masks for various types of images. Developed by experts, it offers users an intuitive interface to process their images effortlessly. Whether for professional use or personal projects, this tool ensures superior quality and reliability in image segmentation tasks.
151
+ """,
152
+ "article": """
153
+ ## Technologies
154
+
155
+ - **Model**: ISNetDIS
156
+ - **Developed by**: Rafa艂 Dembski
157
+ - **Technologies**: PyTorch, Gradio, OpenCV
158
+ """
159
+ },
160
+ "de": {
161
+ "title": "Fortschrittliche Bildsegmentierung",
162
+ "description": """
163
+ # Fortschrittliche Bildsegmentierung
164
+
165
+ **Fortschrittliche Bildsegmentierung** ist ein fortschrittliches KI-gest眉tztes Tool, das entwickelt wurde, um hochpr盲zise Bildsegmentierung zu erm枚glichen. Diese Anwendung nutzt modernste Techniken des Deep Learnings, um pr盲zise Masken f眉r verschiedene Arten von Bildern zu erstellen. Entwickelt von Experten, bietet es den Benutzern eine intuitive Oberfl盲che zur m眉helosen Verarbeitung ihrer Bilder. Ob f眉r professionelle Zwecke oder pers枚nliche Projekte, dieses Tool gew盲hrleistet h枚chste Qualit盲t und Zuverl盲ssigkeit bei Segmentierungsaufgaben.
166
+ """,
167
+ "article": """
168
+ ## Technologien
169
+
170
+ - **Modell**: ISNetDIS
171
+ - **Entwickelt von**: Rafa艂 Dembski
172
+ - **Technologien**: PyTorch, Gradio, OpenCV
173
+ """
174
+ }
175
+ }
176
+
177
+ # Gradio setup with Monochrome theme, logo, and description with language support
178
+ css = """
179
+ #col-container {
180
+ margin: 0 auto;
181
+ max-width: 520px;
182
+ }
183
+ """
184
+
185
+ def change_language(lang):
186
+ return translations[lang]['title'], translations[lang]['description'], translations[lang]['article']
187
+
188
+ with gr.Blocks(theme=gr.themes.Monochrome(), css=css) as demo:
189
+ language_selector = gr.Dropdown(choices=["pl", "en", "de"], value="en", label="Wybierz j臋zyk / Select Language / Sprache ausw盲hlen", show_label=True)
190
+
191
+ title = gr.Markdown(translations["en"]["title"])
192
+ description = gr.Markdown(translations["en"]["description"])
193
+ article = gr.Markdown(translations["en"]["article"])
194
+
195
+ with gr.Row():
196
+ prompt = gr.Image(type='filepath')
197
+ result = gr.Image(label="Segmented Image", show_label=False)
198
+
199
+ language_selector.change(
200
+ fn=change_language,
201
+ inputs=language_selector,
202
+ outputs=[title, description, article],
203
+ )
204
+
205
+ gr.Interface(
206
+ fn=inference,
207
+ inputs=prompt,
208
+ outputs=[result],
209
+ title=title,
210
+ description=description,
211
+ article=article,
212
+ allow_flagging='never',
213
+ cache_examples=False,
214
+ ).launch()