Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,98 +1,118 @@
|
|
1 |
-
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6 |
|
7 |
-
|
|
|
|
|
|
|
|
|
|
|
8 |
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
'summarization': pipeline("summarization", model="facebook/bart-large-cnn", device=device),
|
14 |
-
'sentiment': pipeline("sentiment-analysis", model="nlptown/bert-base-multilingual-uncased-sentiment", device=device),
|
15 |
-
'question_answering': pipeline("question-answering", model="deepset/roberta-base-squad2", device=device),
|
16 |
-
'chat': pipeline("text-generation", model="facebook/opt-125m", device=device),
|
17 |
-
'image_caption': pipeline("image-to-text", model="Salesforce/blip-image-captioning-base", device=device),
|
18 |
-
'text_to_speech': pipeline("text-to-audio", model="facebook/mms-tts-eng", device=device),
|
19 |
-
'zero_shot': pipeline("zero-shot-classification", model="facebook/bart-large-mnli", device=device),
|
20 |
-
'ner': pipeline("token-classification", model="dslim/bert-base-NER", device=device)
|
21 |
-
}
|
22 |
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
'translation': lambda text, direction: models['translation'](text,
|
30 |
-
src_lang="pt" if direction=="pt_en" else "en",
|
31 |
-
tgt_lang="en" if direction=="pt_en" else "pt")[0]['translation_text'],
|
32 |
-
'summarization': lambda text: models['summarization'](text, max_length=130, min_length=30)[0]['summary_text'],
|
33 |
-
'sentiment': lambda text: models['sentiment'](text)[0]['label'],
|
34 |
-
'qa': lambda q, ctx: models['question_answering'](question=q, context=ctx)['answer'],
|
35 |
-
'chat': lambda msg, history: (models['chat'](msg, max_length=100, do_sample=True)[0]['generated_text'], history + [(msg, "")]),
|
36 |
-
'image_caption': lambda img: models['image_caption'](img)[0]['generated_text'],
|
37 |
-
'tts': lambda text: models['text_to_speech'](text),
|
38 |
-
'zero_shot': lambda text, labels: models['zero_shot'](text, labels)['labels'][0],
|
39 |
-
'ner': lambda text: models['ner'](text)
|
40 |
}
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
45 |
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
transcribe_button = gr.Button("Transcrever")
|
53 |
-
transcription_output = gr.Textbox(label="Resultado")
|
54 |
-
transcribe_button.click(lambda x: process_request('transcription', x), inputs=audio_input, outputs=transcription_output)
|
55 |
-
|
56 |
-
with gr.TabItem("🔄 Tradução"):
|
57 |
-
with gr.Row():
|
58 |
-
text_to_translate = gr.Textbox(label="Texto")
|
59 |
-
translation_direction = gr.Radio(["en_pt", "pt_en"], value="en_pt")
|
60 |
-
translate_button = gr.Button("Traduzir")
|
61 |
-
translation_output = gr.Textbox(label="Resultado")
|
62 |
-
translate_button.click(lambda x, y: process_request('translation', x, y),
|
63 |
-
inputs=[text_to_translate, translation_direction],
|
64 |
-
outputs=translation_output)
|
65 |
-
|
66 |
-
with gr.TabItem("📊 Análise"):
|
67 |
-
with gr.Tabs():
|
68 |
-
with gr.TabItem("Resumo"):
|
69 |
-
text_sum = gr.Textbox(label="Texto", lines=5)
|
70 |
-
sum_button = gr.Button("Resumir")
|
71 |
-
sum_output = gr.Textbox(label="Resultado")
|
72 |
-
sum_button.click(lambda x: process_request('summarization', x), inputs=text_sum, outputs=sum_output)
|
73 |
-
|
74 |
-
with gr.TabItem("Sentimento"):
|
75 |
-
text_sent = gr.Textbox(label="Texto")
|
76 |
-
sent_button = gr.Button("Analisar")
|
77 |
-
sent_output = gr.Textbox(label="Resultado")
|
78 |
-
sent_button.click(lambda x: process_request('sentiment', x), inputs=text_sent, outputs=sent_output)
|
79 |
-
|
80 |
-
with gr.TabItem("🤖 IA Avançada"):
|
81 |
-
with gr.Tabs():
|
82 |
-
with gr.TabItem("Chat"):
|
83 |
-
chatbot = gr.Chatbot()
|
84 |
-
msg = gr.Textbox(label="Mensagem")
|
85 |
-
clear = gr.Button("Limpar")
|
86 |
-
msg.submit(lambda x, y: process_request('chat', x, y), inputs=[msg, chatbot], outputs=[msg, chatbot])
|
87 |
-
clear.click(lambda: None, None, chatbot, queue=False)
|
88 |
-
|
89 |
-
with gr.TabItem("Classificação"):
|
90 |
-
zero_text = gr.Textbox(label="Texto")
|
91 |
-
zero_labels = gr.Textbox(label="Categorias (separadas por vírgula)")
|
92 |
-
zero_button = gr.Button("Classificar")
|
93 |
-
zero_output = gr.Textbox(label="Resultado")
|
94 |
-
zero_button.click(lambda x, y: process_request('zero_shot', x, y.split(',')),
|
95 |
-
inputs=[zero_text, zero_labels],
|
96 |
-
outputs=zero_output)
|
97 |
|
98 |
-
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<!DOCTYPE html>
|
2 |
+
<html lang="pt-BR">
|
3 |
+
<head>
|
4 |
+
<meta charset="UTF-8">
|
5 |
+
<title>Central de IA - Bem-vindo</title>
|
6 |
+
<style>
|
7 |
+
.container {
|
8 |
+
max-width: 800px;
|
9 |
+
margin: 2rem auto;
|
10 |
+
padding: 0 1rem;
|
11 |
+
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
|
12 |
+
}
|
13 |
+
|
14 |
+
.header {
|
15 |
+
text-align: center;
|
16 |
+
margin-bottom: 3rem;
|
17 |
+
padding: 2rem;
|
18 |
+
background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
|
19 |
+
border-radius: 1rem;
|
20 |
+
color: white;
|
21 |
+
}
|
22 |
+
|
23 |
+
.header h1 {
|
24 |
+
margin: 0;
|
25 |
+
font-size: 2.5rem;
|
26 |
+
font-weight: 700;
|
27 |
+
}
|
28 |
+
|
29 |
+
.header p {
|
30 |
+
margin: 1rem 0 0;
|
31 |
+
font-size: 1.1rem;
|
32 |
+
opacity: 0.9;
|
33 |
+
}
|
34 |
+
|
35 |
+
.features {
|
36 |
+
display: grid;
|
37 |
+
grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
|
38 |
+
gap: 2rem;
|
39 |
+
margin: 3rem 0;
|
40 |
+
}
|
41 |
+
|
42 |
+
.feature-card {
|
43 |
+
padding: 1.5rem;
|
44 |
+
background: white;
|
45 |
+
border-radius: 0.75rem;
|
46 |
+
box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
|
47 |
+
transition: transform 0.2s;
|
48 |
+
}
|
49 |
+
|
50 |
+
.feature-card:hover {
|
51 |
+
transform: translateY(-4px);
|
52 |
+
}
|
53 |
+
|
54 |
+
.feature-icon {
|
55 |
+
font-size: 2rem;
|
56 |
+
margin-bottom: 1rem;
|
57 |
+
}
|
58 |
|
59 |
+
.feature-title {
|
60 |
+
font-size: 1.25rem;
|
61 |
+
font-weight: 600;
|
62 |
+
margin-bottom: 0.5rem;
|
63 |
+
color: #1f2937;
|
64 |
+
}
|
65 |
|
66 |
+
.feature-description {
|
67 |
+
color: #6b7280;
|
68 |
+
line-height: 1.5;
|
69 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
70 |
|
71 |
+
.footer {
|
72 |
+
text-align: center;
|
73 |
+
margin-top: 3rem;
|
74 |
+
padding: 2rem;
|
75 |
+
color: #6b7280;
|
76 |
+
border-top: 1px solid #e5e7eb;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
77 |
}
|
78 |
+
</style>
|
79 |
+
</head>
|
80 |
+
<body>
|
81 |
+
<div class="container">
|
82 |
+
<header class="header">
|
83 |
+
<h1>Central de Inteligência Artificial</h1>
|
84 |
+
<p>Uma plataforma completa com ferramentas de IA para suas necessidades</p>
|
85 |
+
</header>
|
86 |
+
|
87 |
+
<div class="features">
|
88 |
+
<div class="feature-card">
|
89 |
+
<div class="feature-icon">📝</div>
|
90 |
+
<h3 class="feature-title">Transcrição de Áudio</h3>
|
91 |
+
<p class="feature-description">Converta áudio em texto com precisão usando tecnologia de ponta em reconhecimento de fala.</p>
|
92 |
+
</div>
|
93 |
+
|
94 |
+
<div class="feature-card">
|
95 |
+
<div class="feature-icon">🔄</div>
|
96 |
+
<h3 class="feature-title">Tradução</h3>
|
97 |
+
<p class="feature-description">Traduza textos entre português e inglês com nossa ferramenta de tradução neural.</p>
|
98 |
+
</div>
|
99 |
+
|
100 |
+
<div class="feature-card">
|
101 |
+
<div class="feature-icon">📊</div>
|
102 |
+
<h3 class="feature-title">Análise de Texto</h3>
|
103 |
+
<p class="feature-description">Gere resumos automáticos e analise o sentimento de textos com facilidade.</p>
|
104 |
+
</div>
|
105 |
|
106 |
+
<div class="feature-card">
|
107 |
+
<div class="feature-icon">🤖</div>
|
108 |
+
<h3 class="feature-title">IA Avançada</h3>
|
109 |
+
<p class="feature-description">Experimente nosso chatbot inteligente e classificação automática de textos.</p>
|
110 |
+
</div>
|
111 |
+
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
112 |
|
113 |
+
<footer class="footer">
|
114 |
+
<p>Desenvolvido com tecnologia de ponta em Inteligência Artificial</p>
|
115 |
+
</footer>
|
116 |
+
</div>
|
117 |
+
</body>
|
118 |
+
</html>
|