TugceL / app.py
codermert's picture
Create app.py
c3dc8bf verified
raw
history blame
809 Bytes
import gradio as gr
from diffusers import StableDiffusionPipeline
import torch
# Hugging Face'den FLUX modelini yükle
model_id = "black-forest-labs/FLUX.1-dev"
pipe = StableDiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.float16)
pipe = pipe.to("cuda") # GPU üzerinde çalışmak için CUDA'yı kullan
# Kendi LoRA modelini FLUX ile birleştir
pipe.unet.load_attn_procs("codermert/tugce2-lora")
# Gradio için resim üretme fonksiyonu
def generate_image(prompt):
image = pipe(prompt).images[0]
return image
# Gradio arayüzü
interface = gr.Interface(
fn=generate_image,
inputs=gr.Textbox(label="Prompt", placeholder="Enter your prompt here"),
outputs=gr.Image(label="Generated Image")
)
# Uygulama başlatılır
if __name__ == "__main__":
interface.launch()