Spaces:
Sleeping
Sleeping
Delete app.py
Browse files
app.py
DELETED
@@ -1,34 +0,0 @@
|
|
1 |
-
import gradio as gr
|
2 |
-
from transformers import pipeline
|
3 |
-
|
4 |
-
# Carregar o pipeline de geração de imagens
|
5 |
-
pipe = pipeline("image-generation", model="stabilityai/stable-diffusion-2-1")
|
6 |
-
|
7 |
-
def generate_image(prompt):
|
8 |
-
"""
|
9 |
-
Gera uma imagem com base em um prompt textual usando o modelo.
|
10 |
-
"""
|
11 |
-
try:
|
12 |
-
# Gera a imagem
|
13 |
-
image = pipe(prompt, num_inference_steps=50, guidance_scale=7.5)[0]["image"]
|
14 |
-
return image
|
15 |
-
except Exception as e:
|
16 |
-
return f"Erro ao gerar imagem: {str(e)}"
|
17 |
-
|
18 |
-
# Configurar a interface do Gradio
|
19 |
-
with gr.Blocks() as demo:
|
20 |
-
gr.Markdown("## Gerador de Imagens com Texto - Stable Diffusion")
|
21 |
-
|
22 |
-
with gr.Row():
|
23 |
-
with gr.Column():
|
24 |
-
prompt = gr.Textbox(label="Texto (Prompt)", placeholder="Descreva a imagem que deseja gerar...")
|
25 |
-
submit_button = gr.Button("Gerar Imagem")
|
26 |
-
|
27 |
-
with gr.Column():
|
28 |
-
output_image = gr.Image(label="Imagem Gerada")
|
29 |
-
|
30 |
-
submit_button.click(fn=generate_image, inputs=prompt, outputs=output_image)
|
31 |
-
|
32 |
-
# Executar o app
|
33 |
-
if __name__ == "__main__":
|
34 |
-
demo.launch(server_name="0.0.0.0", server_port=7860)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|