MRuslanR commited on
Commit
0b99225
·
1 Parent(s): 1698b81

initial commit

Browse files
Files changed (2) hide show
  1. app.py +29 -0
  2. requirements.txt +76 -0
app.py ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from rembg import remove
3
+ from PIL import Image
4
+ import numpy as np
5
+
6
+
7
+ def remove_background(input_image):
8
+ # Конвертируем изображение из Gradio в PIL
9
+ image = Image.fromarray(input_image.astype('uint8'), 'RGB')
10
+
11
+ # Удаляем фон с помощью U²-Net
12
+ output_image = remove(image)
13
+
14
+ # Конвертируем результат обратно в numpy array для Gradio
15
+ return np.array(output_image)
16
+
17
+
18
+ # Создаем интерфейс с примерами изображений для теста
19
+ demo = gr.Interface(
20
+ fn=remove_background,
21
+ inputs=gr.Image(label="Загрузите фото"),
22
+ outputs=gr.Image(label="Результат без фона"),
23
+ title="Background Remover",
24
+ description="Загрузите фото → получите PNG без фона!"
25
+ )
26
+
27
+
28
+ if __name__ == "__main__":
29
+ demo.launch(share=False)
requirements.txt ADDED
@@ -0,0 +1,76 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ aiofiles==23.2.1
2
+ annotated-types==0.7.0
3
+ anyio==4.8.0
4
+ attrs==25.1.0
5
+ certifi==2025.1.31
6
+ charset-normalizer==3.4.1
7
+ click==8.1.8
8
+ coloredlogs==15.0.1
9
+ fastapi==0.115.8
10
+ ffmpy==0.5.0
11
+ filelock==3.17.0
12
+ flatbuffers==25.1.24
13
+ fsspec==2025.2.0
14
+ gradio==5.14.0
15
+ gradio_client==1.7.0
16
+ h11==0.14.0
17
+ httpcore==1.0.7
18
+ httpx==0.28.1
19
+ huggingface-hub==0.28.1
20
+ humanfriendly==10.0
21
+ idna==3.10
22
+ imageio==2.37.0
23
+ Jinja2==3.1.5
24
+ jsonschema==4.23.0
25
+ jsonschema-specifications==2024.10.1
26
+ lazy_loader==0.4
27
+ llvmlite==0.44.0
28
+ markdown-it-py==3.0.0
29
+ MarkupSafe==2.1.5
30
+ mdurl==0.1.2
31
+ mpmath==1.3.0
32
+ networkx==3.4.2
33
+ numba==0.61.0
34
+ numpy==2.1.3
35
+ onnxruntime==1.20.1
36
+ opencv-python-headless==4.11.0.86
37
+ orjson==3.10.15
38
+ packaging==24.2
39
+ pandas==2.2.3
40
+ pillow==11.1.0
41
+ platformdirs==4.3.6
42
+ pooch==1.8.2
43
+ protobuf==5.29.3
44
+ pydantic==2.10.6
45
+ pydantic_core==2.27.2
46
+ pydub==0.25.1
47
+ Pygments==2.19.1
48
+ PyMatting==1.1.13
49
+ python-dateutil==2.9.0.post0
50
+ python-multipart==0.0.20
51
+ pytz==2025.1
52
+ PyYAML==6.0.2
53
+ referencing==0.36.2
54
+ rembg==2.0.62
55
+ requests==2.32.3
56
+ rich==13.9.4
57
+ rpds-py==0.22.3
58
+ ruff==0.9.4
59
+ safehttpx==0.1.6
60
+ scikit-image==0.25.1
61
+ scipy==1.15.1
62
+ semantic-version==2.10.0
63
+ shellingham==1.5.4
64
+ six==1.17.0
65
+ sniffio==1.3.1
66
+ starlette==0.45.3
67
+ sympy==1.13.3
68
+ tifffile==2025.1.10
69
+ tomlkit==0.13.2
70
+ tqdm==4.67.1
71
+ typer==0.15.1
72
+ typing_extensions==4.12.2
73
+ tzdata==2025.1
74
+ urllib3==2.3.0
75
+ uvicorn==0.34.0
76
+ websockets==14.2