File size: 769 Bytes
684e9f3
d5238b1
666f8bf
d48e497
666f8bf
684e9f3
4f1e465
666f8bf
684e9f3
4f1e465
d48e497
 
4f1e465
 
666f8bf
 
d48e497
98f0f16
d48e497
 
98f0f16
d48e497
666f8bf
 
 
98f0f16
4f1e465
d48e497
4f1e465
684e9f3
55bf26f
d48e497
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import os
import torch
import gradio as gr
from diffusers import StableDiffusion3Pipeline
from huggingface_hub import login

# Login com token via Secrets
login(os.environ["HF_TOKEN"])

# Carregar pipeline (sem variant)
pipe = StableDiffusion3Pipeline.from_pretrained(
    "stabilityai/stable-diffusion-3.5-medium",
    torch_dtype=torch.float16
).to("cuda")

def gerar_imagem(prompt):
    image = pipe(
        prompt,
        num_inference_steps=30,
        guidance_scale=4.5
    ).images[0]
    return image

demo = gr.Interface(
    fn=gerar_imagem,
    inputs=gr.Textbox(label="Prompt"),
    outputs=gr.Image(label="Imagem"),
    title="Stable Diffusion 3.5 Medium",
    description="Gere imagens com SD3.5 diretamente no Hugging Face"
)

demo.launch(share=True)