Spaces:
Sleeping
Sleeping
Commit
·
fff10f8
1
Parent(s):
c1bdb46
amend interface
Browse files
app.py
CHANGED
@@ -905,66 +905,50 @@ def process_and_download(file_bytes, control=None):
|
|
905 |
def create_interface():
|
906 |
control = ProcessControl()
|
907 |
|
908 |
-
with gr.Blocks(
|
909 |
-
|
910 |
-
|
911 |
-
|
912 |
gr.Markdown("# AI-анализ мониторинга новостей v.2.24a + extn")
|
913 |
|
914 |
with gr.Row():
|
915 |
file_input = gr.File(
|
916 |
label="Загрузите Excel файл",
|
917 |
file_types=[".xlsx"],
|
918 |
-
type="binary"
|
919 |
)
|
920 |
|
921 |
with gr.Row():
|
922 |
-
|
923 |
-
|
924 |
-
"▶️ Начать анализ",
|
925 |
-
variant="primary",
|
926 |
-
size="lg"
|
927 |
-
)
|
928 |
-
with gr.Column(scale=1):
|
929 |
-
stop_btn = gr.Button(
|
930 |
-
"⏹️ Остановить",
|
931 |
-
variant="stop",
|
932 |
-
size="lg"
|
933 |
-
)
|
934 |
|
935 |
with gr.Row():
|
936 |
-
|
937 |
-
label="Статус
|
938 |
-
|
939 |
-
|
940 |
)
|
941 |
|
942 |
with gr.Row():
|
943 |
-
|
944 |
-
label="Статус
|
945 |
-
|
946 |
-
|
947 |
)
|
948 |
|
949 |
with gr.Row():
|
950 |
-
stats = gr.
|
951 |
label="Результаты анализа",
|
952 |
interactive=False,
|
953 |
wrap=True
|
954 |
)
|
955 |
|
956 |
with gr.Row():
|
957 |
-
|
958 |
-
|
959 |
-
with gr.Column(scale=1):
|
960 |
-
events_plot = gr.Plot(label="Распределение событий")
|
961 |
|
962 |
with gr.Row():
|
963 |
-
file_output = gr.File(
|
964 |
-
label="Скачать результаты",
|
965 |
-
visible=True,
|
966 |
-
interactive=True
|
967 |
-
)
|
968 |
|
969 |
def stop_processing():
|
970 |
control.request_stop()
|
@@ -972,23 +956,17 @@ def create_interface():
|
|
972 |
|
973 |
stop_btn.click(fn=stop_processing, outputs=[progress])
|
974 |
|
975 |
-
# Main processing with control object passed
|
976 |
analyze_btn.click(
|
977 |
fn=lambda x: process_and_download(x, control),
|
978 |
inputs=[file_input],
|
979 |
-
outputs=[
|
980 |
-
stats,
|
981 |
-
sentiment_plot,
|
982 |
-
events_plot,
|
983 |
-
file_output,
|
984 |
-
progress,
|
985 |
-
status_box
|
986 |
-
]
|
987 |
)
|
988 |
|
989 |
return app
|
990 |
|
991 |
-
|
992 |
if __name__ == "__main__":
|
993 |
app = create_interface()
|
994 |
-
app.launch(
|
|
|
|
|
|
|
|
905 |
def create_interface():
|
906 |
control = ProcessControl()
|
907 |
|
908 |
+
with gr.Blocks(
|
909 |
+
theme=gr.themes.Soft(),
|
910 |
+
title="AI News Analysis"
|
911 |
+
) as app:
|
912 |
gr.Markdown("# AI-анализ мониторинга новостей v.2.24a + extn")
|
913 |
|
914 |
with gr.Row():
|
915 |
file_input = gr.File(
|
916 |
label="Загрузите Excel файл",
|
917 |
file_types=[".xlsx"],
|
918 |
+
type="binary" # Changed for Gradio 5.x
|
919 |
)
|
920 |
|
921 |
with gr.Row():
|
922 |
+
analyze_btn = gr.Button("▶️ Начать анализ", variant="primary")
|
923 |
+
stop_btn = gr.Button("⏹️ Остановить", variant="stop")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
924 |
|
925 |
with gr.Row():
|
926 |
+
progress = gr.Textbox(
|
927 |
+
label="Статус обработки",
|
928 |
+
value="Ожидание файла...",
|
929 |
+
interactive=False
|
930 |
)
|
931 |
|
932 |
with gr.Row():
|
933 |
+
status_box = gr.Textbox(
|
934 |
+
label="Статус дедупликации",
|
935 |
+
value="",
|
936 |
+
interactive=False
|
937 |
)
|
938 |
|
939 |
with gr.Row():
|
940 |
+
stats = gr.Dataframe(
|
941 |
label="Результаты анализа",
|
942 |
interactive=False,
|
943 |
wrap=True
|
944 |
)
|
945 |
|
946 |
with gr.Row():
|
947 |
+
sentiment_plot = gr.Plot(label="Распределение тональности")
|
948 |
+
events_plot = gr.Plot(label="Распределение событий")
|
|
|
|
|
949 |
|
950 |
with gr.Row():
|
951 |
+
file_output = gr.File(label="Скачать результаты")
|
|
|
|
|
|
|
|
|
952 |
|
953 |
def stop_processing():
|
954 |
control.request_stop()
|
|
|
956 |
|
957 |
stop_btn.click(fn=stop_processing, outputs=[progress])
|
958 |
|
|
|
959 |
analyze_btn.click(
|
960 |
fn=lambda x: process_and_download(x, control),
|
961 |
inputs=[file_input],
|
962 |
+
outputs=[stats, sentiment_plot, events_plot, file_output, progress, status_box]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
963 |
)
|
964 |
|
965 |
return app
|
966 |
|
|
|
967 |
if __name__ == "__main__":
|
968 |
app = create_interface()
|
969 |
+
app.launch(
|
970 |
+
server_name="0.0.0.0",
|
971 |
+
server_port=7860
|
972 |
+
)
|