Spaces:
Sleeping
Sleeping
Commit
·
3390451
1
Parent(s):
7384288
v.1.21+
Browse files
app.py
CHANGED
@@ -285,6 +285,34 @@ class EventDetector:
|
|
285 |
except Exception as e:
|
286 |
logger.error(f"Error in cleanup: {e}")
|
287 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
288 |
@spaces.GPU
|
289 |
def process_file(file_obj):
|
290 |
try:
|
@@ -395,7 +423,7 @@ def create_interface():
|
|
395 |
control = ProcessControl()
|
396 |
|
397 |
with gr.Blocks(theme=gr.themes.Soft()) as app:
|
398 |
-
gr.Markdown("# AI-анализ мониторинга новостей v.1.21")
|
399 |
|
400 |
with gr.Row():
|
401 |
file_input = gr.File(
|
|
|
285 |
except Exception as e:
|
286 |
logger.error(f"Error in cleanup: {e}")
|
287 |
|
288 |
+
def create_visualizations(df):
|
289 |
+
if df is None or df.empty:
|
290 |
+
return None, None
|
291 |
+
|
292 |
+
try:
|
293 |
+
sentiments = df['Sentiment'].value_counts()
|
294 |
+
fig_sentiment = go.Figure(data=[go.Pie(
|
295 |
+
labels=sentiments.index,
|
296 |
+
values=sentiments.values,
|
297 |
+
marker_colors=['#FF6B6B', '#4ECDC4', '#95A5A6']
|
298 |
+
)])
|
299 |
+
fig_sentiment.update_layout(title="Распределение тональности")
|
300 |
+
|
301 |
+
events = df['Event_Type'].value_counts()
|
302 |
+
fig_events = go.Figure(data=[go.Bar(
|
303 |
+
x=events.index,
|
304 |
+
y=events.values,
|
305 |
+
marker_color='#2196F3'
|
306 |
+
)])
|
307 |
+
fig_events.update_layout(title="Распределение событий")
|
308 |
+
|
309 |
+
return fig_sentiment, fig_events
|
310 |
+
|
311 |
+
except Exception as e:
|
312 |
+
logger.error(f"Visualization error: {e}")
|
313 |
+
return None, None
|
314 |
+
|
315 |
+
|
316 |
@spaces.GPU
|
317 |
def process_file(file_obj):
|
318 |
try:
|
|
|
423 |
control = ProcessControl()
|
424 |
|
425 |
with gr.Blocks(theme=gr.themes.Soft()) as app:
|
426 |
+
gr.Markdown("# AI-анализ мониторинга новостей v.1.21+")
|
427 |
|
428 |
with gr.Row():
|
429 |
file_input = gr.File(
|