Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from PIL import Image # Needed create blank "proxy image in the functions below
|
3 |
+
|
4 |
+
|
5 |
+
def dummy_process_image(image):
|
6 |
+
"""Заглушка для обработки изображения. Возвращает пустое изображение."""
|
7 |
+
return Image.new("RGB", (256, 256), "white"), Image.new("RGB", (256, 256), "black")
|
8 |
+
|
9 |
+
|
10 |
+
def dummy_process_url(url):
|
11 |
+
|
12 |
+
"""Заглушка для обработки URL. Возвращает пустое изображение."""
|
13 |
+
return Image.new("RGB", (256, 256), "white"), Image.new("RGB", (256, 256), "black")
|
14 |
+
|
15 |
+
def dummy_process_file(filepath):
|
16 |
+
"""Заглушка для обработки файла. Возвращает имя фиктивного файла."""
|
17 |
+
return "dummy_output.png"
|
18 |
+
|
19 |
+
|
20 |
+
with gr.Blocks() as demo:
|
21 |
+
with gr.Tab("Image Upload"):
|
22 |
+
with gr.Row():
|
23 |
+
image_upload = gr.Image(label="Upload an image")
|
24 |
+
output_image = gr.Image(label="Processed Image", type="pil")
|
25 |
+
image_upload.change(dummy_process_image, image_upload, output_image)
|
26 |
+
|
27 |
+
|
28 |
+
with gr.Tab("URL Input"):
|
29 |
+
with gr.Row():
|
30 |
+
url_input = gr.Textbox(label="Paste an image URL")
|
31 |
+
output_url = gr.Image(label="Processed Image from URL", type="pil")
|
32 |
+
url_input.submit(dummy_process_url, url_input, output_url) # Or "submit" is more appropriate for text inputs and not change.
|
33 |
+
|
34 |
+
|
35 |
+
with gr.Tab("File Output"):
|
36 |
+
with gr.Row():
|
37 |
+
image_file_upload = gr.Image(label="Upload an image", type ="filepath")
|
38 |
+
output_file = gr.File(label="Output PNG File")
|
39 |
+
image_file_upload.change(dummy_process_file, image_file_upload, output_file)
|
40 |
+
|
41 |
+
if __name__ == "__main__":
|
42 |
+
demo.launch()
|