File size: 2,495 Bytes
39ac521
a951bd6
39ac521
 
a951bd6
39ac521
a951bd6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
39ac521
 
a951bd6
39ac521
a951bd6
 
 
 
 
 
 
 
 
 
 
 
 
39ac521
a951bd6
 
39ac521
a951bd6
 
 
 
39ac521
a951bd6
 
 
 
 
 
39ac521
a951bd6
 
 
 
 
 
 
 
 
 
 
 
 
 
39ac521
a951bd6
 
 
 
 
 
 
 
 
 
 
39ac521
 
a951bd6
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
import gradio as gr
from diffusers import AutoPipelineForText2Image
import torch

# Model ve pipeline kurulumu
device = "cuda" if torch.cuda.is_available() else "cpu"
pipeline = AutoPipelineForText2Image.from_pretrained(
    "black-forest-labs/FLUX.1-dev",
    torch_dtype=torch.float16
).to(device)

# LoRA modelini yükle
pipeline.load_lora_weights("codermert/gamzekocc_fluxx", weight_name="lora.safetensors")

def generate_image(prompt, negative_prompt, guidance_scale):
    # TOK trigger'ını otomatik ekle
    if not prompt.startswith("TOK"):
        prompt = "TOK, " + prompt
    
    # Görseli oluştur
    image = pipeline(
        prompt=prompt,
        negative_prompt=negative_prompt,
        guidance_scale=float(guidance_scale)
    ).images[0]
    
    return image

# Gradio arayüzü
with gr.Blocks(title="Mert Baba'nın Görsel Oluşturucusu") as demo:
    gr.Markdown("""
    # 🎨 Mert Baba'nın AI Görsel Oluşturucusu
    FLUX LoRA modeli ile özel görseller oluşturun!
    """)
    
    with gr.Row():
        with gr.Column():
            prompt = gr.Textbox(
                label="Prompt",
                placeholder="Görsel için açıklama girin...",
                lines=3
            )
            negative_prompt = gr.Textbox(
                label="Negative Prompt",
                value="blurry, bad quality, worst quality, jpeg artifacts",
                lines=2
            )
            guidance_scale = gr.Slider(
                minimum=1,
                maximum=20,
                value=7.5,
                step=0.5,
                label="Guidance Scale"
            )
            generate_btn = gr.Button("Görsel Oluştur 🎨")
        
        with gr.Column():
            output_image = gr.Image(label="Oluşturulan Görsel")
    
    # Örnek promptlar
    gr.Examples(
        examples=[
            ["A striking woman lit with bi-color directional lighting poses", 
             "blurry, bad quality, worst quality, jpeg artifacts",
             7.5],
            ["A beautiful portrait photo in a city", 
             "blurry, bad quality",
             7.5],
        ],
        inputs=[prompt, negative_prompt, guidance_scale],
        outputs=output_image,
        fn=generate_image,
        cache_examples=True,
    )
    
    # Butona tıklayınca çalışacak fonksiyon
    generate_btn.click(
        fn=generate_image,
        inputs=[prompt, negative_prompt, guidance_scale],
        outputs=output_image
    )

demo.launch()