Spaces:
Build error
Build error
Delete app.py
Browse files
app.py
DELETED
|
@@ -1,25 +0,0 @@
|
|
| 1 |
-
import gradio as gr
|
| 2 |
-
from diffusers import StableDiffusionPipeline
|
| 3 |
-
import torch
|
| 4 |
-
|
| 5 |
-
# Carregue o modelo do Hugging Face Model Hub
|
| 6 |
-
MODEL_NAME = "runwayml/stable-diffusion-v1-5" # Escolha seu modelo aqui
|
| 7 |
-
pipe = StableDiffusionPipeline.from_pretrained(MODEL_NAME, torch_dtype=torch.float16)
|
| 8 |
-
pipe = pipe.to("cuda") # Envia para a GPU
|
| 9 |
-
|
| 10 |
-
# Função que gera uma imagem a partir do prompt
|
| 11 |
-
def generate_image(prompt):
|
| 12 |
-
image = pipe(prompt).images[0]
|
| 13 |
-
return image
|
| 14 |
-
|
| 15 |
-
# Interface Gradio para o usuário
|
| 16 |
-
interface = gr.Interface(
|
| 17 |
-
fn=generate_image, # Função que será chamada
|
| 18 |
-
inputs=gr.Textbox(label="Escreva um prompt para a imagem"),
|
| 19 |
-
outputs=gr.Image(label="Imagem Gerada"),
|
| 20 |
-
title="Gerador de Imagens com Stable Diffusion"
|
| 21 |
-
)
|
| 22 |
-
|
| 23 |
-
# Execute a interface
|
| 24 |
-
if __name__ == "__main__":
|
| 25 |
-
interface.launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|