File size: 1,423 Bytes
8923aba 9f261f3 031ae3b f726406 a1538f9 9450330 a1538f9 9f261f3 a1538f9 9f261f3 a1538f9 |
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 |
import gradio as gr
import torch
from diffusers import AutoPipelineForText2Image
def generate_image(prompt):
try:
# Pipeline'ı CPU modunda başlat (Space'de GPU yoksa)
pipeline = AutoPipelineForText2Image.from_pretrained(
'prithivMLmods/Canopus-LoRA-Flux-UltraRealism-2.0',
torch_dtype=torch.float16 if torch.cuda.is_available() else torch.float32
).to('cuda' if torch.cuda.is_available() else 'cpu')
# LoRA modelini yükle
pipeline.load_lora_weights(
'codermert/ezelll_flux',
weight_name='flux_train_replicate.safetensors'
)
# Görsel oluştur
image = pipeline(prompt).images[0]
return image
except Exception as e:
return str(e)
# Gradio arayüzünü SSR modu kapalı olarak başlat
with gr.Blocks() as iface:
gr.Markdown("# Ezel Flux Görsel Oluşturucu")
gr.Markdown("Bu model 'zehra' kelimesi ile en iyi sonucu verir.")
with gr.Row():
text_input = gr.Textbox(label="Prompt'unuzu girin (zehra kelimesini kullanmayı unutmayın)")
image_output = gr.Image(label="Oluşturulan Görsel")
generate_btn = gr.Button("Görsel Oluştur")
generate_btn.click(fn=generate_image, inputs=[text_input], outputs=[image_output])
# SSR modunu kapatarak ve kuyruk sistemini etkinleştirerek başlat
iface.queue().launch(ssr_mode=False) |