Spaces:
Sleeping
Sleeping
Commit
·
601d2f9
1
Parent(s):
ff8256a
back 2 async fix3
Browse files
app.py
CHANGED
@@ -771,12 +771,15 @@ def create_output_file(df, uploaded_file):
|
|
771 |
|
772 |
|
773 |
@spaces.GPU(duration=300)
|
774 |
-
def process_and_download(file_bytes):
|
775 |
"""Synchronous wrapper for async processing"""
|
776 |
if file_bytes is None:
|
777 |
gr.Warning("Пожалуйста, загрузите файл")
|
778 |
return pd.DataFrame(), None, None, None, "Ожидание файла...", ""
|
779 |
|
|
|
|
|
|
|
780 |
async def async_process():
|
781 |
detector = None
|
782 |
gpu_manager = GPUTaskManager(
|
@@ -894,7 +897,8 @@ def process_and_download(file_bytes):
|
|
894 |
asyncio.set_event_loop(loop)
|
895 |
|
896 |
return loop.run_until_complete(async_process())
|
897 |
-
|
|
|
898 |
def create_interface():
|
899 |
control = ProcessControl()
|
900 |
|
@@ -902,7 +906,7 @@ def create_interface():
|
|
902 |
# Create state for file data
|
903 |
current_file = gr.State(None)
|
904 |
|
905 |
-
gr.Markdown("# AI-анализ мониторинга новостей v.2.
|
906 |
|
907 |
with gr.Row():
|
908 |
file_input = gr.File(
|
@@ -965,9 +969,9 @@ def create_interface():
|
|
965 |
|
966 |
stop_btn.click(fn=stop_processing, outputs=[progress])
|
967 |
|
968 |
-
# Main processing with
|
969 |
analyze_btn.click(
|
970 |
-
fn=process_and_download,
|
971 |
inputs=[file_input],
|
972 |
outputs=[
|
973 |
stats,
|
|
|
771 |
|
772 |
|
773 |
@spaces.GPU(duration=300)
|
774 |
+
def process_and_download(file_bytes, control=None):
|
775 |
"""Synchronous wrapper for async processing"""
|
776 |
if file_bytes is None:
|
777 |
gr.Warning("Пожалуйста, загрузите файл")
|
778 |
return pd.DataFrame(), None, None, None, "Ожидание файла...", ""
|
779 |
|
780 |
+
if control is None:
|
781 |
+
control = ProcessControl()
|
782 |
+
|
783 |
async def async_process():
|
784 |
detector = None
|
785 |
gpu_manager = GPUTaskManager(
|
|
|
897 |
asyncio.set_event_loop(loop)
|
898 |
|
899 |
return loop.run_until_complete(async_process())
|
900 |
+
|
901 |
+
# Update the interface creation to pass the control object
|
902 |
def create_interface():
|
903 |
control = ProcessControl()
|
904 |
|
|
|
906 |
# Create state for file data
|
907 |
current_file = gr.State(None)
|
908 |
|
909 |
+
gr.Markdown("# AI-анализ мониторинга новостей v.2.2 + extn")
|
910 |
|
911 |
with gr.Row():
|
912 |
file_input = gr.File(
|
|
|
969 |
|
970 |
stop_btn.click(fn=stop_processing, outputs=[progress])
|
971 |
|
972 |
+
# Main processing with control object passed
|
973 |
analyze_btn.click(
|
974 |
+
fn=lambda x: process_and_download(x, control),
|
975 |
inputs=[file_input],
|
976 |
outputs=[
|
977 |
stats,
|