Update app.py
Browse files
app.py
CHANGED
@@ -6,6 +6,8 @@ import cv2
|
|
6 |
import numpy as np
|
7 |
from pydub import AudioSegment
|
8 |
from langdetect import detect
|
|
|
|
|
9 |
|
10 |
# Инициализация клиента для модели HuggingFaceH4/zephyr-7b-beta
|
11 |
client = InferenceClient("HuggingFaceH4/zephyr-7b-beta")
|
@@ -42,6 +44,13 @@ def process_txt(file):
|
|
42 |
text = f.read()
|
43 |
return text
|
44 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
45 |
# Функция для определения языка текста
|
46 |
def detect_language(text):
|
47 |
try:
|
@@ -131,7 +140,7 @@ with gr.Blocks() as demo:
|
|
131 |
with gr.Row():
|
132 |
new_chat_button = gr.Button("Новый чат", variant="secondary")
|
133 |
|
134 |
-
# Felguk Tools: Txt Analyzer
|
135 |
with gr.Tab("Felguk Tools"):
|
136 |
gr.Markdown("## Txt Analyzer")
|
137 |
txt_file = gr.File(label="Загрузите txt файл", file_types=[".txt"])
|
@@ -139,6 +148,12 @@ with gr.Blocks() as demo:
|
|
139 |
analyze_button = gr.Button("Анализировать")
|
140 |
analyze_button.click(fn=analyze_txt, inputs=txt_file, outputs=txt_output)
|
141 |
|
|
|
|
|
|
|
|
|
|
|
|
|
142 |
# Интерфейс чата
|
143 |
chat_interface = gr.ChatInterface(
|
144 |
respond,
|
|
|
6 |
import numpy as np
|
7 |
from pydub import AudioSegment
|
8 |
from langdetect import detect
|
9 |
+
from rembg import remove
|
10 |
+
import io
|
11 |
|
12 |
# Инициализация клиента для модели HuggingFaceH4/zephyr-7b-beta
|
13 |
client = InferenceClient("HuggingFaceH4/zephyr-7b-beta")
|
|
|
44 |
text = f.read()
|
45 |
return text
|
46 |
|
47 |
+
# Функция для удаления фона с изображения
|
48 |
+
def remove_background(image):
|
49 |
+
if image is None:
|
50 |
+
return None
|
51 |
+
output = remove(image)
|
52 |
+
return output
|
53 |
+
|
54 |
# Функция для определения языка текста
|
55 |
def detect_language(text):
|
56 |
try:
|
|
|
140 |
with gr.Row():
|
141 |
new_chat_button = gr.Button("Новый чат", variant="secondary")
|
142 |
|
143 |
+
# Felguk Tools: Txt Analyzer и Remove Background
|
144 |
with gr.Tab("Felguk Tools"):
|
145 |
gr.Markdown("## Txt Analyzer")
|
146 |
txt_file = gr.File(label="Загрузите txt файл", file_types=[".txt"])
|
|
|
148 |
analyze_button = gr.Button("Анализировать")
|
149 |
analyze_button.click(fn=analyze_txt, inputs=txt_file, outputs=txt_output)
|
150 |
|
151 |
+
gr.Markdown("## Удаление фона с изображения")
|
152 |
+
image_input = gr.Image(label="Загрузите изображение", type="pil")
|
153 |
+
image_output = gr.Image(label="Результат (без фона)", type="pil")
|
154 |
+
remove_bg_button = gr.Button("Удалить фон")
|
155 |
+
remove_bg_button.click(fn=remove_background, inputs=image_input, outputs=image_output)
|
156 |
+
|
157 |
# Интерфейс чата
|
158 |
chat_interface = gr.ChatInterface(
|
159 |
respond,
|